Fix forced_bos_token_id not set in generation_config#41521
Fix forced_bos_token_id not set in generation_config#41521Addyk-24 wants to merge 1 commit intohuggingface:mainfrom
Conversation
|
What's worked for me is that I set model.generation_config.decoder_start_token_id to the target language ID of MBart. When I discovered this bug, I think I checked the forced_bos_token_id of the output of MBart, and it should still be the start token s>. In this case, I think what was missing was the target language ID after start token, if I remembered correctly. |
|
@Addyk-24 do you mind reverting all unrelated changes please? 🤗 I.e. all style changes (newlines etc) so that we can see the clear diff |
1198033 to
3927ffe
Compare
@Cyrilvallez Done! I've reverted all unrelated formatting changes. The PR now only includes the fix for setting forced_bos_token_id in generation_config, so the language ID is handled automatically instead of manually. I've also performed 4 custom tests to verify this behavior. Please let me know if any further adjustments are needed. Thanks 🤗 |
|
Thanks! cc @gante here as well, it's a simple change from config to generation_config, maybe worth checking it out to see if it should be upstreamed to generate! |

What does this PR do?
Fixes #41492
Fixes incorrect target language generation during evaluation/validation in run_translation.py for multilingual translation models (mBART , M2M100).
Problem
When fine-tuning multilingual models, forced_bos_token_id was only set in model.config but not in model.generation_config. During evaluation, model.generate() reads from generation_config, causing generation in wrong language and artificially low BLEU scores.Previously would be ~2-5 (wrong language)
Solution
Set forced_bos_token_id in both model.config and model.generation_config.
Results:
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@zach-huggingface @Cyrilvallez