Skip to content
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

fix: [whisper] don't overwrite GenerationConfig's return_timestamps when return_timestamps is not passed to generate function #31296

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

hrl
Copy link
Contributor

@hrl hrl commented Jun 6, 2024

What does this PR do?

When WhisperGenerationMixin.generate called without return_timestamps, GenerationConfig's return_timestamps will be overwritten to None.

It's okay if we can control generate's arguments. But in some particular case, for example, in Trainer.evaluation_loop, then in Seq2SeqTrainer.prediction_step, there is no way to pass gen_kwargs to generate function. (#19777)
Which makes it impossible to generate with timestamps to calculate generative metrics when training.

This PR fixes this case by initializing return_timestamps to GenerationConfig's value.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@patrickvonplaten @sanchit-gandhi

@amyeroberts
Copy link
Collaborator

Possibly cc @gante as it relates to generation

@amyeroberts
Copy link
Collaborator

cc @kamilakesbi

Copy link
Contributor

@kamilakesbi kamilakesbi left a comment

Choose a reason for hiding this comment

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

Hi @hrl,

Thanks for working on this! it LGTM :)
@amyeroberts we should be able to merge

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 handling this!

Could you add a test?

I'd just like to confirm this behaviour is consistent with the rest of the generation API cc @gante

@kamilakesbi
Copy link
Contributor

@hrl did you have time to iterate on this ? thank you!

@hrl
Copy link
Contributor Author

hrl commented Jul 25, 2024

@hrl did you have time to iterate on this ? thank you!

@kamilakesbi conflicts resolved.

Could you add a test?
I'd just like to confirm this behaviour is consistent with the rest of the generation API cc @gante

@amyeroberts I'm not familiar with the rest of the generation API. Should I write a test for this?

The behavior will be different only when GenerationConfig.return_timestamps == True and return_timestamps is not passed to generate.

@amyeroberts
Copy link
Collaborator

@amyeroberts I'm not familiar with the rest of the generation API. Should I write a test for this?

Oh, no worries, this was a question for @gante, our generate king and who knows all the ins-and-outs best :)

@huggingface huggingface deleted a comment from github-actions bot Aug 20, 2024
@amyeroberts
Copy link
Collaborator

Gentle ping @gante

Copy link
Member

@gante gante left a comment

Choose a reason for hiding this comment

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

Apologies for the delayed review, and thank you for fixing 🙏

@gante
Copy link
Member

gante commented Aug 21, 2024

(@amyeroberts @kamilakesbi the root cause for the issue behind this PR is that Whisper's generate breaks a few assumptions present in the global generate, such as how the generation config and the generate kwargs interact with each other. Some of our tools, like Trainer, are built with the general case in mind -- I will try to nudge Whisper towards the general case whenever I see the opportunity 🤗 )

@gante gante merged commit c6d484e into huggingface:main Aug 21, 2024
18 checks passed
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
… when `return_timestamps` is not passed to `generate` function (huggingface#31296)

[whisper] don't overwrite return_timestamps when not passed to generate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants