Preserve previous result as context for next segment #1335
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In online transducer recognizer during reset() sherpa-onnx preserves the output of the decoder network (decoder_output), but resets model context to sequence of blanks.
After the reset, at t0 of the new segment the beam-search-decoder reuses decoder_output.
Let's assume it outputs some token Z, because it's the most probable considering cached decoder output (calculated for previous context before reset - "X Y").
Then on step t1, the beam-search-decoder calculates new decoder_output using current reset context which now is " Z".
It may happen that Z is no longer most probable hypothesis and so the beam search switches to another path. User sees this as "Z" flickering and getting deleted. Sometimes this switch can also happen after outputting 2-3 and probably even more tokens. Besides user discomfort, deleted words frequently contain correct transcript (at least in my subjective experience).
This PR fixes this by using previous result tokens as "context" for next segment instead of caching the decoder output for one timestep.