Skip to content

Conversation

@eustlb
Copy link
Contributor

@eustlb eustlb commented Jan 17, 2025

What does this PR do?

Fixes #34210 #31942 #36602

In the tokenizer decoding logic for the pipeline, timestamp offsetting when the call to Whisper's generate have seeking (meaning generating for a new segment).

EDIT

⚠️
This also fixes another issue, indirectly spotted in #36612: when condition_on_prev_tokens=True, we need to use last generated tokens as decoder_input_ids. Nevertheless, this requires skipping one of the double ending tokens (cf #34537) to match OAI implementation, done via in place modification tokens=tokens[:-1]. But we actually need this token to be kept for further decoding (also cf #34537) !!

TODO

  • make sure the edge cases are correctly handled: what about chunk_length_s=60 e.g. ? → actually Whisper just should not be used with chunk_length_s set! Added a warning
  • add a test for above mentioned edge case → done via complexifying test_large_timestamp_generation with condition_on_prev_tokens=True

@eustlb eustlb marked this pull request as ready for review January 17, 2025 13:52
@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.

It's missing a test IMO! 🤗

Comment on lines 306 to 309
elif self.type == "seq2seq_whisper" and not ignore_warning:
logger.warning(
"Using `chunk_length_s` with Whisper models is not recommended and will result in unreliable results, as it uses it's own chunking mechanism "
"(cf. Whisper original paper, section 3.8. Long-form Transcription)."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned offline would be a pity to not use that batch algo in some cases! But up to debate!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! I just want to make sure:

  1. the user knows that for seq2seq models the pipeline's chunking mechanism is unreliable. A warning already exists for that, it is just not taking whisper into account...
  2. ensure the user is not using the pipeline to do long-form transcription (or at least he knows he could use something more reliable when it comes to whisper) !!

I've updated the warning accordingly

@FaresBadrCA
Copy link

I tried the code in this PR on a sample audio. The chunk timestamps go out of sync with the audio, and it gets worse the longer the input audio is.

@as-suvorov
Copy link

Hi @eustlb, could you please tell what is the status of this PR?

@eustlb
Copy link
Contributor Author

eustlb commented Apr 25, 2025

Hey @as-suvorov, it's waiting for a core maintainer's approval to merge. @ArthurZucker I've addressed your comment, ready to merge 🤗

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.

thanks!

cut_off_length=None,
return_token_timestamps=False,
force_unique_generate_call=False,
skip_ending_double_timestamps=False,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are missing documentation on this one no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a comment explaining this hidden parameters and links to related PRs to understand why we need it

@eustlb eustlb enabled auto-merge (squash) June 26, 2025 14:20
@eustlb eustlb merged commit cfff7ca into huggingface:main Jun 26, 2025
20 checks passed
@eustlb eustlb deleted the fix-pipeline branch June 26, 2025 14:36
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
* handle long form generation

* add warning

* correct incorrect in place token change

* update test to catch edge case

* make style

* update warning

* add doc
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
* handle long form generation

* add warning

* correct incorrect in place token change

* update test to catch edge case

* make style

* update warning

* add doc
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
* handle long form generation

* add warning

* correct incorrect in place token change

* update test to catch edge case

* make style

* update warning

* add doc
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
* handle long form generation

* add warning

* correct incorrect in place token change

* update test to catch edge case

* make style

* update warning

* add doc
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
* handle long form generation

* add warning

* correct incorrect in place token change

* update test to catch edge case

* make style

* update warning

* add doc
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
* handle long form generation

* add warning

* correct incorrect in place token change

* update test to catch edge case

* make style

* update warning

* add doc
zaristei pushed a commit to zaristei/transformers that referenced this pull request Sep 9, 2025
* handle long form generation

* add warning

* correct incorrect in place token change

* update test to catch edge case

* make style

* update warning

* add doc
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.

Missing timestamp offset using Whisper with pipeline and sequential decoding

5 participants