Skip to content

fix(onnx): keep no left-context frames when chunk_size[0] is 0 in streaming Paraformer - #3790

Merged
LauraGPT merged 1 commit into
modelscope:mainfrom
ychy7001:fix/funasr-onnx-online-zero-left-chunk
Oct 31, 2026
Merged

LauraGPT merged 1 commit into
modelscope:mainfrom
ychy7001:fix/funasr-onnx-online-zero-left-chunk

Conversation

@ychy7001

@ychy7001 ychy7001 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #3789.

add_overlap_chunk stored the left context with overlap_feats[:, -n:, :]. With n == 0 this returns every frame, so with chunk_size=[0, 10, 5] (the streaming example in README and docs) the final chunk re-decodes the previous chunk's features and repeats the last characters, e.g. 火爆 → 火爆爆爆.

The start index is now computed explicitly in a small _tail_frames helper, used for both the final and non-final cache updates. Behaviour for non-zero context sizes is unchanged.

Type of change

  • Bug fix
  • Documentation
  • Example or demo
  • Runtime or deployment
  • Benchmark or evaluation
  • Model/training change

Validation

  • python -m compileall funasr examples tests

  • Docs or links checked

  • Runtime/deployment command tested

  • python tests/test_funasr_onnx_paraformer_online_overlap.py against the installed package: 3 passed. Against the unfixed package, the two zero-context tests fail and the non-zero test passes.

  • The test is added to test-funasr-onnx-package.yml (path filters and a step after the installed-wrapper check), so CI runs it against the built wheel.

  • AISHELL-1 test (7176 utterances), iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online v2.0.5, chunk_size=[0, 10, 5], onnxruntime 1.20.1 CPU, dither 0:

export CER before CER after changed outputs
FP32 17.23% 15.18% 2170
quantized 17.15% 15.08% 2179

PyTorch AutoModel with the same settings: 14.81%.

  • With chunk_size=[5, 10, 5], outputs for the sampled utterances are identical before and after (the fix does not change slicing for non-zero sizes).

User impact

Removes the extra tail decoding caused by retaining all overlap frames when the requested context size is zero. This affects users running the streaming ONNX model with the documented chunk_size=[0, 10, 5]. Other trailing repeats that also appear in the PyTorch reference are out of scope.

Notes for reviewers

Only paraformer_online_bin.py is affected; the C++ runtime does not use this code. Running black on the file also reformats unrelated pre-existing lines, so those are left untouched.

…eaming Paraformer

overlap_feats[:, -0:, :] returns every frame instead of none, so with
chunk_size=[0, 10, 5] (the streaming example in README and docs) the
final chunk re-decodes the previous chunk's features and repeats the
last characters. Compute the tail start index explicitly; the same
applies to the non-final cache when chunk_size[0] + chunk_size[2] is 0.
@ychy7001
ychy7001 force-pushed the fix/funasr-onnx-online-zero-left-chunk branch from 45c7863 to c81b11d Compare October 24, 2026 09:24
@LauraGPT
LauraGPT merged commit e867d28 into modelscope:main Oct 31, 2026
2 checks passed
LauraGPT added a commit that referenced this pull request Oct 31, 2026
Preserve ychy7001's #3792 inference change and regressions while retaining #3790's workflow checks.

Co-authored-by: ychy7001 <62779060+ychy7001@users.noreply.github.com>

Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
LauraGPT added a commit that referenced this pull request Oct 31, 2026
Integrate ychy7001's #3792 inference change and regressions with the #3790 cache checks. The combined tree passed 55 focused CPU tests and 20 real synthetic FP32 L20Z boundary cases, plus exact-head CI and package-byte acceptance. Not pretrained ASR accuracy or a package publication.

Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
@LauraGPT

Copy link
Copy Markdown
Collaborator

Merged normally with the original contributor commit preserved. The zero-context failures were reproduced on main; the candidate passed 50 focused CPU tests and eight actual L20Z CUDA wrapper-boundary cases. Author-head and merged-main Python 3.11/3.12 CI, package source bytes and the three regression logs were verified.

#3808 subsequently integrates #3792 while retaining these tests; its combined tree passes 55 focused tests and 20 CUDA boundary cases, plus both new-head/final-main CI matrices. The GPU graphs have explicit fixed synthetic parameters (FP32, batch 1); this does not reproduce or independently confirm the reported AISHELL CER, pretrained recognition quality, or a full repository suite. Existing released packages remain unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

funasr_onnx streaming Paraformer repeats the last characters when chunk_size[0] is 0

2 participants