Skip to content

Commit

Permalink
Fix Whisper CI (#34617)
Browse files Browse the repository at this point in the history
* Revert "Revert "Fix Whisper CI" (#34605)"

This reverts commit 74d3824.

* update

---------

Co-authored-by: ydshieh <[email protected]>
Co-authored-by: Arthur <[email protected]>
  • Loading branch information
3 people authored Nov 18, 2024
1 parent 759a378 commit eed11f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/transformers/generation/flax_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,11 @@ def generate(
)
generation_config.max_length = generation_config.max_new_tokens + input_ids_seq_length
else: # by default let's always generate 10 new tokens
generation_config.max_length = generation_config.max_length + input_ids_seq_length
if generation_config.max_length == GenerationConfig().max_length:
generation_config.max_length = generation_config.max_length + input_ids_seq_length
max_position_embeddings = getattr(self.config, "max_position_embeddings", None)
if max_position_embeddings is not None:
generation_config.max_length = min(generation_config.max_length, max_position_embeddings)

if generation_config.min_length is not None and generation_config.min_length > generation_config.max_length:
raise ValueError(
Expand Down
9 changes: 5 additions & 4 deletions src/transformers/generation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,10 +1452,11 @@ def _prepare_generated_length(
):
generation_config.max_length -= inputs_tensor.shape[1]
elif has_default_max_length: # by default let's always generate 20 new tokens
generation_config.max_length = generation_config.max_length + input_ids_length
max_position_embeddings = getattr(self.config, "max_position_embeddings", None)
if max_position_embeddings is not None:
generation_config.max_length = min(generation_config.max_length, max_position_embeddings)
if generation_config.max_length == GenerationConfig().max_length:
generation_config.max_length = generation_config.max_length + input_ids_length
max_position_embeddings = getattr(self.config, "max_position_embeddings", None)
if max_position_embeddings is not None:
generation_config.max_length = min(generation_config.max_length, max_position_embeddings)

# same for min length
if generation_config.min_new_tokens is not None:
Expand Down

0 comments on commit eed11f3

Please sign in to comment.