Skip to main content

A high-performance Python package for calculating Word Error Rate (WER), powered by Rust.

Project description

logo-werx

⚡Lightning fast Word Error Rate Calculations

Meta PyPI version  Supports Python 3.10-3.14  Apache 2.0 License  uv  Ruff  Powered by Rust  Analytics in Motion

What is WERx?

WERx is a high-performance Python package for calculating Word Error Rate (WER), built with Rust for unmatched speed, memory efficiency, and stability. WERx delivers accurate results with exceptional performance, making it ideal for large-scale evaluation tasks.


🚀 Why Use WERx?

Blazing Fast: Rust-powered core delivers outstanding performance, optimized for large datasets

🧩 Robust: Designed to handle edge cases gracefully, including empty strings and mismatched sequences

📐 Insightful: Provides rich word-level error breakdowns, including substitutions, insertions, deletions, and weighted error rates

🛡️ Production-Ready: Minimal dependencies, memory-efficient, and engineered for stability


⚙️ Installation

You can install WERx either with 'uv' or 'pip'.

Using uv (recommended)

uv pip install werx

Using pip

pip install werx

✨ Usage

Import the WERx package

Python Code:

import werx

Examples

1. Single sentence comparison

Python Code:

wer = werx.wer('i love cold pizza', 'i love pizza')
print(wer)

Results Output:

0.25

2. Corpus level Word Error Rate Calculation

Python Code:

ref = ['i love cold pizza','the sugar bear character was popular']
hyp = ['i love pizza','the sugar bare character was popular']
wer = werx.wer(ref, hyp)
print(wer)

Results Output:

0.2

3. Weighted Word Error Rate Calculation

Python Code:

ref = ['i love cold pizza', 'the sugar bear character was popular']
hyp = ['i love pizza', 'the sugar bare character was popular']

# Apply lower weight to insertions and deletions, standard weight for substitutions
wer = werx.weighted_wer(
    ref, 
    hyp, 
    insertion_weight=0.5, 
    deletion_weight=0.5, 
    substitution_weight=1.0
)
print(wer)

Results Output:

0.15

4. Complete Word Error Rate Breakdown

The analysis() function provides a complete breakdown of word error rates, supporting both standard WER and weighted WER calculations.

It delivers detailed, per-sentence metrics—including insertions, deletions, substitutions, and word-level error tracking, with the flexibility to customize error weights.

Results are easily accessible through standard Python objects or can be conveniently converted into Pandas and Polars DataFrames for further analysis and reporting.

4a. Getting Started

Python Code:

ref = ["the quick brown fox"]
hyp = ["the quick brown dog"]

results = werx.analysis(ref, hyp)

print("Inserted:", results[0].inserted_words)
print("Deleted:", results[0].deleted_words)
print("Substituted:", results[0].substituted_words)

Results Output:

Inserted Words   : []
Deleted Words    : []
Substituted Words: [('fox', 'dog')]

4b. Converting Analysis Results to a DataFrame

Note: To use this module, you must have either pandas or polars (or both) installed.

Install Pandas / Polars for DataFrame Conversion

uv pip install pandas
uv pip install polars

Python Code:

ref = ["i love cold pizza", "the sugar bear character was popular"]
hyp = ["i love pizza", "the sugar bare character was popular"]
results = werx.analysis(
    ref, hyp,
    insertion_weight=2,
    deletion_weight=2,
    substitution_weight=1
)

We have created a special utility to make working with DataFrames seamless. Just import the following helper:

import werx
from werx.utils import to_polars, to_pandas

You can then easily convert analysis results to get output using Polars:

# Convert to Polars DataFrame
df_polars = to_polars(results)
print(df_polars)

Alternatively, you can also use Pandas depending on your preference:

# Convert to Pandas DataFrame
df_pandas = to_pandas(results)
print(df_pandas)

Results Output:

wer wwer ld n_ref insertions deletions substitutions inserted_words deleted_words substituted_words
0.25 0.50 1 4 0 1 0 [] ['cold'] []
0.1667 0.1667 1 6 0 0 1 [] [] [('bear', 'bare')]

🚀 Performance Benchmarks

WERx was benchmarked on the LibriSpeech test sets (industry-standard ASR benchmark) evaluating OpenAI Whisper-base transcriptions:

Dataset Utterances Total Time (ms) Throughput
test-clean 2,620 3.35 781,791 utt/s
test-other 2,939 2.78 1,057,194 utt/s
Combined 5,559 6.13 ~907,000 utt/s

What This Means in Practice

Evaluating ASR at scale (WER computation only):

  • 1 million utterances: ~1.1 seconds at ~907,000 utt/s
  • 1-hour podcast (~3,000 utterances): ~3.3 ms of WER computation
  • Large corpora (millions of utterances): seconds, not hours

Technical Performance

Memory Efficiency:

  • Effective space complexity: O(n) per sequence vs O(m×n) traditional implementations
  • Rolling window algorithm reduces memory by 5-50× for typical sentence lengths (10-40 tokens)

Parallelization:

  • Rayon-based automatic multi-core scaling
  • Near-linear speedup with CPU cores

Running Benchmarks Yourself

# Install with benchmark dependencies
uv pip install werx[benchmarks]

# Run full LibriSpeech benchmark
uv run benchmarks/speed_comparison_librispeech_full.py

See the benchmarks/ directory for all benchmark scripts.

📊 Benchmark Details: LibriSpeech test-clean + test-other (5,559 utterances), OpenAI Whisper-base (v20240930), Python 3.14.2, averaged over 10 runs

Environment: 16-core (24 threads) CPU, 64 GB RAM, NVMe SSD; single process, all data in RAM. Results are CPU-bound; no GPU is used for WER.


📄 License

This project is licensed under the Apache License 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

werx-0.3.1.tar.gz (16.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

werx-0.3.1-cp314-cp314-win_amd64.whl (189.3 kB view details)

Uploaded CPython 3.14Windows x86-64

werx-0.3.1-cp314-cp314-manylinux_2_34_x86_64.whl (282.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

werx-0.3.1-cp314-cp314-macosx_11_0_arm64.whl (247.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

werx-0.3.1-cp313-cp313-win_amd64.whl (189.4 kB view details)

Uploaded CPython 3.13Windows x86-64

werx-0.3.1-cp313-cp313-manylinux_2_34_x86_64.whl (282.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

werx-0.3.1-cp313-cp313-macosx_11_0_arm64.whl (247.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

werx-0.3.1-cp312-cp312-win_amd64.whl (189.3 kB view details)

Uploaded CPython 3.12Windows x86-64

werx-0.3.1-cp312-cp312-manylinux_2_34_x86_64.whl (282.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

werx-0.3.1-cp312-cp312-macosx_11_0_arm64.whl (247.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

werx-0.3.1-cp311-cp311-win_amd64.whl (190.6 kB view details)

Uploaded CPython 3.11Windows x86-64

werx-0.3.1-cp311-cp311-manylinux_2_34_x86_64.whl (282.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

werx-0.3.1-cp311-cp311-macosx_11_0_arm64.whl (246.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

werx-0.3.1-cp310-cp310-win_amd64.whl (190.6 kB view details)

Uploaded CPython 3.10Windows x86-64

werx-0.3.1-cp310-cp310-manylinux_2_34_x86_64.whl (282.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

werx-0.3.1-cp310-cp310-macosx_11_0_arm64.whl (246.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file werx-0.3.1.tar.gz.

File metadata

  • Download URL: werx-0.3.1.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for werx-0.3.1.tar.gz
Algorithm Hash digest
SHA256 43a7dab90e1a371ea514e31ffcb38f65974dd100bc79a5315ba6dfce66e94647
MD5 09ef6492ed37d21dcf2b4a0b949d70d2
BLAKE2b-256 f0987049622cf765588ad77e89097726d58ef4cb5949ffadcbdc56758139917d

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1.tar.gz:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: werx-0.3.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 189.3 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for werx-0.3.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 bf24311880174571d1cad3a15cb44feb88fe06df689eb3764a1194f1648f72a1
MD5 51ec3abd324c08e2b39b4596cf0c46d7
BLAKE2b-256 59ec9c6bf6ff84ecb163e1db6fa7b59102c751d9eff120ef856b3743f56447d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp314-cp314-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for werx-0.3.1-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3c5e087256d20fc4d9db98ad31320b2031d3ee9495f049c395a974789d3acd41
MD5 c9b657af021280d7be73fdea4c67098a
BLAKE2b-256 24194f3ce7a9997704659400a26e2315d5f2539026bcd80697f6db83484100ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp314-cp314-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for werx-0.3.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c21fa236b8e03d2735fc2008c6c49360c63dc5fc4d73b99f55a2ac6799f458a5
MD5 05502aae092395f3dd68259e0869a384
BLAKE2b-256 1194e6107387d1937d2f3a694fbf990cfd7c60e5f3dac5fbd474d3d8171ec0d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: werx-0.3.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 189.4 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for werx-0.3.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ff557d2876e5ffbf8e30fd006266da612955f41fabbd847e0d8e7534ca6cd323
MD5 61d4b1f3ad25ee06e95f433d96906c00
BLAKE2b-256 c79702554ce07678450d1e88c56677f5f4a079d77ec680fc1eb0ec9f1231e98d

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp313-cp313-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for werx-0.3.1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f6f10c7454cd516f78e7d7cd43bd4bee0e72d359066d54b5c684096ab21d22ae
MD5 947035dff0ff283d7b3ccf1b8f1f1baa
BLAKE2b-256 0dc43572388b8208ebbc56a07405f15f8239072a91bbc35603d944654d12ecc9

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for werx-0.3.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f37841372e81b3e19b69f7262373965a022fcae1078cf1bcab81546910927c4
MD5 b0765df7ba6b68777ff90009178b9c8c
BLAKE2b-256 cc42d15dfe2a50b01ad63e8f98e98a84a9a9963538bbc9700f4011e56c402599

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: werx-0.3.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 189.3 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for werx-0.3.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f58341d59fa3ad46108df2895d86327ff6791e9beaa442b72f3b99258d88b4c6
MD5 e7fe67897d4d00d1a4c26b7b21bef53a
BLAKE2b-256 6b2739da231dbb028f1b1806b8a3b85c1130664430ed705c80840fca46f9404f

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp312-cp312-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for werx-0.3.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9d651487c148e26db041c888910442e0a6da1ea0b4de75e3603544389dca5dac
MD5 c7a9cf90e96ce466c79e0c0d6c78cb2a
BLAKE2b-256 bcc22f5fc2a4aeeaa45cf25d6e6c7866843db1cd968437a80203ab6882693bf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for werx-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a0d666ff7719a2a26202d42eab3f604f5b0938124127f7c24e36ea4d559d7178
MD5 19e7ed79acc0d29940a107aaaca4a13b
BLAKE2b-256 41cbfd81436a1651d007667cc2d7fd21d1edbba98f9f242575cab7b23bab22a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: werx-0.3.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 190.6 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for werx-0.3.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 62fe6790466b6dd9c03611395f1f41d1059c85c000534cddf81bb9c2ecac0242
MD5 15b07d771edc7305949ee23ea03d784f
BLAKE2b-256 ff2b7b12d29c226cca9a36caac7f4093dd4467ee239f90fa20fc867155ac2ac6

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp311-cp311-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for werx-0.3.1-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4d6692a78650585c2ebc9cc5d7f6d6e2db1ab6ffb217e55e85a94ed6bfe23df5
MD5 153e186ba0b4485afeaead8b72fd3218
BLAKE2b-256 20fa4ae9a9b1ee268ae2807a28c84c9b44d5108392de1cebaaad760aa4f6b225

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for werx-0.3.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f226cce826019d121965db89b61f7badce7bc87c127a9c38ef0cb36382c109d
MD5 d34379a291eb346ccb177203ef46e968
BLAKE2b-256 37c49f7ad645dcf3ebe7e202a74afb7efd9edd9e6e6cf377b4c96f77cc9cf8fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: werx-0.3.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 190.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for werx-0.3.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 140fece3e2fb2c29cb98310fdac347ae7acc2cf9f575db34ad3eeabec41cd42f
MD5 aafc11f04287761a3aa369a122eba91a
BLAKE2b-256 a605a3f4c7b81704c19022cce4323ea8e81882a0fbf17396e70372ff371a0094

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp310-cp310-win_amd64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for werx-0.3.1-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 aaa6b80afc68de4590cab1fcfecdc9e48990ac93a53382ee1f8904fab4d317fd
MD5 9a1932405678c9b9d1b938ab73c04694
BLAKE2b-256 2d5fe1641158547c28fcf302b25e5229f86e4624b6158511d0e83acbbeed5db2

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file werx-0.3.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for werx-0.3.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3598248131ffc3574e7c891e885e93cd421d7c74ead07ea0e4a70d466c05e58d
MD5 b59e0c0f7ff61b2eeaff1ed3639faab7
BLAKE2b-256 a0c9633bc66b4b8aee58f303a488b9ebea57d61cc0107b718a3444bcb1d76fcd

See more details on using hashes here.

Provenance

The following attestation bundles were made for werx-0.3.1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: CI.yml on analyticsinmotion/werx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page