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
[generate] deprecate forced ids processor #29487
[generate] deprecate forced ids processor #29487
Conversation
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad that we removed it!
self.force_token_map = dict(force_token_map) | ||
if not _has_warned: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably use logger.warning_once()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This argument is to distinguish between when the user has passed forced_ids
to generate, in which case we throw a warning explaining so:
transformers/src/transformers/generation/utils.py
Lines 921 to 926 in 4a604ed
if generation_config.forced_decoder_ids is not None: | |
# TODO(Sanchit): deprecate in v4.40 by removing this logic | |
warnings.warn( | |
"You have explicitly specified`forced_decoder_ids`. This functionality has been deprecated and will throw an error in v4.40. Please use `input_ids` or `decoder_input_ids` respectively.", | |
FutureWarning, | |
) |
OR if the user instantiates the forced logits processor standalone. Again, we give a descriptive warning explaining this:
transformers/src/transformers/generation/logits_process.py
Lines 1751 to 1756 in 4a604ed
if not _has_warned: | |
# TODO(Sanchit): remove this processor entirely in v4.40 | |
warnings.warn( | |
"This `ForceTokensLogitsProcessor` has been deprecated and will be removed in v4.40. Please pass `input_ids` or `decoder_input_ids` to the generate method directly.", | |
FutureWarning, | |
) |
=> we don't want to trigger the second warnings if the user does option 1, since the processor has been instantiated automatically. Thus, we have a separate warning for each case. This should not be confused with an argument to detect whether the warning has previously been triggered
1aa9575
to
976f07a
Compare
What does this PR do?
First stage of deprecation for the
ForceTokensLogitsProcessor
. This logits processor was exclusively used for Whisper. However, the PR #29485 removed the last calls to this processor from Whisper, in favour ofdecoder_input_ids
set internally by generate, meaning this processor can now be removed.