Eval sets from your own documents¶
Most teams that process documents already hold an answer key and do not use it: the values their staff typed or
approved, sitting in a database next to the files. readanydoc evals turns those documents and records into an
eval set, keeps it growing from live use, and scores any parser on it. Every score comes from code comparing an
output with the true values; no model judges anything. Everything stays on your machine: nothing is uploaded, and
ReadAnyDoc hosts nothing.
pip install "readanydoc[engine]"
export ANTHROPIC_API_KEY=...
readanydoc evals init my-invoices --docs ./invoices --truth export.csv
readanydoc evals run my-invoices
readanydoc evals view my-invoices
1. Build the set: init¶
--docs is a folder of documents. --truth is the export of their true values:
| Truth | Shape |
|---|---|
| CSV | one row per document; a file column names it (filename, document, doc, path, name, id also work, or pass --id-column) |
| JSON | {"invoice-1.pdf": {...}, ...} or a list of rows |
| JSONL | one row per line |
| a folder | <file stem>.json per document |
A document is matched by its name, with or without the extension. Nested JSON (line items, addresses) is kept as it is; a CSV gives flat fields.
my-invoices: 6 examples in readanydoc-evals/my-invoices
inv_no -> inv_no
amount_due -> amount_due
approved_by -> approved_by
The set is a folder of plain files you can read, edit and keep in git:
readanydoc-evals/my-invoices/
evals.yaml name, schema, instructions, field mapping, capture settings
schema.json the JSON Schema every document is extracted into
examples.jsonl one example per line: id, file, expected values
runs/ the results and report of each run
The field mapping. evals.yaml maps each truth column to a schema field. With your own schema (--schema
invoice.schema.json), the mapping is drafted by name (inv_total to total) by code, and columns with no match are
listed. Without one, a schema is written from the columns. Correct the mapping by hand and run init again; set a
column to null to leave it out, which you should do for columns that are not printed on the document:
fields:
inv_no: number
amount_due: total
approved_by: null # not on the invoice: do not ask a parser for it
Running init again keeps your mapping and every example added by hand or by feedback.
2. Run and read the result¶
readanydoc evals run my-invoices # ReadAnyDoc
readanydoc evals run my-invoices --system readanydoc,reducto # side by side (REDUCTO_API_KEY)
readanydoc evals run my-invoices --outputs ./other_parser_out # results you already have: no model call
readanydoc values found 100.0% right 100.0% documents all right 100% failed 0 cost/doc $0.0013
outputs-other_parser_out values found 91.7% right 95.7% documents all right 67% failed 0
outputs-other_parser_out: INV-2044: amount_due expected '12400.0', got 1240.0
- values found: of the true values, how many are in the output.
- right: of the output's values for those fields, how many are true.
- A run that will call a model shows its rough cost and asks first (
--yesto skip,--budget 2to cap). readanydoc evals view my-invoicesopens the report: every document, every wrong value, the page with citation boxes.
Any parser. --outputs takes a folder with one <example id>.json per document: the extracted object itself,
or wrapped as {"data": ...}, or Reducto's response (
{"result": ...}, with or without citations). So an in-house
parser or another vendor is scored without going through ReadAnyDoc. Systems that run live are listed by
readanydoc bench list; add your own with readanydoc.bench.systems.register.
How values are compared. As documents print them, not as strings: numbers within 0.5% whatever the format
(£1,575.00, 1.575,00, (200)), dates as the same day whatever the format (2026-03-01, 01 Mar 2026,
1-Mar-26), text without case, spacing and punctuation, list rows paired before comparing so order does not matter.
The rules are in readanydoc/bench/grade.py.
3. Keep it growing¶
By hand¶
The true values may cover only the fields you know: only those are scored.
From live use: capture now, confirm later¶
One argument keeps each document and its output as a candidate:
or, with no code change, an environment variable: READANYDOC_EVAL_SET=my-invoices.
Where your application learns the truth (a person approves the values, or corrects one), report it with the extraction's id:
from readanydoc import evals
evals.add_feedback(result.id, correct=True) # a person checked the whole output
evals.add_feedback(result.id, expected={"total": 1575.0}) # the fields that were checked or corrected
evals.add_feedback(result.id, correct=False) # discard
A candidate is never scored until feedback arrives: a parser's own output is not an answer key, and an eval set
that agreed with itself would hide every mistake. correct=True means a person confirmed the output; expected
alone makes only the given fields true values. Corrections are recorded on the example (metadata.corrected).
readanydoc evals pending lists candidates waiting; readanydoc evals feedback <id> --expected '{...}' does the
same from a shell.
Capture is off unless you ask for it. In evals.yaml, capture.sample keeps a share of extractions (0.05 = one
in twenty; READANYDOC_EVAL_SAMPLE overrides it) and capture.max_pending (default 500) stops the pile growing.
Captured documents are copied into the eval set's folder, on your disk. Capture works for readanydoc.extract in
Python; the HTTP server does not capture yet.
4. In CI and in tests¶
from readanydoc import evals
def test_invoices_stay_accurate():
evals.assert_eval("my-invoices", min_score=0.95) # fails with the wrong values listed
Add --replay DIR (or READANYDOC_REPLAY_DIR) to record every model call and answer repeats from disk: after the
first run, a re-run on unchanged code and documents costs nothing, and a change costs only the calls it changed.
Scorers on their own¶
The scorers take (output, expected, input=None) and return a score from 0 to 1 with details, the calling
convention of the common eval tools, so they work inside the eval platform you already use:
from readanydoc.evals import FieldMatch, TableMatch, ValueMatch
FieldMatch()({"total": "£1,575.00", "issued": "01 Mar 2026"}, {"total": 1575.0, "issued": "2026-03-01"}).score # 1.0
TableMatch()(rows_out, rows_true).metadata["wrong"] # [{"field": "[1].amount", "expected": 3, "got": "2"}]
ValueMatch()("28-Mar-2026", "2026-03-28").score # 1.0
Score.as_dict() gives {"name", "key", "score", "metadata"}.
Public eval sets¶
The same commands run the public sets, downloaded on first use and pinned to a fixed revision so a score can be reproduced. ReadAnyDoc redistributes none of them; check a set's licence before you use it.
readanydoc evals list # your sets and the public ones
readanydoc evals pull receipts # download into the cache
readanydoc evals run receipts --limit 10
Every set, who made it and its licence: Public eval sets. The same documents are on Hugging Face
as ReadAnyDoc Evals, in one format, for use without
ReadAnyDoc.
Python reference¶
| Call | Does |
|---|---|
evals.init(name, docs, truth, schema=None, fields=None) |
build or rebuild a set from documents and true values |
evals.create_dataset(name, schema) / evals.get_dataset(name) |
an empty set / an existing one |
dataset.add_example(file, expected, metadata=None) |
add one document and its true values |
evals.run(name, system=None, outputs=None, limit=None, budget_usd=None) |
run and score; returns score, systems, report, out |
evals.failures(out) |
every wrong value of a run |
evals.assert_eval(name, min_score, ...) |
run, failing under min_score |
evals.add_feedback(run_id, expected=None, correct=None) |
turn a captured extraction into an example |
dataset.pending() / dataset.examples() |
candidates waiting / scored examples |
Sets live in ./readanydoc-evals unless READANYDOC_EVALS_DIR names another folder.