mstar.model.whisper.components.timestamps#
Whisper timestamp decoding rules as a per-request state that travels with the token.
When a request asks for timestamps (no <|notimestamps|> in its prompt),
Whisper’s decoding is constrained the way openai-whisper / HF’s
WhisperTimeStampLogitsProcessor constrain it:
the first generated token is a timestamp no later than
max_initial_timestamp_index;timestamps come in pairs — after
<|t|>that closed a segment only a timestamp (>= the same value) or end-of-text may follow, and after the pair only text may follow;timestamps never decrease;
when the total probability of all timestamp tokens beats the best text token, a timestamp is sampled.
Which rule applies depends on the tokens generated so far. The worker
launches the next decode step before it has read the previous step’s token
on the host, so that history cannot live in Python: the four integers that
summarize it ([active, phase, last_ts, ceil]) are a tensor row that is
routed along with the sampled token, updated by TimestampRules.advance()
inside the (captured) forward, and turned into masks on the (bs, vocab)
logits by TimestampRules.apply() with no data-dependent control flow.
rule_state() builds the same row from a token history on the host —
the prefill’s first row, and the tests’ oracle for advance.
Functions
|
The rule for the next token, from what the request generated since its prompt. |
Classes
|
Vectorized rule application and state transition. |
- class mstar.model.whisper.components.timestamps.TimestampRules(config)[source]#
Bases:
objectVectorized rule application and state transition.
- Parameters:
config (WhisperModelConfig)
- mstar.model.whisper.components.timestamps.rule_state(generated, config)[source]#
The rule for the next token, from what the request generated since its prompt.
last_tsis the last timestamp token (timestamp_begin - 1when none yet);ceilthe exclusive timestamp bound.- Parameters:
config (WhisperModelConfig)
- Return type: