Back to Blog
Published:
Last Updated:
Enterprise Document AIFoundational guide

The 8-Stage Document Intelligence Pipeline

11 min read
2,200 words
high priority
Mudassir Marwat

Mudassir Marwat

Founder & CEO, Cognilium AI

The 8-Stage Document Intelligence Pipeline — Cognilium AI

TL;DR

Parse, classify, evidence-map, extract, validate, score, graph, link. The eight-stage pipeline for legal/financial document AI.

Document intelligence on long unstructured PDFs is not "give the LLM a PDF and ask for JSON." That works for two-page invoices. It does not work for 50-page private placement memoranda, 100-page subscription agreements, or the cap-table spreadsheet with five tabs of footnotes. The pipeline that handles these is staged — eight discrete stages with their own contracts and failure modes.

Stage 1: parse

PDF in, structured-text out. Layout-aware parsing — preserve page numbers, paragraph breaks, table structure. Modern PDF parsers (LayoutParser, Adobe Extract API, Gemini's native PDF intake) handle this. Output: a {page, paragraph, span} addressable representation of the document.

Stage 2: classify

What kind of document is this? PPM, SAFE, SPA, cap table, NDA, side letter? Classification picks the schema that subsequent stages will extract against. A classifier on the first 2-3 pages is usually enough. Misclassifying here cascades — the extractor will run a SAFE schema on a SPA and miss everything that matters.

Stage 3: evidence-map

For each field the schema expects, find the page-and-span pointers where the value lives. This is a retrieval step, not an extraction step. The output is a map: {field_name → [{page, span}, ...]}. The extractor in stage 4 sees only those pointers — it cannot extract from unspecified parts of the document. Hallucination is bounded by where evidence has been mapped.

Stage 4: extract

Run the LLM on each field with its evidence pointers as context. Structured output (JSON schema, Pydantic, or equivalent). Each field has a confidence score from the model. Output: typed structured data with per-field provenance back to {page, span}.

Stage 5: validate

Cross-field consistency rules. Total preferred shares should match the sum of issued + reserved. Post-money valuation should equal pre-money + raise amount. Date fields should be temporally consistent. Validation failures flag the field for human review without rejecting the whole document.

Stage 6: score

Per-field and per-document confidence aggregation. A document where 28 of 30 fields extracted with high confidence and 2 flagged for review gets a single document-level score. Scores below threshold queue for human verification before the document is considered "extracted."

Stage 7: graph

The validated structured data lands in the knowledge graph (Neo4j in our case). Entities (companies, people, instruments, transactions) become nodes; relationships (issuer-of, party-to, beneficiary-of) become edges. Each node carries a back-reference to its source document and provenance.

Stage 8: cross-document link

When a new document's entities are added to the graph, the linker checks: is "Acme Corp" in this PPM the same as "Acme Corporation" in last quarter's cap table? Probably yes. The linker uses Gemini-driven entity disambiguation: name variation + corporate jurisdiction + EIN match → link. Confident matches get auto-merged; uncertain ones queue for human disambiguation.

Mislink detection

After auto-merge, a final pass re-checks linkage by comparing all the entity's attributes across the two source documents. If "Acme" in PPM A has post-money valuation $50M and "Acme" in cap table B has post-money $52M, the link is flagged as suspect. Human reviews; either confirms a typo on one side or splits the merge. This pass catches the long tail of bad auto-merges that no single-pass linker catches.

Numbers from production

  • 7 document types currently supported (PPM, SAFE, SPA, cap table, side letter, NDA, subscription agreement)
  • Per-document P50 latency: 90-180 seconds (mostly stages 1, 4, 8)
  • Per-document cost: $0.40-1.20 (Gemini 2.5 Pro for stages 4 + 8, smaller model for 2 + 5)
  • Mislink-detection catch rate: ~15% of auto-merges flagged, ~3% turn out to be actual mislinks
  • Human review queue: ~5-8% of documents, processed within 24 hours

What this is not

Real-time document Q&A. The pipeline takes minutes per document, not seconds. For real-time use cases (RAG over already-extracted documents), the pipeline runs once at ingestion and the runtime queries hit the graph + vector store. Pipeline at ingestion, retrieval at runtime — never confuse the two.

Share this article

The work behind this series

The staged extraction architecture these articles describe, deployed on your documents.

Mudassir Marwat

Mudassir Marwat

Founder & CEO, Cognilium AI

Mudassir Marwat's argument is that ERP systems record decisions they never optimise.

Founder & CEO of Cognilium AI; 37 AI agents in production across four products; 4 production AI products built and operated; three clouds in production (AWSGCPAzure)
Agentic AIRAG → GraphRAG retrievalVoice AIMulti-Agent Orchestration

Frequently Asked Questions

Find answers to common questions about the topics covered in this article.

A single-prompt extraction works for short structured documents. Long unstructured documents (50-page PPMs, 100-page SAFEs) need staging: classification before extraction so the right schema applies; evidence mapping before extraction so each field has a citation; validation after extraction so wrong values get caught before they hit the graph. Each stage has a narrow job; the failure modes are visible.
For each field the schema expects (e.g., "post-money valuation"), a list of {page, span} pointers in the source PDF where the value can be found. The extractor sees those pointers and only extracts from cited spans — hallucination cannot reach unspecified parts of the document.
After cross-document linking (entity X in PPM A is the same as entity X in cap table B), a final pass re-checks the linkage by comparing all the entity's attributes across the two documents. If the post-money valuation in PPM A does not match the cap-table valuation in B, the link is flagged as suspect.
The pattern is model-agnostic. We use Gemini 2.5 Pro because it handles long-context PDFs natively. Claude 3.5 Sonnet works equally well; GPT-4o needs PDF preprocessing (page-by-page) since its native PDF support is weaker.
Each tenant has its own document store, schema (most tenants use a shared base schema with extensions), and extraction job queue. Cross-tenant data never mixes — strict isolation at the storage and queue layers.

Still have questions?

Get in touch with our team for personalized assistance.

Contact Us

Still have a question this did not answer?

The person who wrote this article answers these. Describe your setup and what you are stuck on — you will get a straight answer, including where we think the approach is wrong.

Related Articles

Continue exploring related topics and insights from our content library.

Anti-Hallucination via Runtime Grounding Against a Domain Vocabulary
6 min
1
Mudassir Marwat
May 5, 2026

Anti-Hallucination via Runtime Grounding Against a Domain Vocabulary

A startup-loaded domain vocabulary the generator must match against, plus framework rules baked into every prompt — a low-cost pattern that catches hallucinated terminology before the user sees it.

words
Read Article
Zero-Trust Multi-Tenant Firestore: Middleware, Claims, and 60+ Wildcard Permissions
9 min
2
Mudassir Marwat
May 5, 2026

Zero-Trust Multi-Tenant Firestore: Middleware, Claims, and 60+ Wildcard Permissions

Hard tenant isolation on Firestore: middleware, immutable claims, wildcard permissions. The architecture that makes leakage structurally impossible.

words
Read Article
Organizational Memory: RAG Across Slack, Confluence, and Loom
9 min
3
Mudassir Marwat
May 5, 2026

Organizational Memory: RAG Across Slack, Confluence, and Loom

A single retrieval surface over Slack, Confluence, Loom, and meeting transcripts — with cross-source ranking and source attribution that survives ingestion.

words
Read Article

Explore More Insights

Discover more expert articles on AI, engineering, and technology trends.

Personalized for You

Curated content recommendations based on your current reading and interests.

Zero-Trust Multi-Tenant Firestore: Middleware, Claims, and 60+ Wildcard Permissions — Cognilium AI
Trending
119%

Zero-Trust Multi-Tenant Firestore: Middleware, Claims, and 60+ Wildcard Permissions

Same topic cluster: Enterprise Document AI
Same author: Mudassir Marwat

Hard tenant isolation on Firestore: middleware, immutable claims, wildcard permissions. The architecture that makes leakage structurally impossible.

Mudassir Marwat
9 min read
Enterprise Document AI
Read Article
Stacked sheets of paper seen edge on
Recommended
33%

How does an AI agent turn an RFQ into a quote?

High priority content
Related topic cluster: Engineering Quote Automation

An agent reads the request, identifies the customer, matches each line and prices it. What it does with the lines it cannot resolve is the real engineering.

Ali Ahmed
8 min read
Engineering Quote Automation
Read Article
Gemini-Driven Entity Disambiguation With Post-Creation Mislink Detection — Cognilium AI
For You
107%

Gemini-Driven Entity Disambiguation With Post-Creation Mislink Detection

Same topic cluster: Enterprise Document AI
Same author: Mudassir Marwat

Auto-merging "Acme Corp" with "Acme Corporation" is the easy half. Catching merges that should not have happened is what a high-precision pass earns.

Mudassir Marwat
7 min read
Enterprise Document AI
Read Article
Voice AI architecture diagram showing Twilio call routing into Whisper STT, an LLM, and ElevenLabs TTS with the per-stage latency budget.
Trending
79%

Enterprise Voice AI: Real Latency, Real Compliance, Real Money

Same author: Mudassir Marwat
Related topic cluster: Enterprise Voice AI

Sub-1.5s p95 voice AI on Twilio + ElevenLabs + Whisper, designed for HIPAA and SOC2. The decisions that mattered, and the ones we got wrong twice.

Mudassir Marwat
11 min read
Enterprise Voice AI
Read Article
Mem0 vs Graphiti vs building your own graph: three agent-memory options shown as cards, with the choice driven by whether the facts your agent remembers change over time.
Trending
74%

Mem0 vs Graphiti vs Building Your Own Graph

Same author: Mudassir Marwat
Preferred author

Graphiti models memory as a temporal graph; Mem0 extracts and stores facts. The difference shows up in what each one can answer months later.

Mudassir Marwat
13 min read
Agent Memory & Context Graphs
Read Article
Why your AI agent keeps forgetting: a memory stack where the top working-memory layer dissolves into particles, showing that a context window is ephemeral, not durable memory.
Trending
72%

Why Your AI Agent Keeps Forgetting

Same author: Mudassir Marwat
Preferred author

Your agent does not have a memory problem. It has a memory architecture problem. The four kinds of agent memory, where each one lives, and why a context window was never going to be enough.

Mudassir Marwat
12 min read
Agent Memory & Context Graphs
Read Article

Smart Recommendations

Our AI analyzes topic clusters, author expertise, and content relationships to surface the most relevant articles for you.

Topic Matching
Author Expertise
Content Quality
Personal Interests

Questions on this?

Talk to an engineer

Schedule a call