Repository navigation
Handle all-empty reference batches in WER and CER - #895
Open
snygginghani wants to merge 1 commit into
Open
snygginghani wants to merge 1 commit into
snygginghani wants to merge 1 commit into
Conversation
atishay-kasliwal
left a comment
There was a problem hiding this comment.
Ran WER and CER with all-empty references (['a b'] vs [''], two empty refs, empty vs empty). Without concatenate_texts, main raised ZeroDivisionError; here both modes match jiwer 4.0.0 (2, 3, 3, 4, 0, 0). Mixed empty and non-empty references are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The default segmented WER and CER paths sum the errors and reference lengths returned by JiWER, then divide by the total reference length. An all-silence batch can therefore raise
ZeroDivisionErroreven though JiWER 4 supports empty references.Apply JiWER 4's empty-reference behavior when the batch has no reference words or characters. This returns zero for correct silence and counts words or characters inserted into silence. Mixed batches still use the total reference length.
Validation
With JiWER 4.0.0, the following returns 3 for WER and 11 for CER. Both calls raised on the baseline.
python -m pytest tests/test_speech_metrics.py -qpassed all eight cases, including empty, whitespace-only, and mixed reference batches. Six cases failed on the baseline.git diff --checkpassed on the changed files.AI assistance was used to prepare the patch and tests.