File size: 575 Bytes
5fa1a76 |
1 2 3 4 5 6 7 8 9 10 11 12 |
Supervised training thon from transformers import PLBartForConditionalGeneration, PLBartTokenizer tokenizer = PLBartTokenizer.from_pretrained("uclanlp/plbart-base", src_lang="en_XX", tgt_lang="python") example_python_phrase = "def maximum(a,b,c):NEW_LINE_INDENTreturn max([a,b,c])" expected_translation_english = "Returns the maximum value of a b c." inputs = tokenizer(example_python_phrase, text_target=expected_translation_english, return_tensors="pt") model(**inputs) Generation While generating the target text set the decoder_start_token_id to the target language id. |