ke
A framework for building Knowledge Evaluation systems — evaluating the outputs of information-extraction systems. OCR is treated as the noisiest special case of a general problem, so the core is source-agnostic and the OCR pieces are optional.
import ke
ke.score("hello wrld", "hello world") # -> Score(value=0.0909..., metric='cer')
ke.score("hello wrld", "hello world", metric="wer").value # 0.5
ke.evaluate(
[("ct", "cat"), ("dg", "dog")], metric="cer"
).aggregate # 0.333... (global CER)
What it does
Evaluating an extraction splits along two axes — is there a gold answer
(reference-based) or not (reference-free), and are we scoring one item or a whole
corpus. ke gives you both halves through two facades over one shared typed schema:
score()/evaluate()— reference-based: compare against gold, one item or a corpus, the metric chosen by output type (string → CER/WER, record → field-F1), aggregated correctly (global error-rate accumulation, micro-F1; never a naive mean) with optional per-slice cuts.estimate_quality()— reference-free: gather signals → calibrate → validate → decide accept/flag/block, with no gold answer.
Everything swappable is a strategy injected with a smart default, so the simple call works out of the box and every layer stays replaceable.
Evaluate an OCR engine
The first concrete instance: measure OCR accuracy over a gold corpus. ke consumes
ocracy's normalized OcrResult, so it can
benchmark any of its ~16 engines — or any image -> OcrResult callable of your own.
import ke.ocr
gold = {
"inv-1": {
"image": "scan.png",
"reference_text": "INVOICE 2024",
"slice": "invoices",
}
}
report = ke.ocr.evaluate_ocr(
"ocrmac",
gold,
metric="cer",
normalize=["lower", "collapse_whitespace"],
persist=True,
)
report.aggregate # corpus CER
report.per_slice # CER per document slice
report.detail["per_item"] # prediction, reference, score, confidence per document
Gold corpora, results, and runs persist to local dol stores under
~/.local/share/ke/.
Install
pip install ke # lean, permissive core (dol, config2py, jiwer, rapidfuzz)
pip install "ke[ocr]" # + the ocracy OCR fleet (install engines via ocracy extras)
pip install "ke[all]" # + the permissive capability tiers (metrics, calibration, ...)
Heavier or copyleft/non-commercial libraries are never installed by default; see the
extras in pyproject.toml. Some capabilities (e.g. the cost-weighted typed-graph
metric and the ROVER consensus engine) are on the roadmap — see the tracking issue.
CLI
ke cer "hello wrld" "hello world" # character error rate
ke wer "hello wrld" "hello world" # word error rate
ke where # the local data folder
ke check tesseract # what an OCR engine needs to run
For contributors
The architecture, conventions, and the research behind the design are documented for
agents and humans in AGENTS.md, the dev skills under skills/, and
the research reports under misc/docs/.
Metadata
Release files for ke 0.1.1
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 |
|---|---|---|---|---|
| ke-0.1.1.tar.gz | 232.8 kB | Without provenance | Details for ke-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ke-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for ke-0.1.1-py3-none-any.whl |
Total release size: 273.4 kB
Release files / ke-0.1.1.tar.gz
| Download URL | ke-0.1.1.tar.gz |
|---|---|
| Size | 232.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1102caddfa2f908603befc9b3e8a94d8155b0ad57abd131f27b35624b2b44565
|
|
BLAKE2b-256 checksum How to use checksums |
dec84361d8c8c97dbb030a1ec82e807d744405242c5d302d138a5eabefa4f837
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ke-0.1.1-py3-none-any.whl
| Download URL | ke-0.1.1-py3-none-any.whl |
|---|---|
| Size | 40.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89eb767083ee6ce2f17bb5609b0386b8622ffb890e26b84366fb3eb1fb13dc13
|
|
BLAKE2b-256 checksum How to use checksums |
ca9c014b3dd817e16eb4f860306013979527f2594d902ccfe79b1e246dd5fcab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for ke 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.