Update app.py
Browse files
app.py
CHANGED
@@ -292,9 +292,7 @@ bot_name = "WeASK"
|
|
292 |
from transformers import MBartForConditionalGeneration, MBart50TokenizerFast
|
293 |
|
294 |
#def download_model():
|
295 |
-
|
296 |
-
model = MBartForConditionalGeneration.from_pretrained(model_name)
|
297 |
-
tokenizer = MBart50TokenizerFast.from_pretrained(model_name)
|
298 |
|
299 |
#model, tokenizer = download_model()
|
300 |
|
@@ -302,12 +300,16 @@ tokenizer = MBart50TokenizerFast.from_pretrained(model_name)
|
|
302 |
|
303 |
################################
|
304 |
def get_response(input_text):
|
|
|
|
|
|
|
|
|
305 |
model_inputs = tokenizer(input_text, return_tensors="pt")
|
306 |
generated_tokens = model.generate(**model_inputs,forced_bos_token_id=tokenizer.lang_code_to_id["en_XX"])
|
307 |
translation = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
|
308 |
#list1=["Welcome","To","Tutorials","Point"]
|
309 |
#string1="".join(map(str,list1))
|
310 |
-
string2=" ".join(map(str,translation))
|
311 |
#print(string2)
|
312 |
|
313 |
|
|
|
292 |
from transformers import MBartForConditionalGeneration, MBart50TokenizerFast
|
293 |
|
294 |
#def download_model():
|
295 |
+
|
|
|
|
|
296 |
|
297 |
#model, tokenizer = download_model()
|
298 |
|
|
|
300 |
|
301 |
################################
|
302 |
def get_response(input_text):
|
303 |
+
model_name = "facebook/mbart-large-50-many-to-many-mmt"
|
304 |
+
model = MBartForConditionalGeneration.from_pretrained(model_name)
|
305 |
+
tokenizer = MBart50TokenizerFast.from_pretrained(model_name)
|
306 |
+
|
307 |
model_inputs = tokenizer(input_text, return_tensors="pt")
|
308 |
generated_tokens = model.generate(**model_inputs,forced_bos_token_id=tokenizer.lang_code_to_id["en_XX"])
|
309 |
translation = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
|
310 |
#list1=["Welcome","To","Tutorials","Point"]
|
311 |
#string1="".join(map(str,list1))
|
312 |
+
string2=" ".join(map(str,translation ))
|
313 |
#print(string2)
|
314 |
|
315 |
|