Inbound documents arrive in whatever shape the sender felt like: scans, photographs, exports, the same form in four layouts. Something has to turn that into structured, checkable data without a person reading every page.
Stages, not a pipeline
The design decision that matters is that each stage is isolated and retries on its own:
ingest → OCR → classify → validate → report
OCR pulls the text. An LLM classifies and structures it. Results are checked against reference data — deterministic rules, not another model call. A clean report comes out the other end.
Because the stages are independent, one bad input costs that document a retry rather than stalling the batch behind it. A run of two thousand documents does not fail because one of them was photographed at an angle.
The checks around the model are the product
The interesting engineering is not the model call. Anyone can get an LLM to return JSON. The work is everything that decides whether you can trust it:
validation against reference data, so a confident wrong answer is caught rather than passed on
an audit record per step — which model saw which input, what came back, which check passed or failed, and what the run did next
a defined path for low confidence, instead of silently guessing
That audit trail is what makes the output defensible six weeks later when someone asks why a document was classified the way it was. In a regulated setting it is the difference between a system you can use and one you cannot.
Why isolation beats throughput
A faster pipeline that fails as a unit is worse than a slower one that fails per document. Batch failures are expensive to diagnose and expensive to re-run — and the failure always surfaces at the worst moment, which is when the volume is highest.
Built under NDA, so this describes the architecture rather than showing the code.
Like this project
Posted Oct 6, 2026
Inbound files move through isolated, independently retryable stages — OCR, LLM classification, validation against reference data, report. One bad input never stalls the batch, and every step leaves an audit record.