mirror of
https://github.com/ggml-org/whisper.cpp.git
synced 2026-10-01 03:59:20 +02:00
whisper : fix max_tokens skipping remaining audio (#3798)
* whisper: fix max_tokens skipping remaining audio * add PR reference comment as suggested Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> * fix(ci): enable artifact overwrite
This commit is contained in:
co-authored by
Georgi Gerganov
parent
338cce1e58
commit
f08258abd7
@@ -6216,6 +6216,13 @@ static void whisper_process_logits(
|
||||
}
|
||||
}
|
||||
|
||||
// ref: https://github.com/ggml-org/whisper.cpp/pull/3798
|
||||
if (!params.no_timestamps && !params.single_segment && params.max_tokens > 0 && (int) tokens_cur.size() >= params.max_tokens) {
|
||||
for (int i = 0; i < vocab.token_eot; ++i) {
|
||||
logits[i] = -INFINITY;
|
||||
}
|
||||
}
|
||||
|
||||
// suppress sot and nosp tokens
|
||||
logits[vocab.token_sot] = -INFINITY;
|
||||
logits[vocab.token_nosp] = -INFINITY;
|
||||
@@ -7725,7 +7732,12 @@ int whisper_full_with_state(
|
||||
}
|
||||
|
||||
// ref: https://github.com/ggml-org/whisper.cpp/pull/2629
|
||||
const bool max_tokens_timestamp_ending = params.max_tokens > 0 &&
|
||||
!params.single_segment &&
|
||||
tokens_cur.size() > (size_t) params.max_tokens;
|
||||
|
||||
const bool single_timestamp_ending = tokens_cur.size() > 1 &&
|
||||
!max_tokens_timestamp_ending &&
|
||||
tokens_cur[tokens_cur.size() - 2].id < whisper_token_beg(ctx) &&
|
||||
tokens_cur[tokens_cur.size() - 1].id > whisper_token_beg(ctx);
|
||||
if (single_timestamp_ending) {
|
||||
|
||||
Reference in New Issue
Block a user