Spaces:
Runtime error
Runtime error
Zeimoto
commited on
Commit
•
1f50a3c
1
Parent(s):
9983262
added max length into pipeline
Browse files- translation.py +2 -2
translation.py
CHANGED
@@ -16,8 +16,8 @@ def translate(text_to_translate: str) -> str:
|
|
16 |
text_size = len(text_to_translate)*2
|
17 |
tokenizer = AutoTokenizer.from_pretrained("unicamp-dl/translation-pt-en-t5")
|
18 |
model = AutoModelForSeq2SeqLM.from_pretrained("unicamp-dl/translation-pt-en-t5")
|
19 |
-
pten_pipeline = pipeline('text2text-generation',
|
20 |
-
translated_text = pten_pipeline(text_to_translate)
|
21 |
|
22 |
audit_elapsedtime(function="Finished translation", start=start)
|
23 |
print("Translated text:", translated_text)
|
|
|
16 |
text_size = len(text_to_translate)*2
|
17 |
tokenizer = AutoTokenizer.from_pretrained("unicamp-dl/translation-pt-en-t5")
|
18 |
model = AutoModelForSeq2SeqLM.from_pretrained("unicamp-dl/translation-pt-en-t5")
|
19 |
+
pten_pipeline = pipeline('text2text-generation', model=model, tokenizer=tokenizer)
|
20 |
+
translated_text = pten_pipeline(text_to_translate, max_new_tokens= text_size)
|
21 |
|
22 |
audit_elapsedtime(function="Finished translation", start=start)
|
23 |
print("Translated text:", translated_text)
|