From 659ab0423e6492b079d3df131445a39dda0651cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Am=C3=A9lie=20T=2E=20Reymond?= Date: Thu, 17 Aug 2023 22:58:59 -0700 Subject: [PATCH] Fix typo in example code (#25583) `lang_code_to_id("en_XX")` => `lang_code_to_id["en_XX"]` lang_code_to_id is a dict --- docs/source/en/multilingual.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/en/multilingual.md b/docs/source/en/multilingual.md index 72192487f1..9bf904a3b3 100644 --- a/docs/source/en/multilingual.md +++ b/docs/source/en/multilingual.md @@ -171,9 +171,9 @@ Tokenize the text: MBart forces the target language id as the first generated token to translate to the target language. Set the `forced_bos_token_id` to `en` in the `generate` method to translate to English: ```py ->>> generated_tokens = model.generate(**encoded_en, forced_bos_token_id=tokenizer.lang_code_to_id("en_XX")) +>>> generated_tokens = model.generate(**encoded_en, forced_bos_token_id=tokenizer.lang_code_to_id["en_XX"]) >>> tokenizer.batch_decode(generated_tokens, skip_special_tokens=True) "Don't interfere with the wizard's affairs, because they are subtle, will soon get angry." ``` -If you are using the `facebook/mbart-large-50-many-to-one-mmt` checkpoint, you don't need to force the target language id as the first generated token otherwise the usage is the same. \ No newline at end of file +If you are using the `facebook/mbart-large-50-many-to-one-mmt` checkpoint, you don't need to force the target language id as the first generated token otherwise the usage is the same.