Spaces:
Running
Running
Update src/Translate.py
Browse files- src/Translate.py +3 -3
src/Translate.py
CHANGED
|
@@ -70,16 +70,16 @@ class Translators:
|
|
| 70 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 71 |
|
| 72 |
# tell tokenizer the source language
|
| 73 |
-
tokenizer.src_lang = "en_XX"
|
| 74 |
# tokenizer.tgt_lang = "ro_RO"
|
| 75 |
# set the target language as the model's forced BOS token so pipeline will use it implicitly
|
| 76 |
-
model.config.forced_bos_token_id = tokenizer.lang_code_to_id["ro_RO"]
|
| 77 |
|
| 78 |
# find the id for the target language and force it at generation
|
| 79 |
# forced_bos_token_id = tokenizer.lang_code_to_id["ro_RO"]
|
| 80 |
|
| 81 |
# create the pipeline (pass tokenizer and model explicitly)
|
| 82 |
-
pipe = pipeline("
|
| 83 |
# "translation" task was used, instead of "translation_XX_to_YY", defaulting to "translation_en_to_ro"
|
| 84 |
|
| 85 |
# call the pipeline; generation kwargs are forwarded to model.generate
|
|
|
|
| 70 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 71 |
|
| 72 |
# tell tokenizer the source language
|
| 73 |
+
# tokenizer.src_lang = "en_XX"
|
| 74 |
# tokenizer.tgt_lang = "ro_RO"
|
| 75 |
# set the target language as the model's forced BOS token so pipeline will use it implicitly
|
| 76 |
+
# model.config.forced_bos_token_id = tokenizer.lang_code_to_id["ro_RO"]
|
| 77 |
|
| 78 |
# find the id for the target language and force it at generation
|
| 79 |
# forced_bos_token_id = tokenizer.lang_code_to_id["ro_RO"]
|
| 80 |
|
| 81 |
# create the pipeline (pass tokenizer and model explicitly)
|
| 82 |
+
pipe = pipeline("translation_en_to_ro", model=model, tokenizer=tokenizer)
|
| 83 |
# "translation" task was used, instead of "translation_XX_to_YY", defaulting to "translation_en_to_ro"
|
| 84 |
|
| 85 |
# call the pipeline; generation kwargs are forwarded to model.generate
|