Module 4 · Next-generation RAG architectures
Multimodal RAG: images, tables, diagrams
6 min read
Part of a company's information is not text: assembly diagrams, price tables, screenshots, charts, scanned documents. A text-only RAG ignores them — or worse, text extraction from a PDF turns them into a string of numbers without headers. This lesson presents three strategies to make this content searchable, and implements them for the images and tables of the Nimbus help center.
Three strategies
| Strategy | Principle | Advantages | Drawbacks |
|---|---|---|---|
| Everything as text | A vision model describes each image; the description is indexed | Reuses the whole text pipeline (hybrid, re-ranking) | One vision call per image; the description may miss a detail |
| Multimodal embeddings | Images and texts in the same vector space | No description to generate | Less mature models, no BM25 on the image |
| Pages as images | Each document page is indexed as an image (ColPali-style approach), then sent to the model | Preserves the layout | Heavy storage, specialized models |
In all three cases, at answer time, you can send the image itself to the generation model: a vision model reads a table or a diagram directly, which avoids depending on an intermediate description.
Everything as text: describing in order to retrieve
Prism follows the first strategy, the simplest to set up. The description prompt targets search, not reading:
DESCRIBE = """Décris cette image d'un centre d'aide pour qu'elle soit retrouvée par une recherche
textuelle : type d'image (schéma, tableau, photo, capture), éléments visibles, TOUS les libellés,
valeurs et codes lisibles, et ce qu'elle permet de comprendre. Pas d'interprétation au-delà de ce
qui est visible."""
(Describe this help center image so it can be found by text search: image type, visible elements, ALL readable labels, values and codes, and what it helps understand. No interpretation beyond what is visible.) "All labels, values and codes": that is what will let BM25 find "M6 screw" or "29 €". "No interpretation": a description that extrapolates puts information into the index that the image does not contain.
The call sends the image in base64 along with the instruction:
response = llm.client().messages.create(
model=config.MODEL, max_tokens=1024,
messages=[{"role": "user", "content": [
{"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": data}},
{"type": "text", "text": DESCRIBE},
]}],
)
Each description becomes a passage, with the image path in its metadata and a link to its article:
chunks.append(Chunk(
id=f"img:{path.stem}", article_id=article_for.get(path.name, path.stem), category="images",
title=f"Image : {path.stem}", text=describe_image(path),
meta={"image_path": str(path), "modality": "image"},
))
The link to the article keeps metrics at the article level; the image path lets you send the original image to the model at generation time, in addition to its description.
The corpus contains two images: the assembly diagram of the Lift desk and the delivery price table. The diagram's description ("Top A of 140 × 70 cm resting on two legs B… 8 M6 × 16 screws") makes searchable a piece of information that only the image contained: no article mentions the M6 screws.
Descriptions are expensive to produce and stable: generate them once at ingestion and keep them. In offline mode, Prism reads reference descriptions stored next to the images, to test the pipeline without a vision call.
Tables: linearizing
A table chunked like text loses its headers: the passage "Express | 24 h | €9.90" no longer says what these columns are, and a split in the middle of the table separates rows from their headers. The solution: one sentence per row, with the headers repeated.
def table_to_text(headers: list[str], rows: list[list[str]], caption: str) -> str:
"""Linéarise un tableau : une phrase par ligne, avec les en-têtes répétés.
Chaque ligne reste compréhensible seule, même si le passage est découpé.
"""
lines = [caption]
for row in rows:
lines.append(" ; ".join(f"{h} : {v}" for h, v in zip(headers, row)) + ".")
return "\n".join(lines)
Tarifs de livraison
Mode : Express ; Délai : 24 h ; Prix : 9,90 €.
Mode : Meuble ; Délai : 7 à 10 jours ouvrés ; Prix : 29 €.
(Delivery rates; mode, lead time and price per row: express in 24 h for €9.90, furniture in 7 to 10 business days for €29.) Each row is now a self-contained passage, searchable by dense search as well as BM25. For questions that require a computation over the table ("which is the cheapest mode under 5 days?"), it is better to send the model the full table (in Markdown) or, for large volumes, load it into a database and give the model an SQL tool.
Extracting before indexing
The quality of multimodal RAG depends first on extraction: spotting images, tables and headings in PDFs, slide decks and web pages. Simple extractors flatten everything into text; specialized tools (Docling, Unstructured, LlamaParse, cloud providers' extractors) detect structure, tables and figures. A vision model can also read each page of a PDF directly: it is often the most reliable approach for documents with complex layouts, at the cost of one call per page.
The test that matters remains the same: questions whose answer is only in an image or a table, added to the evaluation set, and a measured recall.
Key takeaways
- Three strategies: everything as text (descriptions), multimodal embeddings, pages indexed as images.
- "Everything as text" reuses the whole pipeline: describe for search (all labels and values, no interpretation).
- Keep the link to the image: at generation time, the model can read it directly.
- Linearize tables (one sentence per row, headers repeated); for computations, provide the full table or an SQL tool.
- Quality depends on extraction: test with questions whose answer is only in an image or a table.
Practice
- Add the image passages to the test bench and ask « Combien de vis faut-il pour fixer le piètement du bureau ? » (how many screws are needed to attach the desk legs?).
- Linearize the price table with
table_to_textand check that « livraison meuble prix » (furniture delivery price) retrieves the right row. - With an API key, compare Claude's description of the assembly diagram with the reference description: which details differ?