Character error rate (CER): calculation, examples, and when to use it
Learn how CER counts character edits in speech transcripts, calculate a 20% example in Python, and choose CER or WER with consistent text normalization.
Character error rate (CER) measures how many character edits turn a reference transcript into a system’s prediction. It is useful when word boundaries are unclear or word tokenization varies, but the score depends on what the evaluator counts as a character and how text is normalized. Hugging Face CER metric
Formula
CER = (S + D + I) / N. S is substitutions, D deletions, and I insertions in a minimum-edit alignment; N is the number of reference characters. A substitution changes a character, a deletion omits one, and an insertion adds one. Multiply the ratio by 100 for a percentage. Lower is better; zero means the normalized strings match exactly.
CER = (S + D + I) / N
Worked example
Reference: hello (5 characters). Prediction: hallo. One character, e, was substituted with a, so CER = 1/5 = 0.20, or 20%. Insertions can make CER exceed 100% because the numerator is not capped at the reference length. That is possible by definition, not necessarily a bug.
Calculate it in Python
The Evaluate library provides a CER metric. Install the packages in an environment where you are allowed to add dependencies, then pass reference and prediction strings in matching order. The result is a ratio; format it as a percentage if that is clearer.
pip install --upgrade evaluate jiwerfrom evaluate import load
metric = load("cer")
score = metric.compute(
references=["hello"],
predictions=["hallo"],
)
print(f"{score:.0%}") # 20%Choosing CER or WER
WER counts word edits and is intuitive when languages have reliable word boundaries and a consistent tokenizer. CER avoids choosing word boundaries and can be a useful primary or complementary measure for some multilingual ASR settings. A 2025 study tested Malayalam, English, and Arabic and found CER closer to human judgments in its tested settings; this is evidence for those settings, not a universal rule. NAACL 2025 study
Make comparisons reproducible
Use the same reference transcripts, segmentation, alignment implementation, and normalization for every system. Decide whether to fold case, remove punctuation or spaces, normalize numbers, or retain disfluencies, and report those choices. Some character-level tools count spaces as characters unless a transform removes them. A library may iterate Unicode code points, while a reader may think in grapheme clusters; one visible character can contain multiple code points. Check the metric’s transforms for scripts that use combining marks. JiWER character transforms · Unicode text segmentation
CER counts edit operations, not their meaning or severity. Inspect substitutions, deletions, and insertions, and listen to or review important errors when the task requires it. Compare scores only when evaluation rules and CER variants match.