Skip to content
datarekha

Multimodal RAG

Standard RAG retrieves text, but knowledge lives in charts, scanned PDFs, and slides — and the OCR-then-parse pipeline flattens all of it. Multimodal RAG retrieves visual content directly: vision-native retrieval (ColPali) embeds the page image itself, cross-modal search matches text queries to images, and a VLM reads the retrieved pages to answer.

Written and reviewed by Last reviewed

7 min read Advanced NLP & Transformers Lesson 44 of 44

What you'll learn

  • Why text RAG's OCR pipeline loses charts, tables, and layout
  • Vision-native retrieval (ColPali) — embedding the page image directly
  • Cross-modal retrieval via the shared image-text space
  • Multimodal agents that reason over retrieved visual context

Before you start

RAG (retrieval-augmented generation, where an LLM answers using documents fetched for the question) retrieves text chunks. But a huge share of real knowledge lives in charts, tables, scanned PDFs, slides, and diagrams. The classic pipeline runs OCR (software that turns a picture of text into text), then parses the result, then chunks the text. That pipeline flattens everything, dropping the layout and figures that carry the meaning. Multimodal RAG retrieves visual content directly.

Vision-native retrieval: skip the OCR

The key technique is vision-native retrieval (ColPali-style): embed the document page image itself into a space shared with the text query, with no OCR and no parsing. An embedding is a list of numbers that captures meaning, and a shared space means text and images can be compared directly. A CLIP-like or VLM encoder (a vision-language model, one that reads images and text together) reads the page as an image. A chart’s shape and a table’s structure then survive into the embedding. Retrieval is ordinary similarity search, but over page images:

import numpy as np

query = np.array([0.9, 0.1])                       # "revenue chart" query embedding
pages = {"p1 cover": [0.1, 0.9], "p2 revenue chart": [0.85, 0.15], "p3 appendix": [0.4, 0.6]}

def cos(a, b):
    a, b = np.array(a), np.array(b)
    return a @ b / (np.linalg.norm(a) * np.linalg.norm(b))

for name in sorted(pages, key=lambda n: cos(query, pages[n]), reverse=True):
    print(f"{cos(query, pages[name]):.2f}  {name}")
1.00  p2 revenue chart
0.64  p3 appendix
0.22  p1 cover

The query retrieves the revenue-chart page straight from its image — no OCR ever ran, and the chart (which OCR would have mangled into garbled numbers) is matched as a visual object. This both simplifies the pipeline (delete the brittle OCR/layout-parsing stage) and preserves information text extraction loses.

Retrieve the page image, then let a VLM read ittext querypage imagessharedspacetop pagepage imagechart preservedVLMreads + answersvs OCR pipelineflattens to text,loses charts/layoutno OCR — the page is retrieved and read as an image
Multimodal RAG embeds page images directly, retrieves by similarity, and feeds the page to a VLM — preserving the charts and layout an OCR pipeline destroys.

Cross-modal retrieval and multimodal agents

Because images and text share a space, retrieval is cross-modal: a text query can fetch images (and vice versa), so “find the slide with the Q3 funnel diagram” just works. Then the retrieved visual content is handed to a VLM, which reads the chart or screenshot to ground its answer — a multimodal agent that reasons over figures, not just extracted text. The full loop: embed pages as images → retrieve cross-modally → a VLM reads the retrieved pages → grounded answer.

In one breath

  • Standard RAG retrieves text, but its OCR → parse pipeline flattens charts, tables, and layout — losing the meaning in visual documents.
  • Vision-native retrieval (ColPali) embeds the page image itself into a space shared with the query (no OCR), so retrieval is similarity search over images (the demo retrieves the revenue-chart page from its picture).
  • This simplifies the pipeline (delete OCR/parsing) and preserves information text extraction drops.
  • Because image and text share a space, retrieval is cross-modal (text query → image), and a VLM reads the retrieved page to ground its answer — a multimodal agent over figures.
  • Use it for chart/scan/slide/diagram-heavy content; for plain prose, cheaper text chunking still suffices.

Quick check

Quick check

0/5
Q1Why does the classic OCR-based RAG pipeline struggle with visual documents?
Q2What is vision-native retrieval (ColPali-style)?
Q3How does the shared image-text space enable cross-modal retrieval?
Q4A law firm has 50,000 pages of typed, text-only contracts with no figures or tables. Users ask questions about clauses. Which approach is the sensible default?
Q5When is multimodal RAG the right choice over text RAG?

Next

Multimodal RAG combines RAG with the shared CLIP space and a VLM reader; it’s the visual counterpart to text chunking and advanced RAG. Reading the retrieved pages connects to document understanding.

Sign in to track your progress

Completed lessons, your XP, level, and streak save to your account — it's free and takes a few seconds.

Practice this in an interview

All questions
What is Retrieval-Augmented Generation (RAG) and how does a basic RAG pipeline work?

RAG retrieves relevant external documents at query time and gives them to an LLM as context before generation. A basic pipeline ingests and chunks documents, embeds the chunks into a searchable store, retrieves the best matches for a question, and asks the LLM to answer from that evidence.

What is Retrieval-Augmented Generation (RAG) and why is it used?

RAG couples a retrieval step — fetching relevant documents from an external store — with a generative model so the LLM can answer questions about knowledge it was never trained on. It solves the stale-knowledge and hallucination problems without retraining. The pattern is preferred when the knowledge base changes frequently or contains proprietary data.

How do multimodal vision-language models combine images and text, and what role does CLIP play?

A multimodal vision-language model turns image regions into visual tokens, maps them into the language model's hidden representation, and combines them with text through attention. CLIP is a contrastively trained dual encoder that aligns image and text embeddings; it can provide a vision backbone or support retrieval and zero-shot classification, but it is not by itself a generative visual question-answering model.

Your RAG system is hallucinating even though the correct context was retrieved. How do you debug it?

Retrieval is only one link in the chain: trace the exact evidence, assembled prompt, token budget, instructions, model settings, and claim-level support. Reproduce with fixed inputs, separate retrieval failure from generation failure, then enforce citations or abstention and evaluate faithfulness rather than trusting retrieval scores alone.

Related lessons

Explore further