Skip to content

Commit b241df9

Browse files
Emre-Akgulclaude
andcommitted
Apply full-context fix to timestamped decoding too
The half-context cap removed for no-timestamp decoding was never actually tied to timestamps - it originated as half of n_text_ctx in OpenAI's reference implementation and applied regardless of the <|notimestamps|> prompt token. Timestamped decoding now also uses the full remaining decoder context (total_max_length - start_step). Verified on large-v3 with the Armenian/Georgian samples from the previous commit using timestamped prompts: Armenian now completes fully (304 tokens vs. the previous 224-token cutoff), and Georgian reaches the full ~445-token decoder budget instead of stopping at 224. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VhE79Fs7AknnXa9EmagCuY
1 parent 68e7bc5 commit b241df9

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

python/tests/test_transformers.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ def _get_features(audio):
865865
assert transcription == expected_transcription
866866

867867
@test_utils.only_on_linux
868-
def test_transformers_whisper_no_timestamps_full_context(self, tmp_dir):
868+
def test_transformers_whisper_full_context(self, tmp_dir):
869869
import transformers
870870

871871
model_name = "openai/whisper-tiny"
@@ -907,11 +907,14 @@ def _generated_length(prompt):
907907
]
908908
timestamped_prompt = ["<|startoftranscript|>", "<|en|>", "<|transcribe|>"]
909909

910-
# With the default max_length of 448, no-timestamp decoding can use up
911-
# to 445 positions (448 minus the 3-token prompt prefix), exceeding the
912-
# previous 224-token cap. Timestamped decoding keeps that 224 limit.
910+
# With the default max_length of 448, decoding can use the entire
911+
# remaining decoder context (448 minus the prompt length), no longer
912+
# capped to half of max_length. This applies to both no-timestamp and
913+
# timestamped decoding, since the previous 224-token cap was not
914+
# actually related to timestamps. The timestamped prompt is one
915+
# token shorter, so it gets one extra position of context.
913916
assert _generated_length(no_timestamps_prompt) == 445
914-
assert _generated_length(timestamped_prompt) == 224
917+
assert _generated_length(timestamped_prompt) == 446
915918

916919
@test_utils.only_on_linux
917920
@test_utils.on_available_devices

src/models/whisper.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,7 @@ namespace ctranslate2 {
301301
decoding_options.length_penalty = options.length_penalty;
302302
decoding_options.repetition_penalty = options.repetition_penalty;
303303
decoding_options.no_repeat_ngram_size = options.no_repeat_ngram_size;
304-
decoding_options.max_length = without_timestamps
305-
? total_max_length - start_step
306-
: std::min(total_max_length / 2,
307-
total_max_length - start_step);
304+
decoding_options.max_length = total_max_length - start_step;
308305
decoding_options.sampling_topk = options.sampling_topk;
309306
decoding_options.sampling_temperature = options.sampling_temperature;
310307
decoding_options.num_hypotheses = options.num_hypotheses;

0 commit comments

Comments
 (0)