Workflow Automation · BraivIQ AI Engineering Playbook
Intelligent Document Processing Pipelines In Code: Ingest, Classify, Extract, Validate, And Route Only The Doubt To Humans
The highest-volume automation opportunity in most enterprises is not exotic - it is documents: invoices, purchase orders, KYC packs, contracts, claims, bank statements, arriving by email, upload and scan in every format imaginable, and still processed largely by people re-keying fields into systems. For years intelligent document processing promised to fix this and delivered brittle templates that broke on every new layout. In 2026 the stack finally makes end-to-end document automation reliable, because the pieces matured together: layout-aware extraction, constrained structured outputs that guarantee a schema, small models cheap enough for volume, and workflow engines with real human-in-the-loop checkpoints. This playbook is a code-side guide to architecting an intelligent document processing pipeline that holds up in production: ingest and normalisation, classification that routes each document to the right schema, LLM extraction against a per-document-type schema, deterministic validation that catches what models cannot, confidence scoring that sends only the doubtful fields to a human rather than whole documents, idempotent posting to downstream systems, and the per-field auditability and feedback loop that make the pipeline both trustworthy and self-improving.
· 13 min read · By BraivIQ Engineering
Highest volume - Documents - invoices, POs, KYC, contracts, claims, statements - remain the largest untapped automation surface in most enterprises · Schema per type - Each document type gets its own JSON Schema; extraction is constrained to it so output is valid by construction · Fields, not documents - Confidence scoring routes only the doubtful fields to human review - not the whole document · Self-improving - Every human correction is captured as labelled data that measures and improves extraction over time
Ask where the most hours are lost in a typical enterprise and the answer is rarely something exotic. It is documents. Invoices and purchase orders from thousands of suppliers in thousands of layouts; know-your-customer packs of passports, utility bills and company filings; contracts whose key terms someone has to find and record; insurance claims with their attachments; bank statements to reconcile - arriving by email, upload, scan and portal, in PDF, image and office formats, and still processed, to a remarkable degree, by people reading them and re-keying fields into systems. Intelligent document processing has promised to fix this for a decade and mostly delivered brittle template-based extractors that broke the moment a supplier redesigned its invoice. In 2026 the promise is finally deliverable, and the reason is that the necessary pieces matured at the same time: layout-aware document understanding that reads a page as structure rather than a string, constrained structured outputs that guarantee an extraction matches a schema, small models cheap enough to run on every page at volume, and workflow engines with real human-in-the-loop checkpoints and durable execution. As an AI Agency Developer London that builds automation platforms, we find document pipelines are where the largest, most measurable returns live - and this playbook is a code-side guide to architecting one that holds up in production.
Stages One To Three: Ingest, Classify, Extract
The pipeline begins with ingestion and normalisation, which is unglamorous and decisive: every channel - mailbox, upload API, scanner, portal - feeds a single intake that assigns each document a durable identifier, stores the original immutably, and normalises it to a common representation (pages as images plus native text where the format has it), with idempotency on the source so that the same email attachment arriving twice produces one document, not two. Classification follows: before you can extract, you must know what you are looking at - an invoice, a purchase order, a passport, a contract - because each type has its own schema and its own extraction strategy, and a small classifier (a compact model, or a lightweight LLM call with a constrained enum output) routes each document to the right one, with an 'unknown' class that sends genuinely novel documents to a human rather than forcing them into the nearest schema. Extraction is where the model does its real work, and the discipline is to make it a structured, schema-bound operation rather than a free-form request: each document type has a JSON Schema describing its fields, their types, allowed values and which are required; the model is given the document's layout-aware content and asked to fill the schema; and constrained structured outputs guarantee the result is schema-valid, so downstream code receives a typed object and never a parse error. Field descriptions in the schema act as extraction instructions - a well-described 'invoice_total_including_tax' field is extracted far more accurately than a bare 'total' - and per-field confidence is captured alongside each value, either from the model's own assessment or from agreement between two passes, because confidence is what drives the next stage.
- Ingest and normalise - one intake for every channel, durable document identifiers, immutable originals, a common page representation, idempotent on source.
- Classify first - route each document to its type's schema with a constrained classifier, and send unknowns to a human rather than forcing a fit.
- Extract against a schema - a JSON Schema per document type, filled with constrained structured outputs so results are valid by construction.
- Describe fields as instructions - schema field names and descriptions steer extraction accuracy; treat the schema as part of the prompt.
- Capture per-field confidence - from the model or from agreement between passes; it is the signal that decides what humans see.
Stages Four To Six: Validate, Route, Post
Extraction gives you a schema-valid object; validation decides whether its values are right, and this stage is deterministic code, not a model, because it checks things models are bad at and code is perfect at. Arithmetic: do the invoice line items sum to the subtotal, does subtotal plus tax equal total, within a tolerance. Cross-field rules: is the due date after the invoice date, does the currency match the supplier's known currency. Reference lookups: does the supplier exist in the vendor master, does the purchase order number match an open order, does the bank account match the one on file - the check that stops payment fraud. Format constraints: valid VAT numbers, IBANs, dates. Each check produces a pass, a fail or a warning on specific fields, and it is these results, combined with the extraction confidences, that feed routing. The routing stage applies policy: fields with high confidence that passed validation are accepted; fields with low confidence or failed checks are queued for human review with the document page and the model's proposed value shown side by side; documents whose critical fields all pass flow straight through to posting. The human-review queue is itself a workflow - built on durable execution so a document can wait days for a reviewer without holding resources, with the reviewer's decision resuming the pipeline - and every correction is written back as labelled data. Finally, posting delivers the validated, reviewed record to the downstream system - the ledger, the ERP, the case-management tool - and it must be idempotent: keyed on the document identifier so that a retry after a failure cannot create a duplicate invoice, with the posting result recorded against the document for a complete audit trail from original file to booked record.
The Bottom Line
Documents remain the largest untapped automation surface in most enterprises, and 2026 is the year intelligent document processing became genuinely reliable, because layout-aware understanding, constrained structured outputs, cheap small models and workflow engines with durable human-in-the-loop checkpoints matured together. The architecture that holds up in production is a staged pipeline: a single idempotent intake that normalises every channel and format; classification that routes each document to its type's schema and sends unknowns to a human; extraction as a schema-bound, constrained operation that yields typed, valid objects with per-field confidence; deterministic validation - arithmetic, cross-field rules, reference lookups, format checks - that catches what models cannot; policy-driven routing that sends only the doubtful fields, not whole documents, to a durable review queue; and idempotent posting with a complete audit trail from original file to booked record. The principle that unlocks the value is routing the doubt rather than the document, and the practices that make the pipeline compound are per-field evaluation in continuous integration, right-sizing the model per stage, and capturing every human correction as labelled data that drives the review share down over time. Built this way, document automation stops being a brittle template and becomes a self-improving platform - which is exactly the workflow-automation architecture we build.
References & Further Reading
- AppScale - structured output engineering: reliable JSON from LLMs (2026) (schema-bound extraction): https://appscale.blog/en/blog/structured-output-engineering-reliable-json-from-llms-2026
- InfoWorld - small language models: rethinking enterprise AI architecture (right-sizing for high-volume tasks): https://www.infoworld.com/article/4160404/small-language-models-rethinking-enterprise-ai-architecture.html
- LangGraph - durable execution and human-in-the-loop interrupts (the review-queue workflow layer): https://langchain-ai.github.io/langgraph/concepts/durable_execution/
- arXiv - TruncProof: a guardrail for LLM-based JSON generation under token-length constraints (long-document extraction): https://arxiv.org/pdf/2605.13076
- OWASP - Top 10 for LLM applications (treating document content as untrusted input): https://owasp.org/www-project-top-10-for-large-language-model-applications/