From e20116c124d59c0a9da7724fd662ba17f96e5af9 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Wed, 18 Jan 2023 22:38:14 +0200 Subject: [PATCH] whisper : condition timestamps to be monotonically increasing --- whisper.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/whisper.cpp b/whisper.cpp index 8846b82..9fd83b8 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -2910,6 +2910,16 @@ static void whisper_process_logits( } } + // condition timestamp tokens to be increasing + // ref: https://github.com/openai/whisper/pull/831#issuecomment-1385910556 + if (decoder.has_ts) { + const int tid0 = decoder.seek_delta/2; + + for (int i = vocab.token_beg; i < vocab.token_beg + tid0; ++i) { + logits[i] = -INFINITY; + } + } + // populate the logprobs array (log_softmax) { const float logit_max = *std::max_element(logits.begin(), logits.end());