Skip to content

feat: Add CharacterErrorRate (CER) metric to ignite.metrics.nlp#3785

Open
Shubh3005 wants to merge 4 commits into
pytorch:masterfrom
Shubh3005:feature/character-error-rate
Open

feat: Add CharacterErrorRate (CER) metric to ignite.metrics.nlp#3785
Shubh3005 wants to merge 4 commits into
pytorch:masterfrom
Shubh3005:feature/character-error-rate

Conversation

@Shubh3005

Copy link
Copy Markdown

Summary

Implements CharacterErrorRate (CER) as a follow-up to #3638 (WER), resolving #3634.

CER measures the edit distance at the character level — used in ASR and OCR evaluation where a single character error (e.g. misreading a financial figure) is a severe failure.

Changes

  • ignite/metrics/nlp/character_error_rate.py — CER metric inheriting from _BaseErrorRate, using character-level Levenshtein distance
  • tests/ignite/metrics/nlp/test_character_error_rate.py — 15 test cases covering: identical sequences, single deletion/insertion/substitution, empty inputs, batch accumulation, multi-update accumulation, reset, single string input, whitespace as character, unicode
  • ignite/metrics/nlp/__init__.py — exports CharacterErrorRate

Design

Follows the same structure as word_error_rate.py and bleu.py:

Closes #3634

Shubh3005 added 3 commits June 9, 2026 13:44
Implements CharacterErrorRate as a follow-up to PR pytorch#3638 (WER).
Closes pytorch#3634

- character_error_rate.py: CER metric using character-level
  Levenshtein distance, inheriting from _BaseErrorRate
- test_character_error_rate.py: 15 test cases covering edge cases,
  batch accumulation, reset, unicode, and whitespace handling

Follows same structure as word_error_rate.py and bleu.py conventions.
@Shubh3005

Copy link
Copy Markdown
Author

"Updated in commit 329d981: made self-contained — inlined _edit_distance and full Metric implementation directly, removing dependency on unmerged PR #3638. All 15 tests pass on master."

@aaishwarymishra

aaishwarymishra commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Hi, @Shubh3005 we really appreciate your pr, but I would still recommend you check withe owner of the other open pr if they are still working on it or not just be sure :)

If not then we can move forward with your pr.

@Shubh3005

Copy link
Copy Markdown
Author

Thank you! I'll reach out to @Manimaran-tech on PR #3638 to check their status. Will follow up shortly.

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

Labels

module: metrics Metrics module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add Word Error Rate (WER) and Character Error Rate (CER) metrics to ignite.metrics.nlp

2 participants