Turning scanned paperwork into a system of record.
10,000+ documents processed, a 96.8% automated match rate — and why the deterministic layer around the AI, not the AI itself, is the product.
The problem
Waste-management customers — manufacturing sites, mostly — receive disposal invoices as a single scanned PDF: the invoice on top, and behind it a stack of supporting paperwork. Weighing slips, delivery notes, transfer notes, sometimes dozens of pages per bundle. Someone in the back office has to answer the same questions for every invoice: does the billed tonnage match what the weighing slips say? Does every disposal event have weight evidence at all? Is this hazardous-waste code the one we actually contracted for?
Done by hand, that is slow, error-prone, and unauditable. Done naively by AI, it is worse: a plausible-looking wrong answer in a financial workflow is more dangerous than no answer.
The constraints
- GDPR and EU data handling. Customer data is isolated per tenant at the database-schema level, so offboarding a customer is a structural operation — a schema drop plus a storage-prefix delete — rather than row-by-row surgery. Inference stays EU-resident.
- A false-positive-intolerant workflow. The output feeds cost accounting, CO₂ reporting, and regulatory documentation. A missed link is a nuisance a human can resolve; a wrong link is a corrupted audit trail. Every design decision below follows from preferring "we couldn't verify this" over "we guessed".
The architecture
Confirmed documents become jobs that feed cost, CO₂, and sustainability analytics.
A stateless parsing service takes the raw PDF, triages each page as machine-readable text or scanned image, splits the bundle into its individual documents, and extracts every field — invoice lines, weights, waste codes, parties — into a versioned JSON schema. Structure is enforced twice, by typed models and by a JSON Schema gate, per document rather than per bundle, so one malformed field can never sink a whole upload. A page-coverage check guarantees completeness: if any page went missing from the output, only those pages are re-extracted, and the document is flagged for review instead of being silently truncated.
Downstream, a multi-tenant backend stores the AI output immutably and layers deterministic enrichment and user corrections on top — the original extraction is never edited, which keeps the audit trail free. A reconciliation engine then cross-checks each invoice against its own attachments: billed tonnage against weighing-slip evidence, prices against line arithmetic, waste codes against the customer's ~130-code catalog, with weights normalized through an 18-unit conversion model. Reconciliation is recomputed on every view, so it is always consistent with live edits. A review workspace shows each document beside its extracted data with field-level red/green indicators and one-click fixes; confirmation is blocked server-side until discrepancies are resolved.
The trust layer
Extracting fields from documents is a commodity — every model vendor demos it. What makes the output bookable is a set of deliberately conservative, deterministic decisions wrapped around the AI:
- Exact matching, zero false links. Attachments are linked to invoice line events by exact reference-number equality, never fuzzy matching. The cost is that trivial format variants go unlinked and a human resolves them; the benefit is that an auditor can trust every link that exists.
- "Unmatched" is not "mismatch". "We couldn't verify this" and "the numbers disagree" are structurally different states, kept apart end to end, so uncertainty never masquerades as a discrepancy — or vice versa.
- Estimated is visibly not measured. Where no weighing evidence exists but a container-based estimate is possible, the value is a first-class "calculated" state, rendered as an estimate with its calculation breakdown — never silently blended into measured data.
- Flag, never auto-correct. A suspected digit transposition between tare and net weight is flagged for human review. Net weight flows into a financial field, so no heuristic is ever allowed to rewrite it.
- The gate lives on the server. The client pre-checks confirmation requirements for fast feedback, but the server enforces them independently — a stale page or a direct API call still cannot confirm incomplete evidence.
Try it — you're the reviewer
Mock invoice line vs. its evidence. The 10 kg tolerance and the hazard-marker rule are the production ones. The AI checks — but it can't confirm. You can.
Job 2026‑004412 created — 4.92 t booked, CO₂ computed, analytics updated in under 10 ms.
You just did what reviewers do 4,500+ times a month at peak — seconds per document, and nothing confirmed on a guess.
The prompts themselves went through the same discipline: dozens of tracked revisions converged on a layered design where the prompt handles semantics — label-anchored field rules for dense German documents, explicit null-over-guess instructions, an arithmetic self-check that forces line totals to reconcile against the invoice net — while code handles everything prompting can't be trusted with.
Results
- 10,000+ documents processed, peaking at 4,500+ in a single month, across 3 paying B2B customers.
- 96.8% automated attachment match rate on the tenant with the cleanest upstream data — and the strict-matching design means the messier tenants' unlinked documents surface to humans instead of becoming silent errors.
- Confirmed documents feed a per-tenant analytics fact table powering 16 self-serve waste, cost, and CO₂ reports with cell-level drill-through to source jobs; pivot queries return in under 10 ms.
- The same extraction service now also powers AI-assisted partner-invoice booking in the company's order-management system — one AI service, two consumer products.
The same discipline, applied to chat
The newest layer applies the trust rules to conversation: an auditor-facing chatbot grounded in a versioned export of the tenant's confirmed data — currently in staging. Its system prompt is nine strict rules, not vibes: answer only from the export, run all arithmetic as executed code rather than in the model's head, cite the rows behind every figure, admit data-quality gaps, refuse questions outside the data — and treat data as data. Instruction-like text inside a document can never impersonate a command: reserved structural markers are stripped from every data value before the model sees them.
Ask the auditor
Scripted demo — the rules are the real ones, the numbers are mock. Pick a question.
What I'd do next
- Persist reconciliation outcomes. Recomputing on every view keeps results consistent with live edits, but it means no history. A compact summary snapshot at confirmation time would make match-rate trends measurable over time.
- Canonicalize reference numbers with the same rigor waste codes already get, keeping exact matching while eliminating trivial case and format variants — the single biggest lever on the match rate for messier customers.
- A ground-truth evaluation harness. The pipeline has strong structural guarantees but no labeled accuracy benchmark; a few hundred hand-verified documents would turn "it feels accurate" into a number that can gate model and prompt changes.
- Prompt–schema drift checks in CI, asserting that every field the prompt mentions exists in the schema, so the two contracts can never quietly diverge.