Document AI · verified extraction

invoice-to-structured

Invoices, purchase orders, and bank statements become structured records only after deterministic math and reconciliation checks.

Public · synthetic demo
The problem

Extraction is easy; trusting the extracted numbers is not.

A model can copy a printed total into JSON even when the document arithmetic is wrong. Posting that output without a gate turns a parsing success into a payment or reconciliation error.

Input

A fictional purchase order excerpt — the flagged line item

{
  "po_number": "PO-3002",
  "vendor": "Fictional Office Supply Co.",
  "line_items": [
    {"sku":"DESK-02", "qty":2, "unit_price":480, "line_total":900}
  ],
  "subtotal": 1860, "tax": 148.8, "shipping": 75,
  "grand_total": 2083.8
}
The money shot

The trust layer catches what the extractor copied

PO-3002 · line math

900 != 2 × 480 = 960

→ needs_review

The changed line also makes the printed subtotal disagree with the extracted line-item sum.
BANK-4002 · closing balance

opening + credits − debits = 2975
printed closing = 2875

→ needs_review

The running transaction balances remain visible, so a reviewer can locate the discrepancy.
Cross-document HITL routing
RecordDecisionWhy
INV-DEMOauto_acceptAll deterministic gates passed
PO-3002needs_reviewline_math + subtotal_mismatch
Bank sampleneeds_reviewduplicate/date/running-balance rules fired

Bundled HITL batch: 33.3% auto-accept, 66.7% review, 0% reject across three synthetic records.

How it's verified

Rules—not an LLM—make the decision.

Line totals, subtotals, grand totals, date ordering, running balances, duplicates, and required fields are checked in deterministic Python. Extraction confidence is calibrated with the validation signal; every flag carries a reason and timestamped audit entry.

Honest limitations
  • Offline PO and bank-statement extraction accepts normalized JSON; arbitrary scans need the optional LLM/OCR front end and human QC.
  • Currency validation checks one uppercase ISO-style code and does not convert exchange rates.
  • Duplicate detection is exact: date + amount + description. Fuzzy duplicates need domain-specific rules.
  • Synthetic samples demonstrate the method, not production accuracy on a customer's document distribution.