Fix WhisperForConditionalGeneration to respect generation_config?#30623
Closed
mizoru wants to merge 2 commits intohuggingface:mainfrom
Closed
Fix WhisperForConditionalGeneration to respect generation_config?#30623mizoru wants to merge 2 commits intohuggingface:mainfrom
mizoru wants to merge 2 commits intohuggingface:mainfrom
Conversation
…ps=None When WhisperForConditionalGeneration.generate is called with return_timestamps=None and return_timestamps=True in generation_config WhisperGenerationMixin._set_return_timestamps replaces the value in the config with None, now set to check return_timestamps is not None
Contributor
Author
|
Sorry, I'm a bit in over my head on how to contribute this properly right now, but: This should work
@staticmethod
def _set_return_timestamps(return_timestamps, is_shortform, generation_config):
if return_timestamps is None and hasattr(generation_config, "return_timestamps"):
return_timestamps = generation_config.return_timestamps
if not is_shortform:
if return_timestamps is False:
raise ValueError(
"You have passed more than 3000 mel input features (> 30 seconds) which automatically enables long-form generation which "
"requires the model to predict timestamp tokens. Please either pass `return_timestamps=True` or make sure to pass no more than 3000 mel input features."
)
logger.info("Setting `return_timestamps=True` for long-form generation.")
return_timestamps = True
if return_timestamps and not hasattr(generation_config, "no_timestamps_token_id"):
raise ValueError(
"You are trying to return timestamps, but the generation config is not properly set. "
"Make sure to initialize the generation config with the correct attributes that are needed such as `no_timestamps_token_id`. "
"For more details on how to generate the approtiate config, refer to https://github.com/huggingface/transformers/issues/21878#issuecomment-1451902363"
)
generation_config.return_timestamps = return_timestamps |
Contributor
|
Hi @mizoru, Thanks for iterating on this! |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Contributor
|
It will be solved by PR #31296 :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I had to change a line in
WhisperGenerationMixinfor it to generate with timestamps during evaluation.Many parameters of
WhisperGenerationMixin.generateareNoneby deafult. So that whenWhisperForConditionalGeneration.generateis called with default parameters andreturn_timestampsis set to True in generation_config,WhisperGenerationMixin._set_return_timestampsis called and replaces the value in the config with None.The same thing happens with
return_token_timestampsin the method_set_return_outputs, so I'm unsure if this is intended.Should I maybe open an issue first?
What does this PR do?
Change
WhisperGenerationMixin._set_return_timestampsto only replace the valuereturn_timestampsingeneration_configif new value is notNone.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
I can see @patrickvonplaten was the last person who worked on these lines.