|
Set the forced_bos_token_id to en in the generate method to translate to English: |
|
|
|
generated_tokens = model.generate(**encoded_zh, forced_bos_token_id=tokenizer.get_lang_id("en")) |
|
tokenizer.batch_decode(generated_tokens, skip_special_tokens=True) |
|
'Do not interfere with the matters of the witches, because they are delicate and will soon be angry.' |
|
|
|
MBart |
|
The following MBart models can be used for multilingual translation: |
|
|
|
facebook/mbart-large-50-one-to-many-mmt (One-to-many multilingual machine translation, 50 languages) |
|
facebook/mbart-large-50-many-to-many-mmt (Many-to-many multilingual machine translation, 50 languages) |
|
facebook/mbart-large-50-many-to-one-mmt (Many-to-one multilingual machine translation, 50 languages) |
|
facebook/mbart-large-50 (Multilingual translation, 50 languages) |
|
facebook/mbart-large-cc25 |
|
|
|
In this example, load the facebook/mbart-large-50-many-to-many-mmt checkpoint to translate Finnish to English. |