Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[FlaxGenerate] Fix bug in decoder_start_token_id #17035

Merged
merged 1 commit into from
May 2, 2022

Conversation

sanchit-gandhi
Copy link
Contributor

In Python, bool is a subclass of int, and False has the value 0. We observe this by calling the __bool__ method of 0:

print((0).__bool__())
print((1).__bool__())
False
True

decoder_start_token_id = (
decoder_start_token_id if decoder_start_token_id else self.config.decoder_start_token_id
)

In the preceding lines of code, if decoder_start_token_id has the value 0 (valid):

  • if decoder_start_token_id will be False
  • decoder_start_token_id will be set to self.config.decoder_start_token_id

The correct behaviour should be that if decoder_start_token_id has the value 0, it remains set to 0, and not changed to self.config.decoder_start_token_id.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented May 2, 2022

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

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

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

Great catch!

@sanchit-gandhi sanchit-gandhi merged commit ff846e9 into huggingface:main May 2, 2022
@sanchit-gandhi sanchit-gandhi deleted the flax-generate branch May 2, 2022 09:06
nandwalritik pushed a commit to nandwalritik/transformers that referenced this pull request May 3, 2022
stevhliu pushed a commit to stevhliu/transformers that referenced this pull request May 3, 2022
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants