Skip to content

Incorrect setting for num_beams in translation and summarization examples #27519

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

Merged
merged 3 commits into from
Nov 15, 2023

Conversation

Rocketknight1
Copy link
Member

@Rocketknight1 Rocketknight1 commented Nov 15, 2023

Our translation and summarization examples use None as a default value for num_beams, but this is no longer valid now that we use GenerationConfig. This PR fixes the examples, and also adds a guard in GenerationConfig so that None values there are replaced with 1 (and a warning is thrown).

Also, while I'm fixing example issues, some of our TF examples use main_process_first - this is a Torch function, and is not necessary because TF handles distributed training very differently. Since it looks like it could cause problems depending on whether Torch is also present, I'm removing it from all of the TF examples.

Fixes #27505

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Nov 15, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing!

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
@Rocketknight1 Rocketknight1 merged commit 2e72bba into main Nov 15, 2023
@Rocketknight1 Rocketknight1 deleted the tf-example-fixes branch November 15, 2023 18:18
EduardoPach pushed a commit to EduardoPach/transformers that referenced this pull request Nov 19, 2023
…ples (huggingface#27519)

* Remove the torch main_process_first context manager from TF examples

* Correctly set num_beams=1 in our examples, and add a guard in GenerationConfig.validate()

* Update src/transformers/generation/configuration_utils.py

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>

---------

Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
@ArthurZucker ArthurZucker mentioned this pull request Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: '>' not supported between instances of 'NoneType' and 'int'
3 participants