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

⚠️ Raise Exception when trying to generate 0 tokens ⚠️ #28621

Merged
5 changes: 2 additions & 3 deletions src/transformers/generation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,11 +1133,10 @@ def _validate_generated_length(self, generation_config, input_ids_length, has_de
)
if input_ids_length >= generation_config.max_length:
input_ids_string = "decoder_input_ids" if self.config.is_encoder_decoder else "input_ids"
warnings.warn(
raise ValueError(
f"Input length of {input_ids_string} is {input_ids_length}, but `max_length` is set to"
f" {generation_config.max_length}. This can lead to unexpected behavior. You should consider"
" increasing `max_new_tokens`.",
UserWarning,
" increasing `max_new_tokens`."
danielkorat marked this conversation as resolved.
Show resolved Hide resolved
)

# 2. Min length warnings due to unfeasible parameter combinations
Expand Down