Skip to content

Courses / RAG Systems / Module 12

Module 12: Multimodal RAG: images, tables, page-image retrieval

8 h · theory 2 · hands-on 3 · project 2 · revision 1

You will be able to

  • Retrieve pages as images with ColPali-style models
  • Answer questions about charts and tables
  • Choose between text extraction and page images
  • Measure multimodal retrieval

Capstone increment: Page-image retrieval for diagram- and table-heavy documents.

Job-description skills: Multimodal · Lab tools: colpali-engine, pymupdf

1. When the answer is in a picture

Many answers live in charts, diagrams, slides, scanned forms and tables with merged cells. Text extraction flattens or loses them: a revenue chart becomes a few axis labels, an architecture diagram becomes nothing. If users ask about those pages, a text-only system can’t answer however good its retrieval is.

There are two paths. Extract text, tables and image descriptions at ingestion and search text; or retrieve the page images themselves with a vision retrieval model and let a vision-language model read them.

PDF pagetext, tables, chartsParse + captiontables as MarkdownText indexhybrid searchPage imagerender at ~150 dpiColPali embedmulti-vector patchesMaxSim searchlate interactionVLM answersees the pagePath A: extract, then search textPath B: search the page image itselfpage ids
Text extraction is cheap and searchable; page-image retrieval keeps charts and layout that extraction loses. Measure both on your documents.

2. Path A: extract and describe

Parse tables into Markdown (Module 2), and caption each figure with a vision-language model at ingestion: what kind of chart it is, the axes, the series, the key numbers and the takeaway. Index captions and table text with the rest. Queries stay cheap and fast, and the hybrid retriever works unchanged.

The risk is that captions miss the detail a user asks about. Store the page image reference with every caption, show the image next to the answer, and spot-check captions against the originals.

3. Path B: retrieve page images with ColPali

ColPali (Faysse and others, 2024) embeds a page image directly: a vision-language model turns the page into about a thousand patch vectors, and queries are scored by late interaction (MaxSim), the same idea as ColBERT in Module 6. No OCR, no layout parsing; on visually rich documents it beats text pipelines on the ViDoRe benchmark.

The cost is storage and compute: about a thousand vectors per page. Binary quantization, token pooling and a first-stage filter keep it manageable; Qdrant and others support multi-vector fields. ColQwen and other variants trade size for quality.

Common misconception: “Page-image retrieval replaces text RAG.” It is excellent for slides, reports and scans, and wasteful for plain prose that text search handles well. Route by document type.

Deep dive

Deep dive: what ColPali stores and how it scores

ColPali skips OCR. A vision-language model (PaliGemma) cuts each page image into a 32 × 32 grid of patches and outputs one 128-d vector per patch: about 1,030 vectors per page including a few extra tokens. The query becomes one vector per token, and pages are scored with the same MaxSim as ColBERT: each query token takes its best-matching patch.

That keeps the layout, tables, charts and fonts that text extraction loses, at a storage cost of about 1,030 × 128 numbers per page. Teams cut it with binary quantization, by pooling neighbouring patches, or by using ColPali only to re-rank pages found by a cheaper text index.

Worked example: storage and work for page-image retrieval

one page: 1,030 vectors × 128 dims × 2 bytes (fp16)   = 264 KB
100,000 pages                                         = 26 GB
binary quantization: 1,030 × 128 bits = 16.5 KB/page  = 1.6 GB
query “Q3 revenue by region”: ~6 tokens × 1,030 patches = 6,180 dot products per page
One vector or one per token?Query: “refund window laptops”. The token vectors use five readable features (refund, time limit, laptop, shipping, warranty) so you can follow the scores.
RankSingle vector (mean of tokens, cosine)Late interaction (MaxSim)
1Electronics refund window 0.92Complete returns, shipping and warranty policy 3.00
2Laptop warranty and repairs 0.50Electronics refund window 2.93
3Complete returns, shipping and warranty policy 0.31Laptop warranty and repairs 2.32
Query tokenshippingcourierPIN codewarrantyrepairinvoicelaptopsrefundable14 daysdeliverypackagingservicemax
refund0.000.000.000.000.000.430.001.000.000.000.000.001.00
window0.000.000.000.000.000.000.000.001.000.000.000.001.00
laptops0.000.000.000.000.110.001.000.000.000.000.000.001.00

MaxSim = sum of each row’s best match = 3.00. The single vector scores the same document 0.31, because averaging every token into one vector blurs what the document is about: in the long policy, nine tokens about shipping and warranty bury the three that answer the question.

What it costs to store

One 1,024-d float vector each: 4.1 GB · one 128-d fp16 vector per token: 51 GB · ColBERTv2 residual compression (≈36 bytes per vector): 7 GB

Guided experiments
  1. Compare the two rankings. Why does the single-vector search put the complete policy last, even though it holds the exact answer (“laptops refundable 14 days”)?
  2. Open the matrix for the policy, then for “Laptop warranty and repairs”. Which query token fails to find a good match in the warranty document? That is the signal MaxSim keeps and averaging throws away.
  3. A cross-encoder goes further: it reads query and document together, so “window” can attend to “14 days” directly. Why is it then too slow to run over the whole index, and fine for re-ranking the top 20–50?
  4. Switch to ColPali at 5 million pages. Why do teams pair multi-vector retrieval with compression, or use it only to re-rank candidates from a cheaper first stage?

4. Answer with a vision-language model

Send the top one to three page images, with the question, to a vision-language model and ask it to answer from them and name the page. Image tokens are expensive, so send fewer, well-chosen pages, and resize them to the lowest resolution that keeps the numbers readable.

Keep grounding rules from Module 9: cite the page, refuse when the page doesn’t show the answer, and check numbers the model reads from a chart against the extracted table where one exists.

In production: Cache page renders and image embeddings by page hash. Re-rendering 100,000 pages because one parser setting changed is an expensive afternoon.

5. Measure multimodal retrieval

Write golden questions whose answers are only on visual pages: values from charts, cells from complex tables, labels on diagrams. Measure page-level recall@k for each path, plus answer accuracy, latency, storage and cost per question.

Most teams end up with both: text RAG by default and page-image retrieval for slide decks, reports and scans, chosen by document type at ingestion or by a router at query time.

Hands-on: coding window

The coding window and the full VS Code lab are available after you sign in.

Sign in to code

Labs

Lab 12.1: ColPali on visual pages

Index 30 slide and report pages with colpali-engine (or byaldi) on a free GPU and compare page recall@5 with the text path on 15 visual questions.

Expected: Recall@5 for both paths and five examples where they disagree.

Lab 12.2: Answer from page images

Send the top 2 retrieved page images to a vision-language model with a grounded prompt that must name the page. Check 10 numeric answers against the source.

Expected: Answer accuracy and image-token cost per question.

Lab 12.3: Visual route (capstone increment)

Index table- and diagram-heavy documents as page images in a multi-vector collection, and route visual questions there.

Expected: Visual questions are answered with page citations; text questions are unaffected.

Go deeper

Videos

Further reading

GitHub repositories

  • illuin-tech/colpali: The ColPali and ColQwen model code and the processor that turns pages into patch vectors.
  • AnswerDotAI/byaldi: A small wrapper to index and search PDFs with ColPali in a few lines.
  • pymupdf/PyMuPDF: Page.get_pixmap(): rendering PDF pages to images at a chosen resolution.

Checkpoint quiz

1. A user asks for a value shown only in a bar chart. A text-only pipeline…
2. How does ColPali score a page against a query?
3. ColPali’s main cost?
4. Why send only 1–3 page images to the answer model?
5. Typical production setup?

Interview questions

  1. How would you build RAG over slide decks and annual reports full of charts?
  2. Compare captioning figures at ingestion with ColPali-style page retrieval.
  3. How do you control the storage cost of multi-vector page embeddings?
  4. How do you evaluate a multimodal RAG system?
  5. A VLM misreads a number from a chart. How would you detect and reduce this?

Ask the professor

Sign in to ask questions about this module.

Discussion

Community discussion appears here once giscus is configured (see README).