The last two lessons searched passages and photographs. This lesson tackles the messier thing most organisations actually need to search: real documents — reports, forms, manuals, invoices.
Open any annual report and look at what carries the meaning:
Every one of those depends on position. Move the number out of its cell and it stops meaning anything.
The standard approach is to run OCR, pull the text out, and search that text. The trouble is what OCR produces: a stream of words with the layout stripped off.
The number 73 was in the Q3 column of a revenue table. After extraction it is just 73, floating in a list beside dozens of other numbers. The fact that made it an answer — its position — is gone.
This happens silently, during indexing, long before anyone asks a question. By the time retrieval runs, the evidence has already been destroyed and nothing downstream can tell.
The other option is to stop extracting altogether: keep each page as an image, and let a vision-language model encode it directly. Charts, tables, and layout stay intact because nothing was pulled apart.
Neither approach wins everywhere, which is why the rest of this lesson is about choosing between them.
A multimodal document QA system has two main components:
The retriever chooses the evidence. The vision-language model (VLM) reads it and writes the answer.
This is a sensible starting point for clean, mostly textual documents. It supports exact term matching and can be cheaper.
This preserves charts, tables, text, and layout together. It avoids making OCR and layout parsing the only path to the evidence.
| Consideration | Parse then embed | Vision-space retrieval |
|---|---|---|
| Clean native text | Strong choice | Often unnecessary |
| Exact keyword matching | Easy to include | May need a separate text path |
| Charts and unusual layouts | Parsing may lose structure | Preserves the original page |
| Compute and index size | Usually lower | Usually higher |
| Pipeline | Several extraction steps | Simpler core retrieval path |
The retrieval unit might be a document, page, passage, or visual region.
Always save document ID and page number. The system must answer “which page supports this?”, not only “which file seems related?”
Give the VLM:
Use only the retrieved pages as evidence.
For every numeric claim, cite the page and chart or table region.
If the answer is unsupported, say:
"Not found in the retrieved documents."
Allowing the model to abstain is safer than forcing an answer.
Question:
What was Q3 revenue growth over Q2?
The retriever finds a report page with this chart data:
Q1: 42
Q2: 50
Q3: 73
Q4: 68
The VLM identifies Q2 and Q3. Deterministic code can calculate:
q2, q3 = 50, 73
growth_percent = (q3 - q2) / q2 * 100 # 46%
Grounded answer:
Q3 revenue grew 46% over Q2, using values 50 and 73 from the bar chart on page 7.
Separating visual reading from arithmetic makes both steps easier to verify.
Better prompting cannot repair a missing page. Diagnose retrieval and generation separately.
Document RAG can parse pages into text or search page images directly; the right choice depends on whether visual layout carries the answer.