Registry / ai-ml / jiwer
library4.0.0pypypi✓ verified 23d ago

Jiwer is a simple and fast Python package designed to evaluate Automatic Speech Recognition (ASR) systems. It computes similarity measures such as Word Error Rate (WER), Match Error Rate (MER), Word Information Lost (WIL), Word Information Preserved (WIP), and Character Error Rate (CER). It uses RapidFuzz, which leverages C++ under the hood, for efficient minimum-edit distance calculations, making it faster than pure Python implementations. The current version is 4.0.0, released in June 2025, and it maintains an active development and release cadence.

pip install jiwer
INSTALL
IMPORT
SIG · JIWER
J
jiwer
ai-mlpythonv4.0.0
Install
2.5s avg
Import
70ms
Disk
31MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.074s · 34.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.5s · import 0.066s · 31MB
31MB installed
● package 31MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

wer
from jiwer import wer
cer
from jiwer import cer
process_words
import jiwer output = jiwer.process_words(reference, hypothesis)
output = jiwer.compute_measures(reference, hypothesis)
The 'compute_measures' function was renamed to 'process_words' in version 4.0.0. The return type also changed from a dictionary to a dataclass (WordOutput).
process_characters
import jiwer output = jiwer.process_characters(reference, hypothesis)
Compose
from jiwer import Compose
Used for creating transformation pipelines for text normalization.

This quickstart demonstrates how to calculate the Word Error Rate (WER) for both single and multiple reference/hypothesis pairs using `jiwer.wer()`. It also shows how to use `jiwer.process_words()` to obtain a more detailed output, including various error measures and the alignment between the reference and hypothesis.

import jiwer # Calculate Word Error Rate (WER) for single strings reference_single = "hello world" hypothesis_single = "hello duck" error_single = jiwer.wer(reference_single, hypothesis_single) print(f"WER (single): {error_single}") # Calculate WER for multiple sentences (lists of strings) references_multiple = ["hello world", "i like monthy python"] hypotheses_multiple = ["hello duck", "i like python"] error_multiple = jiwer.wer(references_multiple, hypotheses_multiple) print(f"WER (multiple): {error_multiple}") # Get detailed output including alignments and all measures output_details = jiwer.process_words(reference_single, hypothesis_single) print(f"\nDetailed output WER: {output_details.wer}") print(f"Detailed output MER: {output_details.mer}") print(f"Alignments: {output_details.alignments}")
Debug
Known issues
breakingThe functions `jiwer.compute_measures()` and `jiwer.visualize_measures()` were renamed in version 4.0.0. They are now `jiwer.process_words()` and `jiwer.visualize_alignment()` respectively. Additionally, `process_words` returns a `WordOutput` dataclass instead of a dictionary.
fix
Update calls from `jiwer.compute_measures()` to `jiwer.process_words()` and `jiwer.visualize_measures()` to `jiwer.visualize_alignment()`. Adjust code to access results from the returned `WordOutput` or `CharacterOutput` dataclass attributes (e.g., `output.wer`) instead of dictionary keys.
affects: >=4.0.0
breakingThe behavior for handling empty reference sentences changed in version 4.0.0. Previously, an empty reference with an empty hypothesis could lead to undefined behavior (division by zero). As of 4.0.0, this scenario is explicitly defined to yield zero error, supporting evaluation for models hallucinating on silent audio.
fix
Review existing code that processes empty or potentially empty reference/hypothesis pairs. The new behavior is generally safer, but ensure it aligns with your specific evaluation logic.
affects: >=4.0.0
breakingThe internal representation of alignment chunks changed in version 4.0.0. Alignments are now returned as a list of `jiwer.AlignmentChunk` dataclass objects, replacing the previous tuple-based format. This improves clarity and accessibility of alignment details.
fix
If you are directly inspecting or parsing the `alignments` output from `process_words()` or `process_characters()`, update your code to access attributes of the `AlignmentChunk` dataclass (e.g., `chunk.type`, `chunk.ref_start_idx`) instead of tuple indices.
affects: >=4.0.0
gotchaWord Error Rate (WER) can exceed 100% (or 1.0). This occurs when the total number of errors (substitutions, deletions, and insertions) is greater than the number of words in the reference text, often due to a high number of insertions by the ASR system.
fix
Understand that WER > 1.0 is an expected and valid outcome, indicating poor ASR performance with many extraneous words. Do not cap the WER at 1.0 in your reporting or analysis unless specifically required by a particular standard.
affects: All versions
gotchaWhen `jiwer.wer()` or `jiwer.cer()` are provided with lists of reference and hypothesis sentences, they internally concatenate all sentences to compute a *single, global* error rate for the entire dataset, which is standard for corpus-level evaluation. It does not return individual error rates per sentence.
fix
If sentence-by-sentence error rates are needed, you must iterate through your sentence pairs and call `jiwer.wer()` (or `jiwer.cer()`) for each pair individually, or use `jiwer.process_words()`/`process_characters()` and then access the `.wer` or `.cer` attribute of the returned object for each item in the results list.
affects: All versions
gotchaJiwer calculates metrics on the raw input strings. For robust and fair evaluation, it is crucial to apply consistent text normalization (e.g., lowercasing, punctuation removal, expansion of contractions) to both reference and hypothesis strings *before* calling jiwer functions.
fix
Utilize `jiwer.Compose()` with transformation functions like `jiwer.ToLowerCase()`, `jiwer.RemovePunctuation()`, `jiwer.ExpandCommonEnglishContractions()`, etc., to build a preprocessing pipeline. Apply this pipeline to your reference and hypothesis texts before computing error rates.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jiwer'
The jiwer library is not installed in your current Python environment.
fix
Run `pip install jiwer` in your terminal to install the library.
AttributeError: module 'jiwer' has no attribute 'cer'
The `cer` function (or `wer`, `mer`, etc.) is typically imported directly or accessed from the output of processing functions, rather than as a direct attribute of the top-level `jiwer` module when using `import jiwer`.
fix
Either import the specific function directly (e.g., `from jiwer import cer`) or use `jiwer.process_characters()` and access the `cer` attribute from the returned object (e.g., `output = jiwer.process_characters(ref, hyp); error = output.cer`).
ImportError: cannot import name 'compute_measures' from 'jiwer'
The `compute_measures` function has been deprecated in newer versions of the `jiwer` library (e.g., from version 4.0.0 onwards, released June 2025).
fix
Use `jiwer.process_words()` or `jiwer.process_characters()` instead, which return an object containing all individual metrics like `wer`, `mer`, `wil`, `wip`, and `cer`.
jiwer WER/CER results are unexpectedly high or inaccurate
The reference and hypothesis texts were not properly normalized (e.g., lowercased, punctuation removed, numbers standardized) before calculating the error rate, leading to spurious mismatches.
fix
Apply consistent text normalization steps (such as converting to lowercase, removing punctuation, and standardizing numbers) to both the reference and hypothesis strings before passing them to `jiwer` functions like `wer()` or `cer()`.
Upgrade
Version history
4.0.0latest on PyPI · released Jun 19, 2025
Audit
Dependencies
rapidfuzzrequiredUsed for efficient minimum-edit distance calculation, providing core performance benefits.
clickoptionalRequired for the command-line interface (CLI) functionality.
Agent activity
9 hits · last 30 days
node
8
Resources