Stop timestamps going backwards during decoding - #16
Merged
Merged
Conversation
ApplyTimestampRules collected the positions of timestamp tokens in the sampled sequence rather than their values, so the mask slice timestamp_begin:<position> was always empty and the rule never applied: the model could emit a timestamp earlier than the previous one, or close a segment at the timestamp it opened with. Use the token values, as OpenAI's reference implementation does: mask every timestamp below the last one, and the last one itself unless the last token is a lone timestamp closing a segment (so "<|2.00|><|2.00|>" can still close one segment and open the next). Tests: unit checks on the mask, and a decode with a random-weight model asserting timestamps never decrease. Random test models are now cast to float16 like the published checkpoints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TMXYMqgLAykqRApmbRfpTA
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.
What does this PR do?
Closes #6.
ApplyTimestampRulescollected the positions of timestamp tokens in the sampled sequence rather than their values. The mask slicetimestamp_begin:<position>was therefore always empty, and the rule never applied. The model could emit a timestamp earlier than the previous one, or close a segment at the timestamp it opened with.This uses the token values, as OpenAI's reference implementation does. Every timestamp below the last one is masked. The last one is masked too, unless the last token is a lone timestamp closing a segment, so that
<|2.00|><|2.00|>can still close one segment and open the next.This changes decoded output: it is now closer to the reference behaviour.
Test helpers: random test models are cast to float16, as the published checkpoints are, and only floating-point parameters are cast (
alignment_headsstays an integer array). The warning tests from #14 now use the plain stub model, which is faster.How was this tested?
pytest): 34 passedvayu audio.mp3)tests/test_timestamp_rules.py:Three of these fail on
main.claude-reviewwill fail as on #12 (the repository'sCLAUDE_CODE_OAUTH_TOKENsecret, see this comment).🤖 Generated with Claude Code
https://claude.ai/code/session_01TMXYMqgLAykqRApmbRfpTA
Generated by Claude Code