Skip to content

fix(metrics): report unscored references in the WER summary line - #3787

Merged
LauraGPT merged 1 commit into
modelscope:mainfrom
MohammadHijjawi97:fix/wer-summary-missing-hyp
Oct 22, 2026
Merged

LauraGPT merged 1 commit into
modelscope:mainfrom
MohammadHijjawi97:fix/wer-summary-missing-hyp

Conversation

@MohammadHijjawi97

Copy link
Copy Markdown
Contributor

Summary

The last line of the WER report, Scored N sentences, M not present in hyp., was computed from the hypothesis file: N was the number of hypothesis lines and M the number of hypotheses without a reference. A reference whose hypothesis is missing (for example an utterance the decoder dropped) was never reported, and a stray hypothesis was counted as scored.

This counts the utterances actually scored and the references that have no hypothesis, matching the Kaldi compute-wer summary the line mirrors. The same two-line fix is applied to funasr/metrics/wer.py and the four standalone copies (runtime/python/utils, runtime/python/libtorch/funasr_torch/utils, examples/aishell/paraformer/utils, examples/aishell/e_paraformer/utils).

Repro: ref has utt1, utt2, utt3; hyp has utt1 and utt3 only.

Before:

%SER 0.0 [ 0 / 2 ]
Scored 2 sentences, 0 not present in hyp.

After:

%SER 0.0 [ 0 / 2 ]
Scored 2 sentences, 1 not present in hyp.

With an extra hypothesis utt9 that has no reference, the old line read Scored 3 sentences, 1 not present in hyp.; it now reads Scored 2 sentences, 1 not present in hyp.

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

  • pytest tests/test_metrics_wer.py: 17 passed. Without the fix, the 5 new tests (library plus each of the 4 copies) fail.

  • black --line-length=100 (24.4.0, as pinned in pre-commit) leaves the new test code and the four copies unchanged.

User impact

Anyone running python -m funasr.metrics.wer or the Aishell utils/compute_wer.py recipe step. If decoding silently drops utterances, the report now says so instead of claiming every reference was scored.

Notes for reviewers

The %WER and %SER numbers are unchanged; only the final summary line's counts change. Missing hypotheses are still skipped rather than scored as deletions, as before.

The last line of the WER report, "Scored N sentences, M not present in
hyp.", was computed from the hypothesis file: N was the number of
hypothesis lines and M the number of hypotheses without a reference. A
reference whose hypothesis is missing (for example an utterance the
decoder dropped) was therefore never reported, and a stray hypothesis
was counted as scored. With three references and only two of them
decoded, the report read "Scored 2 sentences, 0 not present in hyp."

Count the utterances actually scored and the references that have no
hypothesis, matching the Kaldi compute-wer summary this line mirrors.
Apply the same fix to the runtime and Aishell copies of compute_wer.py.
@LauraGPT

LauraGPT commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Correction to my earlier review: I incorrectly treated DCO as a mandatory gate for this PR. The current contribution guide, branch protection/rules and checks do not establish that requirement. I withdraw that request; no commit rewrite or sign-off is needed to satisfy the review requirement I invented. Sorry for the unnecessary delay.

Exact head 4444e35, main 24217c8, synthetic merge a21aa21 are unchanged. The recorded 2026-10-22 03:37 UTC run had base+submitted tests 12 passed/5 failed; head and merge each 17 targeted plus 2 adjacent tests passed, with compileall and exact six-file tree checks passing. The receipt hashes and refs were checked again, without rerunning unchanged tests. This is Python 3.12 CPU report-summary validation, not GPU inference, hosted CI or full-suite evidence.

@LauraGPT LauraGPT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review: the five summary implementations now count scored reference/hypothesis pairs and missing reference-side hypotheses correctly; stray hypotheses no longer inflate the summary. WER, SER and the existing skip behavior are unchanged. The fixture covers missing and stray hypotheses in the library and four copies. No correctness findings remain in this focused change. The earlier unsupported DCO gate has been withdrawn.

Exact head 4444e35, main 24217c8, synthetic merge a21aa21 are unchanged. The recorded 2026-10-22 03:37 UTC run had base+submitted tests 12 passed/5 failed; head and merge each 17 targeted plus 2 adjacent tests passed, with compileall and exact six-file tree checks passing. The receipt hashes and refs were checked again, without rerunning unchanged tests. This is Python 3.12 CPU report-summary validation, not GPU inference, hosted CI or full-suite evidence.

@LauraGPT
LauraGPT merged commit fbbfe01 into modelscope:main Oct 22, 2026
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.

2 participants