The problem
A large regulated enterprise held a large back-book of facility agreements, security documents and legal side letters, many running past a hundred pages, most existing only as scanned paper. The terms that matter, obligations, obligations, margins, review clauses, lived inside that paper and nowhere else. Answering a simple portfolio question meant a person opening documents one at a time, and answering it across the whole book was effectively impossible.
I designed the architecture for a portfolio extraction pipeline: key terms, obligations and obligations pulled from every document, verified against a per-type checklist, with every extracted field citing the page it came from and anything uncertain routed to a human exception queue. The programme took it through build and assurance.
Why it was hard
Legal documents are engineered against naive extraction. The operative clause is amended by a side letter, the defined term shifts meaning between schedules, and the number you want appears three times with only one occurrence binding. A model that reads a facility agreement the way it reads a news article will extract something plausible from the wrong clause, and plausible-but-wrong is worse than missing, because it enters a system of record wearing the costume of a fact.
Scale changed the failure economics too. At back-book volume, even a small error rate is thousands of wrong fields, so per-field confidence had to be a first-class output, not an afterthought. And the consumers were credit and legal teams who would trust nothing they could not check in seconds, which made citation to the source page a functional requirement rather than a nicety.
Key decisions
Extraction is anchored to structure before models run. Documents are segmented into a clause-and-schedule span index, so every downstream question is asked of a bounded span, not of a hundred pages.
Every extracted field is bound to its evidence: document identifier, page, span. A field that cannot cite its page is not written to the portfolio store; it goes to the exception queue instead.
Verification is a checklist, not a vibe. Each document type carries an explicit checklist of required fields, cross-field rules and plausibility ranges, and a document is complete only when its checklist passes.
Confidence thresholds route work rather than decorate it. High-confidence fields flow through; everything else queues for a person, and the person's correction is captured as labelled data.
The pipeline runs on managed services throughout, object storage, managed text and layout extraction, workflow orchestration and managed model endpoints on the institution's AWS estate, so scaling the back-book was a capacity decision rather than an engineering project.
Architecture
Documents land in object storage and pass through managed text extraction with layout and table awareness. The span index is built, extraction agents work clause by clause against typed field schemas, and the checklist verifier judges each document. The citation binder attaches page-level evidence to every field before anything is written. Passing fields land in the queryable portfolio store; failures and low-confidence fields route to the exception queue, and resolved corrections flow back in.
The span index carried more weight than any model choice. Asking a model to find the margin ratchet inside a bounded clause is a tractable question with a checkable answer; asking it to find the same thing in a hundred pages is an invitation to confident error.
Trade-offs
Building the span index and per-type checklists front-loads effort that a straight-to-model design skips, and it pays back the moment the document mix broadens, because new document types arrive as new checklists rather than new pipelines. Routing on confidence means the exception queue is real work for real people; the design treats that as the point, since every resolved exception is both a corrected record and a training example. Page-level citation costs storage and plumbing and buys the only currency that matters with legal reviewer: a claim they can check in seconds.
Outcome
The pipeline was taken through build and assurance by the programme at a large regulated enterprise, and the extracted portfolio store became the substrate for obligations monitoring and portfolio-wide term queries that were previously manual archaeology. The pattern, span index, checklist verification, citation binding, exception queue, shipped as a certified pattern with its evaluation pack and control mapping, and teams I worked with have reused it on other document-heavy back-books.
What I learned
Bounding the question is worth more than upgrading the model; most extraction failures I saw were retrieval failures wearing extraction clothes. Checklists turn quality from an opinion into a state a document is in. And the exception queue is where the system earns trust: reviewers forgave the pipeline for saying "not sure" far more readily than they would ever have forgiven a confident mistake.