Update app.py
Browse files
app.py
CHANGED
|
@@ -217,7 +217,7 @@ class Translators:
|
|
| 217 |
)
|
| 218 |
# Generate response
|
| 219 |
temperature = 0.7
|
| 220 |
-
with torch.
|
| 221 |
outputs = model.generate(
|
| 222 |
tokenized_chat.to(model.device),
|
| 223 |
max_new_tokens=512,
|
|
@@ -243,7 +243,7 @@ class Translators:
|
|
| 243 |
except Exception as error:
|
| 244 |
return f"Error translating with model: {self.model_name}! Try other available language combination or model.", error
|
| 245 |
|
| 246 |
-
|
| 247 |
model = AutoModelForCausalLM.from_pretrained(
|
| 248 |
self.model_name,
|
| 249 |
dtype=torch.bfloat16,
|
|
|
|
| 217 |
)
|
| 218 |
# Generate response
|
| 219 |
temperature = 0.7
|
| 220 |
+
with torch.inference_mode():
|
| 221 |
outputs = model.generate(
|
| 222 |
tokenized_chat.to(model.device),
|
| 223 |
max_new_tokens=512,
|
|
|
|
| 243 |
except Exception as error:
|
| 244 |
return f"Error translating with model: {self.model_name}! Try other available language combination or model.", error
|
| 245 |
|
| 246 |
+
def rosetta(self):
|
| 247 |
model = AutoModelForCausalLM.from_pretrained(
|
| 248 |
self.model_name,
|
| 249 |
dtype=torch.bfloat16,
|