Skip to main content

semcer

Equal CER, Unequal Damage: Severity-Weighted Character Error Rate for OCR
Nguyen Nguyen, Yongyi Zang

Paper (coming soon) Model Dataset Docs Open in Colab

Six one-character OCR errors, each charged 1 by CER and a different severity by semcer

CER counts every character error as 1. semcer uses the same alignment and gives each error a severity from 0 (harmless) to 1 (meaning lost), predicted by a 0.8B model that runs locally. The figure shows six one-character errors from the paper, with the mean rating of human readers on the same scale.

A line's score is the sum of its severities divided by the reference length, so semcer is at most CER.

Install

pip install semcer

Usage

import semcer

result = semcer.score(reference="The total is 15 dollars.", hypothesis="The total is 75 dollars.")
print(result.explain())
# semcer=0.0414  CER=0.0417  (1 edit(s) over 24 reference graphemes; lower is better)
#   SUB ref[13:14] '1' -> '7'  severity 0.99 (meaning lost)

For many lines, load the scorer once. The model downloads on first use.

scorer = semcer.SemCER()
results = scorer.score_batch(references=refs, hypotheses=hyps)

Or from the shell, with two text files that hold one line each per row:

semcer score --references refs.txt --hypotheses hyps.txt --output scores.jsonl

Speed

Device Precision Edits/s Lines/s
CPU (12-vCPU Xeon, 2.2 GHz) fp32 5.2 0.63
NVIDIA T4 16 GB (free Colab) fp32 46 5.5
NVIDIA A100 40 GB fp32 144 17.4
NVIDIA A100 40 GB bf16 209 25.2

Measured on 201 lines containing 1,667 edits. A GPU is used when available, and is the practical choice for a corpus.

Citation

To be added with the paper.

License

Apache-2.0 for the code and the model weights.

The scan crops in the figure come from OmniDocBench and VieBookRead. They are shown for illustration, remain under those datasets' terms, and are not covered by this repository's license.

Metadata

Release files for semcer 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for semcer 0.1.2
File Size Uploaded Provenance Actions
semcer-0.1.2.tar.gz 61.0 kB Without provenance Details for semcer-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for semcer 0.1.2
File Interpreter ABI Platform Actions
semcer-0.1.2-py3-none-any.whl Python 3 none any Details for semcer-0.1.2-py3-none-any.whl

Total release size: 110.8 kB

Release files / semcer-0.1.2.tar.gz

Download URL semcer-0.1.2.tar.gz
Size 61.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0c2d1062bbace18a6ebb6f8095527c161b743a4285b1029ffb6c20258c64d636
BLAKE2b-256 checksum
How to use checksums
cc8441eb88dd8e705fb9136b3a8b0e4cb8af7af516faf71534e914c16519bea4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / semcer-0.1.2-py3-none-any.whl

Download URL semcer-0.1.2-py3-none-any.whl
Size 49.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3f4338c01976d9898b20055a391c0abfa1b025f3825322c049abaa80cb59d81
BLAKE2b-256 checksum
How to use checksums
f5926144b4aaff2dbb5e36ca45407c5bbf97964c7c8e224b1b58ddc681b2759c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for semcer 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page