]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commit
whisper : improve beam search candidate diversity (#1947)
authorJosh Bleecher Snyder <redacted>
Sun, 10 Mar 2024 14:54:43 +0000 (07:54 -0700)
committerGitHub <redacted>
Sun, 10 Mar 2024 14:54:43 +0000 (16:54 +0200)
commitec166499d8fa1d884211c5f098011c13b1583d70
tree35c2c05f56ba2b4d36d01060c6962ed875437e4c
parentccf022f970e8201758f3b2ad148bb366912a084a
whisper : improve beam search candidate diversity (#1947)

As of #1486, whisper.cpp uses a unified KV cache with KQ masking.
As a result, depending on their location in the batch,
identical sequences in a batch can have slightly different outputs
due to floating point rounding errors during reduction.
See the discussion in #1941 for more details.

The beam search code used "has identical sum of log probabilities"
as a shorthand for "is an identical token sequence". However, per above,
identical tokens do not necessarily result in identical probabilities.

Instead, explicitly compare on sequences.
This is linear in cost when they are identical,
but the lengths are always small and the comparisons are cheap.

This increases diversity during beam search.

This improves output quality for some short samples I've been working
with, at no detectable performance cost.
I haven't checked against larger corpuses.

Fixes #1941
whisper.cpp