semcer
Equal CER, Unequal Damage: Severity-Weighted Character Error Rate for OCR
Nguyen Nguyen, Yongyi Zang
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.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| semcer-0.1.3.tar.gz | 66.3 kB | Without provenance | Details for semcer-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| semcer-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for semcer-0.1.3-py3-none-any.whl |
Total release size: 120.0 kB
Release files / semcer-0.1.3.tar.gz
| Download URL | semcer-0.1.3.tar.gz |
|---|---|
| Size | 66.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e70749b2f3e11a2260ee707d33e2ec2f3d0ad57715f2df651e0f949275fbd9e
|
|
BLAKE2b-256 checksum How to use checksums |
ec42f9425e62b535a4f5fc24caec3a5d61aa522aa751bac9e22d98fef2f6fa5b
|
| 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.3-py3-none-any.whl
| Download URL | semcer-0.1.3-py3-none-any.whl |
|---|---|
| Size | 53.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b33fde066b4f778a952ccbd342708d1fb51577cd76fe8988ccf3fd67939531e0
|
|
BLAKE2b-256 checksum How to use checksums |
22fd62dbc03235b50c23ec1e5587da1647df4a76d2c9af8c626686bbed35ab99
|
| 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.3
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.