-
Notifications
You must be signed in to change notification settings - Fork 25.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'NllbTokenizerFast' object has no attribute 'lang_code_to_id' #31348
Comments
Yes, we had a deprecation cycle and this attribute was removed 😉 |
Thanks, but then how can i provide the language code for translation? |
you should simply do |
Then why the doc says otherwise? This is |
It seems there is an error: whatever the language code I gave to the NLLB tokenizer, it will always output English token id. My version is |
I think, |
Yes! You should use |
What worked for me is |
yep this is what we expect! |
System Info
transformers
version: 4.42.0.dev0Who can help?
@ArthurZucker
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-600M", src_lang="ron_Latn",
token=token)
model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M", token=token)
article = "Şeful ONU spune că nu există o soluţie militară în Siria"
inputs = tokenizer(article, return_tensors="pt")
translated_tokens = model.generate(**inputs, forced_bos_token_id=tokenizer.lang_code_to_id["deu_Latn"], max_length=30)
tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)[0]
Expected behavior
It should output translated text: UN-Chef sagt, es gibt keine militärische Lösung in Syrien
Complete error:
The text was updated successfully, but these errors were encountered: