Update app.py
Browse files
app.py
CHANGED
|
@@ -212,16 +212,16 @@ class Translators:
|
|
| 212 |
return f"Error translating with model: {self.model_name}! Try other available language combination or model.", error
|
| 213 |
|
| 214 |
def salamandraTApipe(self):
|
| 215 |
-
pipe = pipeline("text-generation", model=self.
|
| 216 |
messages = [f"Translate the following text from {self.sl} into {self.tl}.\n{self.sl}: {self.input_text} \n{self.tl}:"]
|
| 217 |
return pipe(messages)[0]["generated_text"]
|
| 218 |
|
| 219 |
def salamandraTA(self):
|
| 220 |
# from datetime import datetime
|
| 221 |
text = f"Translate the following text from {self.sl} into {self.tl}.\n{self.sl}: {self.input_text} \n{self.tl}:"
|
| 222 |
-
tokenizer = AutoTokenizer.from_pretrained(self.
|
| 223 |
model = AutoModelForCausalLM.from_pretrained(
|
| 224 |
-
self.
|
| 225 |
device_map="auto",
|
| 226 |
torch_dtype=torch.bfloat16
|
| 227 |
)
|
|
|
|
| 212 |
return f"Error translating with model: {self.model_name}! Try other available language combination or model.", error
|
| 213 |
|
| 214 |
def salamandraTApipe(self):
|
| 215 |
+
pipe = pipeline("text-generation", model=self.model_name)
|
| 216 |
messages = [f"Translate the following text from {self.sl} into {self.tl}.\n{self.sl}: {self.input_text} \n{self.tl}:"]
|
| 217 |
return pipe(messages)[0]["generated_text"]
|
| 218 |
|
| 219 |
def salamandraTA(self):
|
| 220 |
# from datetime import datetime
|
| 221 |
text = f"Translate the following text from {self.sl} into {self.tl}.\n{self.sl}: {self.input_text} \n{self.tl}:"
|
| 222 |
+
tokenizer = AutoTokenizer.from_pretrained(self.model_name)
|
| 223 |
model = AutoModelForCausalLM.from_pretrained(
|
| 224 |
+
self.model_name,
|
| 225 |
device_map="auto",
|
| 226 |
torch_dtype=torch.bfloat16
|
| 227 |
)
|