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

[generate] deprecate forced ids processor #29487

Merged
merged 3 commits into from Mar 13, 2024

Conversation

sanchit-gandhi
Copy link
Contributor

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 of decoder_input_ids set internally by generate, meaning this processor can now be removed.

@HuggingFaceDocBuilderDev

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.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a 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:
Copy link
Collaborator

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()?

Copy link
Contributor Author

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:

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:

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

src/transformers/generation/logits_process.py Outdated Show resolved Hide resolved
@sanchit-gandhi sanchit-gandhi merged commit fafe909 into huggingface:main Mar 13, 2024
21 checks passed
@sanchit-gandhi sanchit-gandhi deleted the forced-logits-proc branch March 13, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants