Skip to content

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
Contributor

Possibly cc @gante as it relates to generation

@amyeroberts
Copy link
Contributor

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
Contributor

@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
Contributor

@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
Contributor

Gentle ping @gante

Copy link
Contributor

@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
Contributor

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
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