Repository navigation
Conversation
…tampLogitsProcessor The early `continue` at `begin_index` made the `max_initial_timestamp` block unreachable, so the first timestamp was never restricted. Mirror the reference implementation by nesting the check inside the first-step branch, and align the `WhisperGenerationConfig` default with transformers (unset means no restriction) instead of the previous `1` (= 0.02s).
|
FYI, #1875 fixes the same unreachable first-step branch, and independently reached the same conclusion about the default ( One detail that may be worth folding in here: the guard has to be |
WhisperTimeStampLogitsProcessor._callreturned early (continue) atbegin_index, which made the subsequent "apply themax_initial_timestampoption" block unreachable since it is guarded by the same condition. As a resultmax_initial_timestamp_index(set to 50, i.e. 1.0s, in the generation config of the official Whisper exports) was never enforced and the first timestamp token could be sampled anywhere in the 30s window. The reference implementation intransformersapplies the restriction inside the first-step branch, right after masking text tokens.This PR:
max_initial_timestampcheck, mirroringtransformers'WhisperTimeStampLogitsProcessor.__call__;WhisperGenerationConfig.max_initial_timestamp_indexdefault from1tonull(no restriction), matchinggetattr(generate_config, "max_initial_timestamp_index", None)intransformers. The previous default of1looks like a leftover of openai-whisper'smax_initial_timestamp = 1.0seconds and would have clamped models without the key to 0.02s once the block became reachable; the processor now checks!= nullso a missing key cannot producesubarray(NaN).Tests: added unit tests in
tests/utils/logits_process.test.jsthat construct the processor directly with a small synthetic vocabulary and verify (1) timestamps beyondtimestamp_begin + max_initial_timestamp_indexare masked at the first step, (2) nothing is masked when the index is unset, (3) the restriction is not applied on later steps. The first test fails onmain.pnpm format:checkandpnpm typegenpass.Note: expected outputs of existing timestamp tests that rely on hub models (e.g. the
return_timestamps: truecase forXenova/tiny-random-WhisperForConditionalGeneration, whose config setsmax_initial_timestamp_index: 50yet the current expectation has a first timestamp of 28.96s) may need to be regenerated, since they were recorded with the restriction unintentionally disabled. Happy to update them if you confirm the expected values.