Document AI Starts Before Extraction: Route First
In Document AI, the high-leverage decision often happens before extraction. A production system does not just extract fields — it classifies the document, routes it, then extracts.
TL;DR: In Document AI, classification determines the extraction strategy. Routing is not just preprocessing — it is the decision layer that tells the system what kind of problem it is solving. Route first, extract second, validate always: a document with low confidence belongs in a review queue, because unknown is a valid system outcome, not a pipeline failure.
Visual Summary
The Problem
The high-leverage decision in Document AI often happens before extraction. Most demos look like this: upload a PDF, extract fields. A production system often needs a different pattern.
Document → classify → route → extract → validate.
An invoice, a contract, an identity document, and a free-form letter are different problems. They may need different extraction schemas, prompts or instructions, OCR and layout handling, model tiers, validation rules, and human-review policies.
The Approach
So I do not start with one general extraction workflow. I start with a routing layer in front of extraction to decide which kind of problem the system is solving.
Which pipeline
Which specialized extraction workflow should process this document?
Which schema
Which fields are expected, and which schema should be enforced for this document family?
Which model tier
Is a low-cost path sufficient, or does the document need table extraction or long-context reasoning?
Whether to review
Is uncertainty high enough that the document should go to a human review queue?
This improves more than extraction quality. It also improves cost control, latency, maintainability, monitoring by document family, and safe handling of unknown document types.
Outcome
A standard invoice may follow a structured extraction path. A contract may need clause-level extraction and stronger validation.
An unknown document should not be forced into either path just because the system needs an answer. It should be flagged, queued, or sent to review.
Routing is not just preprocessing. It is the decision layer that tells the system what kind of problem it is solving. Route first. Extract second. Validate always.
Key Takeaway
Design insight: In Document AI, classification determines the extraction strategy. Routing is not just preprocessing — it is the decision layer that tells the system what kind of problem it is solving. Route first, extract second, validate always: a document with low confidence belongs in a review queue, because unknown is a valid system outcome, not a pipeline failure.
Related
The Hardest Forecasting Decision Is Which Model to Use →Route Structurally Inactive Series Before Forecasting →Hard Constraints Belong in the Architecture, Not Preferences →Structured Outputs for Reliable LLM Pipelines →NLP Classification in 2018 vs LLMs Today →A Valid LLM Response Is Not Necessarily a Safe Decision →
FAQ
What is the key takeaway from "Document AI Starts Before Extraction: Route First"?
In Document AI, classification determines the extraction strategy. Routing is not just preprocessing — it is the decision layer that tells the system what kind of problem it is solving. Route first, extract second, validate always: a document with low confidence belongs in a review queue, because unknown is a valid system outcome, not a pipeline failure.
Who wrote this and what is it about?
This was written by Mahmoud Trigui, Senior Data Scientist. In Document AI, the high-leverage decision happens before extraction: classify and route the document to the right schema, pipeline, and model tier first.