Update app.py
Browse files
app.py
CHANGED
|
@@ -36,13 +36,14 @@ models = ["Helsinki-NLP", "QUICKMT", "Argos", "Lego-MT/Lego-MT", "HPLT", "HPLT-O
|
|
| 36 |
"Helsinki-NLP/opus-mt-tc-bible-big-roa-en",
|
| 37 |
"facebook/nllb-200-distilled-600M", "facebook/nllb-200-distilled-1.3B", "facebook/nllb-200-1.3B", "facebook/nllb-200-3.3B",
|
| 38 |
"facebook/mbart-large-50-many-to-many-mmt", "facebook/mbart-large-50-one-to-many-mmt", "facebook/mbart-large-50-many-to-one-mmt",
|
| 39 |
-
"facebook/m2m100_418M", "facebook/m2m100_1.2B",
|
|
|
|
| 40 |
"bigscience/mt0-small", "bigscience/mt0-base", "bigscience/mt0-large", "bigscience/mt0-xl",
|
| 41 |
"bigscience/bloomz-560m", "bigscience/bloomz-1b1", "bigscience/bloomz-1b7", "bigscience/bloomz-3b",
|
| 42 |
"t5-small", "t5-base", "t5-large",
|
| 43 |
"google/flan-t5-small", "google/flan-t5-base", "google/flan-t5-large", "google/flan-t5-xl",
|
| 44 |
"google/madlad400-3b-mt", "Heng666/madlad400-3b-mt-ct2", "Heng666/madlad400-3b-mt-ct2-int8", "Heng666/madlad400-7b-mt-ct2-int8",
|
| 45 |
-
"
|
| 46 |
"BSC-LT/salamandraTA-2b-instruct", "BSC-LT/salamandraTA-7b-instruct",
|
| 47 |
"utter-project/EuroLLM-1.7B", "utter-project/EuroLLM-1.7B-Instruct",
|
| 48 |
"Unbabel/Tower-Plus-2B", "Unbabel/TowerInstruct-7B-v0.2", "Unbabel/TowerInstruct-Mistral-7B-v0.2",
|
|
@@ -64,7 +65,7 @@ class Translators:
|
|
| 64 |
url = os.environ['GCLIENT'] + f'sl={self.sl}&tl={self.tl}&q={self.input_text}'
|
| 65 |
response = httpx.get(url)
|
| 66 |
return response.json()[0][0][0].strip()
|
| 67 |
-
|
| 68 |
def mitre(self):
|
| 69 |
from transformers import AutoModel, AutoTokenizer
|
| 70 |
tokenizer = AutoTokenizer.from_pretrained(self.model_name, trust_remote_code=True, use_fast=False)
|
|
@@ -236,7 +237,7 @@ class Translators:
|
|
| 236 |
def simplepipe(self):
|
| 237 |
try:
|
| 238 |
pipe = pipeline("translation", model=self.model_name, device=self.device)
|
| 239 |
-
translation = pipe(self.input_text)
|
| 240 |
message = f'Translated from {iso1toall[self.sl][0]} to {iso1toall[self.tl][0]} with {self.model_name}.'
|
| 241 |
return translation[0]['translation_text'], message
|
| 242 |
except Exception as error:
|
|
@@ -630,6 +631,9 @@ def translate_text(model_name: str, s_language: str, t_language: str, input_text
|
|
| 630 |
elif "salamandra" in model_name.lower():
|
| 631 |
translated_text = Translators(model_name, s_language, t_language, input_text).salamandratapipe()
|
| 632 |
|
|
|
|
|
|
|
|
|
|
| 633 |
elif "small100" in model_name.lower():
|
| 634 |
translated_text = Translators(model_name, sl, tl, input_text).smallonehundred()
|
| 635 |
|
|
|
|
| 36 |
"Helsinki-NLP/opus-mt-tc-bible-big-roa-en",
|
| 37 |
"facebook/nllb-200-distilled-600M", "facebook/nllb-200-distilled-1.3B", "facebook/nllb-200-1.3B", "facebook/nllb-200-3.3B",
|
| 38 |
"facebook/mbart-large-50-many-to-many-mmt", "facebook/mbart-large-50-one-to-many-mmt", "facebook/mbart-large-50-many-to-one-mmt",
|
| 39 |
+
"facebook/m2m100_418M", "facebook/m2m100_1.2B",
|
| 40 |
+
"alirezamsh/small100", "naist-nlp/mitre_466m", "naist-nlp/mitre_913m",
|
| 41 |
"bigscience/mt0-small", "bigscience/mt0-base", "bigscience/mt0-large", "bigscience/mt0-xl",
|
| 42 |
"bigscience/bloomz-560m", "bigscience/bloomz-1b1", "bigscience/bloomz-1b7", "bigscience/bloomz-3b",
|
| 43 |
"t5-small", "t5-base", "t5-large",
|
| 44 |
"google/flan-t5-small", "google/flan-t5-base", "google/flan-t5-large", "google/flan-t5-xl",
|
| 45 |
"google/madlad400-3b-mt", "Heng666/madlad400-3b-mt-ct2", "Heng666/madlad400-3b-mt-ct2-int8", "Heng666/madlad400-7b-mt-ct2-int8",
|
| 46 |
+
"yanolja/YanoljaNEXT-Rosetta-4B-2511"
|
| 47 |
"BSC-LT/salamandraTA-2b-instruct", "BSC-LT/salamandraTA-7b-instruct",
|
| 48 |
"utter-project/EuroLLM-1.7B", "utter-project/EuroLLM-1.7B-Instruct",
|
| 49 |
"Unbabel/Tower-Plus-2B", "Unbabel/TowerInstruct-7B-v0.2", "Unbabel/TowerInstruct-Mistral-7B-v0.2",
|
|
|
|
| 65 |
url = os.environ['GCLIENT'] + f'sl={self.sl}&tl={self.tl}&q={self.input_text}'
|
| 66 |
response = httpx.get(url)
|
| 67 |
return response.json()[0][0][0].strip()
|
| 68 |
+
|
| 69 |
def mitre(self):
|
| 70 |
from transformers import AutoModel, AutoTokenizer
|
| 71 |
tokenizer = AutoTokenizer.from_pretrained(self.model_name, trust_remote_code=True, use_fast=False)
|
|
|
|
| 237 |
def simplepipe(self):
|
| 238 |
try:
|
| 239 |
pipe = pipeline("translation", model=self.model_name, device=self.device)
|
| 240 |
+
translation = pipe(self.input_text, , src_lang=self.sl, tgt_lang=self.tl)
|
| 241 |
message = f'Translated from {iso1toall[self.sl][0]} to {iso1toall[self.tl][0]} with {self.model_name}.'
|
| 242 |
return translation[0]['translation_text'], message
|
| 243 |
except Exception as error:
|
|
|
|
| 631 |
elif "salamandra" in model_name.lower():
|
| 632 |
translated_text = Translators(model_name, s_language, t_language, input_text).salamandratapipe()
|
| 633 |
|
| 634 |
+
elif "Rosetta" in model_name.lower():
|
| 635 |
+
translated_text = Translators(model_name, s_language, t_language, input_text).simplepipe()
|
| 636 |
+
|
| 637 |
elif "small100" in model_name.lower():
|
| 638 |
translated_text = Translators(model_name, sl, tl, input_text).smallonehundred()
|
| 639 |
|