Repository navigation
fix(postprocess): keep a trailing @@ piece instead of dropping it - #3836
Conversation
A token list that ends on a BPE piece (a streaming chunk that ends inside a word) left the piece in word_item and never emitted it.
LauraGPT
left a comment
There was a problem hiding this comment.
The trailing-only examples reproduce on main, and all 32 selected text-postprocessing tests pass with this patch. However, the unconditional flush also emits an older buffered piece after a later Chinese token, so the mixed-text case called out as unchanged in the PR is changed by these lines.
At 84c7b76b5622caf803f7838be6e908769b22f417, in all three copies:
sentence_postprocess(["hel@@", "你"])
# ('你hel', ['你', 'hel'])
sentence_postprocess(["hel@@", "你"], [[0, 100], [100, 200]])
# ('你 hel', [[0, 100], [100, 100]], ['你', 'hel'])Main already drops that partial piece and has a timestamp bug for the Chinese token, but this patch newly appends the piece out of order and attaches a zero-length timestamp to it. ["hel@@", "你", "wor@@"] also produces 你helwor, combining pieces separated by Chinese text.
Please address the stale buffer at mixed-language boundaries before merging: preserve token order and each retained piece's own span, or keep a strictly scoped trailing-only fix from flushing stale pieces across a Chinese boundary. Add timed and untimed regressions for these boundary cases in all three implementations alongside the existing trailing-only cases. The separate streaming cross-chunk word-joining semantics should not be claimed solved by a stateless text flush.
Validation here is real pure-Python text/timestamp execution (baseline 2 failing tests, candidate 32 passing selected tests plus 96 boundary observations), not GPU inference or ASR quality. No production files were changed during review.
|
b5c05ab closes an open sentence_postprocess(["hel@@", "你"]) # ('hel你', ['hel', '你'])
sentence_postprocess(["hel@@", "你"], [[0, 100], [100, 200]]) # ('hel 你', [[0, 100], [100, 200]], ['hel', '你'])
sentence_postprocess(["hel@@", "你", "wor@@"]) # ('hel你wor', ['hel', '你', 'wor'])
|
LauraGPT
left a comment
There was a problem hiding this comment.
The revised boundary handling addresses my earlier ordering/span concern at b5c05ab. I reviewed all three implementations and the new tests: an interrupted BPE piece is emitted before the Chinese/symbol token, with its own timestamp, and the trailing piece is retained. The description correctly excludes cross-chunk word joining.
Independent validation: new regressions fail on main (3 failures); the related local text suite passes 53/53. Downloaded CI evidence confirms Python 3.10/3.12 text matrices at 76/76 each, Torch wheel/sdist tests and runtime-evaluation tests. ONNX CI uses the merge preview, whose full tree equals the reviewed head; the built Torch and ONNX postprocessor bytes match that source.
A bounded L20Z integration reused existing synthetic CTC weights and constructed hidden inputs: actual CUDA softmax/greedy decoding feeds all three CPU postprocessors, with explicit timed/untimed outputs. Across 72 observations per version, baseline has 63 expected mismatches and this head has none. This is not pretrained audio recognition, ASR quality/performance, streaming-continuity or production validation. An initial validation-harness spacing assumption failed and was corrected against the existing two interface formats; no production changes were made for that check.
No weights were downloaded and no production service or protection setting was changed.
Problem
sentence_postprocesscollects a BPE word inword_itemuntil a token without@@closes it. When the token list ends on a@@piece, nothing closes it and the piece is dropped:Streaming Paraformer hits this when a word spans two chunks:
paraformer_streaming/model.pyandfunasr_onnx/paraformer_online_bin.pypostprocess each chunk on its own, so the first part of that word disappears from the transcript.The buffer is also left open across a token that cannot continue the word. On
main,["hel@@", "你"]dropsheland gives你the span[0, 100], and["hel@@", "你", "wor@@", "ld"]becomes你helworld.Fix
@@word is closed before a Chinese or symbol token, at its own place and with its own[begin, end].word_itemis added as a word in the same way.The same lines go into all three copies of
postprocess_utils.py(funasr, funasr_onnx, funasr_torch). Token lists without an open@@piece are unchanged.Tests
Added to
tests/test_sentence_postprocess_timestamps.py, over all three copies:["hello", "wor@@"],["你", "好", "wor@@"], and the timestamped["hello", "wor@@", "l@@"];["hel@@", "你"],["hel@@", "l@@", "你"],["hel@@", "你", "wor@@"],["hel@@", "你", "wor@@", "ld"],["hel@@", "%"].Without the source change each boundary case fails in each copy, timed and untimed. With the trailing flush alone (84c7b76) they fail too. With both, on b5c05ab with
mainmerged,test_postprocess_hotwords.py,test_rich_transcription_postprocess.pyandtest_sentence_postprocess_timestamps.py: 47 passed, 6 skipped, 96 subtests passed (the 6 fuzzy hotword tests need pypinyin/rapidfuzz).Scope
This does not join a word across streaming chunks:
["wor@@"]then["ld"]givesworandldas two words, because each call is stateless.