-
Notifications
You must be signed in to change notification settings - Fork 509
Fix prompt tokens causing empty transcription output #428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -764,7 +764,8 @@ open class TextDecoder: TextDecoding, WhisperMLModel { | |
|
|
||
| let isPrefill = tokenIndex < initialPromptIndex - 1 // Prefill stops at the last token of the initial prompt | ||
| let isLastPrefillToken = tokenIndex == initialPromptIndex - 1 | ||
| let isFirstToken = tokenIndex == prefilledIndex | ||
| let isInPrefillPhase = isPrefill || isLastPrefillToken // tokenIndex < initialPromptIndex | ||
| let isFirstToken = tokenIndex == max(prefilledIndex, initialPromptIndex) // First actually decoded token (after prompt) | ||
|
|
||
| // Check if current index is part of the initial prompt | ||
| if tokenIndex < initialPromptIndex { | ||
|
|
@@ -854,8 +855,11 @@ open class TextDecoder: TextDecoding, WhisperMLModel { | |
| } else { | ||
| false | ||
| } | ||
| // During prefill phase (processing prompt tokens), skip early termination checks: | ||
| // - The model is being force-fed prompt tokens, so EOT predictions and low log probs are expected | ||
| // - Early stopping should only apply to actually decoded tokens after the prompt | ||
| let isSegmentCompleted = | ||
| sampleResult.completed || | ||
| (!isInPrefillPhase && sampleResult.completed) || | ||
| currentTokens.count >= Constants.maxTokenContext - 1 || | ||
| isFirstTokenLogProbTooLow | ||
|
Comment on lines
861
to
864
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isFirstTokenlooks off by one relative to hownextTokenLogProbis computed. In this loop, the first decoded token after the prompt is the token predicted whentokenIndex == initialPromptIndex - 1(see the debug log usingtokenIndex + 1). With the currenttokenIndex == max(prefilledIndex, initialPromptIndex), thefirstTokenLogProbThresholdcheck will fire one iteration late (and won’t fire at all wheninitialPromptIndex == 1, breaking the existingfirstTokenLogProbThresholdfallback behavior). Consider basingisFirstTokenonmax(prefilledIndex, initialPromptIndex - 1)(or equivalentlytokenIndex + 1 == max(prefilledIndex + 1, initialPromptIndex)) so it aligns with the first sampled token after the prompt.