Enterprise AI
Production RAG Pipeline for Enterprise PDFs Incorporates Relational Parsing and TOC Retrieval
The system upgrades document parsing, question parsing, retrieval, and generation to deliver typed answers with citations from complex PDF documents using the Attention Is All You Need paper as the running example.
A production RAG pipeline for enterprise PDFs is a system that upgrades the four bricks of document parsing, question parsing, retrieval, and generation to handle complex documents and noisy questions with relational data and typed outputs.
The upgraded pipeline applies the four bricks to the same question on the Attention Is All You Need paper.
The baseline pipeline consists of one hundred lines of Python code that wire the four functions together.
What limitations does the basic RAG pipeline face with enterprise PDFs?
That pipeline returns the right answer on a clean question against a paper with a built-in table of contents.
On a real corpus it breaks the first time the user types a query with two typos.
It also breaks the first time the document is a 200-page contract with no PDF outline.
The basic approach breaks the first time the question asks for every exclusion instead of one.
It breaks the first time downstream code wants a typed object instead of a string.
That pipeline returns the right answer on a clean question against a paper with a built-in table of contents. On a real corpus it breaks the first time the user types “positonal encodig” with two typos, the first time the document is a 200-page contract with no PDF outline, the first time the question asks for every exclusion instead of one, the first time downstream code wants a typed object instead of a string.Angela Shi, Author
How does relational parsing improve document handling?
Document parsing produces line_df one row per visible line with page_num, line_num, text, bounding box.
Document parsing also produces page_df one row per page.
It produces toc_df one row per section with title, level, start_page.
The parsing produces parsing_summary as well.
On the Attention paper the toc_df has three levels and twenty-two entries.
In what way does question parsing address noisy inputs?
Question parsing turns noisy input like “What are the optoins for posiitional encoding?” into a structured ParsedQuestion.
The structured ParsedQuestion includes corrected keywords.
It includes intent.
It includes RetrievalQuery.
It includes GenerationBrief.
How does TOC-aware retrieval enhance accuracy?
Retrieval filters using keyword hits per TOC section.
It then uses an LLM TOC router to pick sections by semantic relevance.
The process merges with keyword pages.
It sizes context by question granularity.
What does the generation step produce in the upgraded pipeline?
Generation returns a typed answer with one citable span per item.
It also returns four context-quality indicators.
What are the market and stakeholder implications for enterprise AI?
The output is what an enterprise user needs a typed answer with verbatim quotes tied to line ranges and a full audit trail from question to citation.
This approach supports production use on real corpora.
How have experts reacted to the pipeline approach?
Angela Shi described the limitations of the basic pipeline in detail.
What comes next for this enterprise document intelligence series?
The companion GitHub repo at doc-intel/notebooks-vol1 provides runnable notebooks for the series.
The repo has 32 stars.
The series builds an enterprise RAG system from four bricks.
A follow up article points the one pipeline at four very different PDFs.
The Attention Is All You Need arXiv paper used as the running example is 15 pages long.
A hundred lines of Python wire the four functions together in the baseline pipeline.
The public companion-code repo at doc-intel/notebooks-vol1 provides runnable notebooks for the series.
The series is called Enterprise Document Intelligence.
The article opens Part III of Enterprise Document Intelligence.
The output is a typed answer with verbatim quotes tied to line ranges and a full audit trail from question to citation.
In the previous article the pipeline was upgraded for each of the four bricks.
The pipeline is pointed at four very different PDFs in the follow up.
Document parsing produces line_df one row per visible line with page_num line_num text bounding box.
Document parsing produces page_df one row per page.
Document parsing produces toc_df one row per section with title level start_page.
Document parsing produces parsing_summary.
Question parsing corrects typos and infers answer shape.
Retrieval uses TOC router plus keywords.
Generation returns typed answers with citable spans.
The pipeline returns the right answer on a clean question against a paper with a built-in table of contents.
On a real corpus it breaks the first time the user types “positonal encodig” with two typos.
It breaks the first time the document is a 200-page contract with no PDF outline.
It breaks the first time the question asks for every exclusion instead of one.
It breaks the first time downstream code wants a typed object instead of a string.
| Component | Baseline | Upgraded Pipeline |
|---|---|---|
| Document Parsing | Basic text extraction | Relational set with line_df page_df toc_df and parsing_summary |
| Question Parsing | Raw input | ParsedQuestion with corrected keywords intent RetrievalQuery and GenerationBrief |
| Retrieval | Embedding similarity | TOC router plus keyword hits merging with keyword pages |
| Generation | String response | Typed answer with citable spans and four context-quality indicators |
- Document parsing produces relational dataframes.
- Question parsing structures the input.
- Retrieval selects relevant sections using TOC and keywords.
- Generation creates typed answers with citations.
Frequently asked
What is the length of the example paper used in the pipeline demonstration?
The running example uses the public 15-page arXiv paper Attention Is All You Need.
How many entries are in the TOC of the example paper?
The native TOC on the Attention paper has three levels and twenty-two entries.
Sources
- Towards Data Science — The upgraded pipeline upgrades four bricks on the same Attention Is All You Need paper.
- GitHub — The companion GitHub repo provides runnable notebooks for the series with 32 stars.
- Towards Data Science — The pipeline is pointed at four very different PDFs using the same four bricks.