Repository navigation
Conversation
WhisperTimeStampLogitsProcessor masked the text tokens with
if (input_ids[i].length === this.begin_index) { ...; continue; }
and then, after that continue, tried to cap the allowed timestamps with
if (input_ids[i].length === this.begin_index && max_initial_timestamp_index !== null)
The second condition can never be true, so max_initial_timestamp_index (1 by
default in WhisperGenerationConfig) was silently ignored and the model was
free to emit any timestamp as the first one. Move the cap into the branch
that handles the first step, before the continue.
Two follow-ups to the unreachable `max_initial_timestamp` branch: - `WhisperGenerationConfig.max_initial_timestamp_index` defaulted to `1`. Now that the cap can actually be reached, that would pin the first timestamp of every model that does not set the key to 0.02 s. The Python reference reads it with `getattr(generate_config, ..., None)`, i.e. a missing key means no restriction, so the default is now `null`. - The guard used `!== null`, so a config without the key (`undefined`) computed `subarray(NaN)`, which is `subarray(0)` and masked *every* logit in the row, text tokens included. `!= null` matches the `getattr(..., None)` semantics. Tests cover the missing-key case, the new default, and that later decoding steps stay uncapped.
Author
|
Pushed
Tests: For the record: #1823 (opened earlier) fixes the same unreachable branch and independently lands on the same |
Collaborator
|
looks like PR farming |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
WhisperTimeStampLogitsProcessorreturns early on the first decoding step:but the cap for
max_initial_timestampsits after thatcontinue, guarded by the same condition, so it is unreachable:max_initial_timestamp_indexis therefore silently ignored: for every Whisper checkpoint whosegeneration_config.jsonexports it (the official conversions set50, i.e. 1.0 s), a segment is free to start at an arbitrarily late timestamp.Fix
logits_process.js: move the cap into the first-step branch, before thecontinue. Later steps keep their pair-wise timestamp masking unchanged.generation_whisper.js:max_initial_timestamp_indexnow defaults tonullinstead of1. Now that the branch is actually reachable, the old port-artifact default would pin the first timestamp of every model that does not set the key to 0.02 s. The Python reference reads the option withgetattr(generate_config, "max_initial_timestamp_index", None), i.e. a missing key means "no restriction".!= nullinstead of!== null: a config that omits the key yieldsundefined, andtimestamp_begin + undefinedisNaN, sosubarray(last_allowed + 1)becomessubarray(NaN)->subarray(0), masking every logit in the row (text tokens included); the row softmax then returnsNaN.!= nullcovers bothnullandundefined, matching the Pythongetattrsemantics.Verification
packages/transformers/tests/utils/logits_process.test.js, synthetic vocabulary (no model download):Before the change,
limits the first timestamp by max_initial_timestamp_indexfails, because every timestamp stays available. Before the!= nullguard,keeps every timestamp when the config omits max_initial_timestamp_indexfails withReceived length: 0(all 99 timestamp logits masked).The file's three
bad_word_idscases fail locally both before and after this change: they load aTextGenerationPipelinefrom the Hub and this machine has no network access, so they are unrelated.Notes
tests/models/whisper/that were recorded while the cap was disabled will move once it is enforced for checkpoints that set the key. I could not regenerate them here for the same network reason; happy to update them once CI reports the new ids.