Spaces:
Running
Running
Update src/Translate.py
Browse files- src/Translate.py +3 -3
src/Translate.py
CHANGED
|
@@ -71,9 +71,10 @@ class Translators:
|
|
| 71 |
|
| 72 |
# tell tokenizer the source language
|
| 73 |
tokenizer.src_lang = "en_XX"
|
|
|
|
| 74 |
|
| 75 |
# find the id for the target language and force it at generation
|
| 76 |
-
forced_bos_token_id = tokenizer.lang_code_to_id["ro_RO"]
|
| 77 |
|
| 78 |
# create the pipeline (pass tokenizer and model explicitly)
|
| 79 |
pipe = pipeline("translation", model=model, tokenizer=tokenizer)
|
|
@@ -83,8 +84,7 @@ class Translators:
|
|
| 83 |
result = pipe(
|
| 84 |
src_text,
|
| 85 |
num_beams=4,
|
| 86 |
-
max_length=512
|
| 87 |
-
forced_bos_token_id=forced_bos_token_id
|
| 88 |
)
|
| 89 |
|
| 90 |
return result[0]["translation_text"], self.message
|
|
|
|
| 71 |
|
| 72 |
# tell tokenizer the source language
|
| 73 |
tokenizer.src_lang = "en_XX"
|
| 74 |
+
tokenizer.tgt_lang = "ro_RO"
|
| 75 |
|
| 76 |
# find the id for the target language and force it at generation
|
| 77 |
+
# forced_bos_token_id = tokenizer.lang_code_to_id["ro_RO"]
|
| 78 |
|
| 79 |
# create the pipeline (pass tokenizer and model explicitly)
|
| 80 |
pipe = pipeline("translation", model=model, tokenizer=tokenizer)
|
|
|
|
| 84 |
result = pipe(
|
| 85 |
src_text,
|
| 86 |
num_beams=4,
|
| 87 |
+
max_length=512
|
|
|
|
| 88 |
)
|
| 89 |
|
| 90 |
return result[0]["translation_text"], self.message
|