From b31790654fb1bb6f022510b20aa727a547530e00 Mon Sep 17 00:00:00 2001 From: emreakgul Date: Sat, 11 Jul 2026 12:32:23 +0300 Subject: [PATCH] Allow no-timestamp Whisper decoding to use full context --- src/models/whisper.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/models/whisper.cc b/src/models/whisper.cc index fcbb6bcc3..c00eac622 100644 --- a/src/models/whisper.cc +++ b/src/models/whisper.cc @@ -292,6 +292,7 @@ namespace ctranslate2 { } const dim_t total_max_length = options.max_length; + const bool without_timestamps = prompts[0][prompt_length - 1] == _no_timestamps_id; DecodingOptions decoding_options; decoding_options.start_step = start_step; @@ -300,7 +301,10 @@ namespace ctranslate2 { decoding_options.length_penalty = options.length_penalty; decoding_options.repetition_penalty = options.repetition_penalty; decoding_options.no_repeat_ngram_size = options.no_repeat_ngram_size; - decoding_options.max_length = std::min(total_max_length / 2, total_max_length - start_step); + decoding_options.max_length = without_timestamps + ? total_max_length - start_step + : std::min(total_max_length / 2, + total_max_length - start_step); decoding_options.sampling_topk = options.sampling_topk; decoding_options.sampling_temperature = options.sampling_temperature; decoding_options.num_hypotheses = options.num_hypotheses; @@ -329,7 +333,7 @@ namespace ctranslate2 { decoding_options.logits_processors.emplace_back(no_speech_probs_processor); } - if (prompts[0][prompt_length - 1] != _no_timestamps_id) { + if (!without_timestamps) { const size_t timestamp_begin_id = _no_timestamps_id + 1; const size_t timestamp_end_id = vocabulary.size() - 1; const size_t max_initial_timestamp_id = timestamp_begin_id + options.max_initial_timestamp_index;