-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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! |
It works for me : |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
I'm getting this error using nllb-serve binary from the latest git version:
|
downgrading transformers from 4.45.1 to 4.37.0 fixed the issue for me. found it here https://drsuneamer.tistory.com/250 |
I need to edit a tokenizer to add a new language code, how can i do it on NllbTokenizer? On the code I'm using it is like that:
|
Just to provide a response here to my own question, this code worked for me
|
There is a function that does exactly that 😉 |
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: