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

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 one JSON object per line (id, reference, hypothesis):

semcer score --input pairs.jsonl --output scores.jsonl

Speed

Device Precision Edits/s Lines/s
CPU (12-vCPU Xeon, 2.2 GHz) fp32 5.2 0.63
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.

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.1

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.1
File Size Uploaded Provenance Actions
semcer-0.1.1.tar.gz 59.4 kB Without provenance Details for semcer-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 108.5 kB

Release files / semcer-0.1.1.tar.gz

Download URL semcer-0.1.1.tar.gz
Size 59.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d3b7cc0386afce246c8b4e78882fad97cbdd1511544dd628f0e05e36aff8d59b
BLAKE2b-256 checksum
How to use checksums
bf31fa35cd881985c702fa6eccc42987aa73b1b2b08d559c88d4b8813e838e07
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.1-py3-none-any.whl

Download URL semcer-0.1.1-py3-none-any.whl
Size 49.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ff009f1ce096b5f6e1e900dd1d472e05ded2b7809fd25e76a3927b6d59b3bc3
BLAKE2b-256 checksum
How to use checksums
f13ec7012726d0fbbc18e28e9d9b0e3a3d622dc9db8f749543927891b7f1d9e0
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.1

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