Skip to content

Commit

Permalink
Fix "'NllbTokenizerFast' object has no attribute 'lang_code_to_id'" i…
Browse files Browse the repository at this point in the history
  • Loading branch information
blackmesataiwan committed Jul 19, 2024
1 parent f8a7d15 commit 07128d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/plugin_fb_nllb_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def translate(core:OneRingCore, text:str, from_lang:str = "", to_lang:str = "",
inputs = tokenizer_from(text, return_tensors="pt").to(to_device)

translated_tokens = model.generate(
**inputs, forced_bos_token_id=tokenizer_from.lang_code_to_id[to_lang_tr], max_length=int(len(text)*5)
**inputs, forced_bos_token_id=tokenizer_from.convert_tokens_to_ids(to_lang_tr), max_length=int(len(text)*5)
)
res = tokenizer_from.batch_decode(translated_tokens, skip_special_tokens=True)[0]

Expand Down

0 comments on commit 07128d0

Please sign in to comment.