Supervised training | |
thon | |
from transformers import MBartForConditionalGeneration, MBartTokenizer | |
tokenizer = MBartTokenizer.from_pretrained("facebook/mbart-large-en-ro", src_lang="en_XX", tgt_lang="ro_RO") | |
example_english_phrase = "UN Chief Says There Is No Military Solution in Syria" | |
expected_translation_romanian = "Şeful ONU declară că nu există o soluţie militară în Siria" | |
inputs = tokenizer(example_english_phrase, text_target=expected_translation_romanian, return_tensors="pt") | |
model = MBartForConditionalGeneration.from_pretrained("facebook/mbart-large-en-ro") | |
forward pass | |
model(**inputs) | |
Generation | |
While generating the target text set the decoder_start_token_id to the target language id. |