05. Multimodal RAG¶
Category: Advanced RAG Architecture
Module: Part V โ Advanced Retrieval-Augmented Generation
Difficulty: Advanced
๐ Overview¶
Traditional Retrieval-Augmented Generation (RAG) systems are primarily designed around text:
Enterprise knowledge, however, is rarely text-only.
Important information can exist in:
Text
Images
Tables
Charts
Diagrams
Screenshots
Scanned Documents
Audio
Video
Presentations
Technical Drawings
Forms
Invoices
Contracts
A Multimodal RAG system extends RAG so that retrieval and generation can work across multiple information modalities.
Instead of treating every document as plain text, Multimodal RAG preserves and retrieves the different forms of evidence contained in enterprise knowledge.
The architecture therefore becomes:
Enterprise Knowledge
โ
โโโโโโโโโโโโโโฌโโโโโโโโผโโโโโโโโโฌโโโโโโโโโโโโ
โผ โผ โผ โผ โผ
Text Images Tables Audio Video
โ โ โ โ โ
โโโโโโโโโโโโโโดโโโโโโโโผโโโโโโโโโดโโโโโโโโโโโโ
โผ
Multimodal Retrieval
โ
โผ
Context Assembly
โ
โผ
Multimodal Foundation Model
โ
โผ
Enterprise Response
The goal is not simply to "put images into a prompt."
The goal is to build a production-grade retrieval architecture that understands, indexes, retrieves, grounds, validates, and cites multimodal enterprise knowledge.
๐ฏ Learning Objectives¶
After completing this chapter, you will be able to:
- Understand Multimodal RAG
- Understand why text-only RAG is insufficient for many enterprise workloads
- Understand multimodal documents
- Understand multimodal ingestion pipelines
- Extract text, images, tables, and layout information
- Understand OCR in Multimodal RAG
- Understand image embeddings
- Understand multimodal embeddings
- Understand cross-modal retrieval
- Understand image-to-text retrieval
- Understand text-to-image retrieval
- Understand image-to-image retrieval
- Understand multimodal chunking
- Understand document layout preservation
- Understand table-aware retrieval
- Understand chart and diagram retrieval
- Understand visual document retrieval
- Design multimodal vector stores
- Combine text and image retrieval
- Build multimodal context
- Use multimodal foundation models
- Handle scanned documents
- Handle PDFs containing images and tables
- Build multimodal enterprise RAG pipelines
- Combine Multimodal RAG with Graph RAG and SQL RAG
- Design multimodal citation and provenance
- Secure multimodal data
- Evaluate multimodal retrieval and generation
- Optimize multimodal RAG latency and cost
- Design production Multimodal RAG systems
๐ง 1. What Is Multimodal RAG?¶
Multimodal RAG is a RAG architecture that retrieves and uses information from multiple modalities.
For example:
A user may ask:
A text-only RAG system may fail if the relationship exists only inside the diagram.
A Multimodal RAG system can retrieve:
and provide both to the model.
๐ 2. Traditional RAG vs Multimodal RAG¶
Traditional Text RAG¶
Document
โ
Text Extraction
โ
Chunking
โ
Text Embedding
โ
Vector Search
โ
Text Context
โ
LLM
Multimodal RAG¶
Document
โ
Multimodal Parsing
โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโ
โผ โผ โผ
Text Images Tables
โ โ โ
โผ โผ โผ
Embeddings Embeddings Structured Index
โโโโโโโโโโโโโโโดโโโโโโโโโโโโโโ
โ
โผ
Multimodal Retrieval
โ
โผ
Multimodal Context
โ
โผ
Multimodal Model
๐งฉ 3. What Makes Enterprise Data Multimodal?¶
Consider a technical architecture document.
It may contain:
Title
Paragraphs
Architecture Diagram
Tables
Code Snippets
Screenshots
Sequence Diagram
Deployment Diagram
A text extractor may capture:
but completely miss the meaning of:
Multimodal RAG attempts to preserve these relationships.
๐ 4. Common Enterprise Multimodal Sources¶
Typical sources include:
PDF
PowerPoint
Word Documents
Scanned Documents
Images
Architecture Diagrams
Technical Drawings
Invoices
Receipts
Contracts
Forms
Dashboards
Screenshots
Product Catalogs
Medical Images
Satellite Images
Video Recordings
Audio Recordings
๐ง 5. Multimodal RAG Mental Model¶
A useful mental model is:
USER QUERY
โ
โผ
QUERY UNDERSTANDING
โ
โผ
MODALITY ANALYSIS
โ
โโโโโโโโโโโโโผโโโโโโโโโโโโ
โผ โผ โผ
TEXT IMAGE TABLE
โ โ โ
โโโโโโโโโโโโโผโโโโโโโโโโโโ
โผ
MULTIMODAL RETRIEVAL
โ
โผ
EVIDENCE FUSION
โ
โผ
CONTEXT ENGINEERING
โ
โผ
MULTIMODAL MODEL
โ
โผ
VALIDATED RESPONSE
๐งฉ 6. Multimodal Data Model¶
A multimodal document should not necessarily be represented as one large blob.
Instead:
Document
โ
โโโ Text Blocks
โโโ Images
โโโ Tables
โโโ Charts
โโโ Diagrams
โโโ Metadata
โโโ Layout
Each component can have its own representation.
๐๏ธ 7. Multimodal Document Representation¶
Example:
{
"document_id": "architecture-001",
"page": 12,
"elements": [
{
"type": "text",
"content": "Payment architecture"
},
{
"type": "image",
"asset_id": "img-128"
},
{
"type": "table",
"asset_id": "table-22"
}
]
}
This preserves the document structure.
๐ 8. Layout Matters¶
Consider:
Architecture Diagram
Service A โโโโโโโโบ Service B
โ โ
โผ โผ
Database A Database B
The text alone:
does not preserve the relationships represented spatially.
Layout-aware processing is therefore important for many enterprise documents.
๐ง 9. Document Layout¶
A document parser may identify:
The ingestion system can preserve:
๐๏ธ 10. Multimodal Ingestion Pipeline¶
flowchart TD
A["Enterprise Document"] --> B["Document Parser"]
B --> C["Layout Analysis"]
C --> D["Text Extraction"]
C --> E["Image Extraction"]
C --> F["Table Extraction"]
C --> G["Chart / Diagram Extraction"]
D --> H["Text Processing"]
E --> I["Visual Processing"]
F --> J["Table Processing"]
G --> K["Visual Processing"]
H --> L["Multimodal Index"]
I --> L
J --> L
K --> L
๐ 11. OCR¶
OCR stands for:
OCR converts text contained in images into machine-readable text.
Example:
OCR is particularly important for:
๐ง 12. OCR Is Not Document Understanding¶
OCR provides:
but does not necessarily understand:
For example:
may be extracted correctly, but the system may still need layout information to determine which value belongs to which field in a complex form.
๐งฉ 13. OCR + Layout Understanding¶
A stronger pipeline is:
Example:
๐ผ๏ธ 14. Image Embeddings¶
Images can be represented as vectors.
Conceptually:
Example:
This allows image similarity search.
๐ 15. Multimodal Embeddings¶
A multimodal embedding model can map different modalities into a compatible semantic space.
Conceptually:
Then:
can potentially retrieve:
even though the query and retrieved object have different modalities.
๐ง 16. Cross-Modal Retrieval¶
Cross-modal retrieval means the query and result can use different modalities.
Examples:
Example:
๐ 17. Text-to-Image Retrieval¶
Text Query
โ
Text Embedding
โ
Multimodal Vector Search
โ
Image Embedding
โ
Architecture Diagram
This is useful for:
๐ผ๏ธ 18. Image-to-Text Retrieval¶
Example:
User uploads:
Architecture Diagram
โ
Visual Embedding
โ
Retrieve:
Architecture Documentation
Runbook
API Documentation
This allows visual information to become a retrieval signal.
๐ผ๏ธ 19. Image-to-Image Retrieval¶
Example:
This can support:
๐ 20. Table Retrieval¶
Tables require special treatment.
Consider:
Naively embedding the table as plain text may lose:
A better architecture can preserve both:
๐งฉ 21. Table-Aware Representation¶
Example:
{
"type": "table",
"columns": [
"Product",
"Revenue",
"Growth"
],
"rows": [
["A", "10M", "12%"],
["B", "8M", "17%"]
]
}
The system can additionally generate a textual representation for semantic retrieval.
๐ 22. Charts¶
Charts contain information that may not exist directly as text.
Example:
Sales Trend
โ
โ โญโโโโฎ
โ โญโโโฏ โ
โ โญโโโฏ โฐโโโ
โโโโโโโโโโโโโโโโโ
Jan Feb Mar
Text extraction might only capture:
The actual trend must be understood visually or reconstructed from structured chart data.
๐ง 23. Chart Understanding¶
A multimodal pipeline may extract:
The representation could be:
{
"chart_type": "line",
"title": "Monthly Sales",
"x_axis": ["Jan", "Feb", "Mar"],
"trend": "increasing"
}
๐ผ๏ธ 24. Diagram Understanding¶
Enterprise diagrams may represent:
A multimodal model can analyze:
๐๏ธ 25. Architecture Diagram Example¶
โโโโโโโโโโโโโโโ
โ Client โ
โโโโโโโโฌโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโ
โ API Gateway โ
โโโโโโโโฌโโโโโโโ
โ
โโโโโโโโโดโโโโโโโโ
โผ โผ
โโโโโโโโโโโโ โโโโโโโโโโโโ
โ Payment โ โ Auth โ
โ Service โ โ Service โ
โโโโโโฌโโโโโโ โโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโ
โPostgreSQLโ
โโโโโโโโโโโโ
The graph of relationships may be:
A multimodal system can retrieve the diagram and derive these relationships.
๐ 26. Multimodal RAG and Knowledge Graphs¶
Visual relationships can be transformed into graph knowledge.
Architecture Diagram
โ
Vision Understanding
โ
Entity Extraction
โ
Relationship Extraction
โ
Knowledge Graph
Example:
This connects Multimodal RAG with Knowledge Graph RAG.
๐ง 27. Multimodal RAG and SQL¶
Tables and charts may contain structured information.
For example:
A production system may transform the information into:
and store it in SQL.
Then:
can enable exact analytical queries.
๐ 28. Multimodal + SQL + Graph + Vector¶
A mature enterprise system may combine:
Enterprise Query
โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโ
โผ โผ โผ
Vector SQL Graph
โ โ โ
โผ โผ โผ
Text Tables Relationships
โ โ โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโ
โ
โผ
Multimodal
Evidence
โ
โผ
LLM
This creates a broader enterprise knowledge fabric.
๐งฉ 29. Multimodal Chunking¶
Traditional chunking:
Multimodal chunking may preserve:
Example:
{
"chunk_id": "chunk-102",
"text": "Payment architecture...",
"images": [
"architecture-12.png"
],
"tables": [
"dependency-table-12"
],
"page": 12,
"section": "Payment Architecture"
}
๐ง 30. Parent-Child Multimodal Retrieval¶
A child chunk may represent:
while the parent context contains:
Retrieval can find the child and return the parent multimodal context.
๐ 31. Caption-Based Image Retrieval¶
Images can be enriched with generated captions.
Example:
Caption:
"Microservices architecture showing an API Gateway
connected to Payment and Authentication services."
Then:
can support image retrieval.
๐ง 32. Image Metadata¶
Useful image metadata includes:
Document ID
Page
Section
Image Type
Caption
Bounding Box
Creation Date
Source
Access Policy
Related Text
Related Entities
๐งฉ 33. Multimodal Index¶
A production index may contain:
or a unified multimodal vector index.
Conceptually:
Multimodal Index
โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโ
โผ โผ โผ
Text Vectors Image Vectors Metadata
โ โ โ
โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโ
โผ
Retrieval Layer
๐๏ธ 34. Unified vs Separate Indexes¶
Unified Index¶
Advantages:
Separate Indexes¶
Advantages:
A hybrid approach is often useful.
๐ 35. Hybrid Multimodal Retrieval¶
flowchart TD
A["User Query"] --> B["Query Analysis"]
B --> C["Text Retrieval"]
B --> D["Image Retrieval"]
B --> E["Table Retrieval"]
C --> F["Text Candidates"]
D --> G["Image Candidates"]
E --> H["Table Candidates"]
F --> I["Candidate Fusion"]
G --> I
H --> I
I --> J["Cross-Modal Re-ranking"]
J --> K["Multimodal Context"]
๐ง 36. Modality-Aware Query Routing¶
Not every query needs every modality.
Example:
"What does the refund policy say?"
โ
Text
"Show the architecture diagram for payments."
โ
Image
"What was revenue in Q2?"
โ
SQL / Table
"Which service connects to the payment gateway?"
โ
Graph + Image + Text
The query planner should determine which modalities are relevant.
๐ 37. Modality Router¶
class ModalityRouter:
def route(self, query):
"""
Return required retrieval modalities.
"""
raise NotImplementedError
Possible result:
๐๏ธ 38. Multimodal Retriever Interface¶
A capability-oriented architecture can expose:
class MultimodalRetriever:
def retrieve(
self,
query,
modalities=None,
filters=None,
top_k=10
):
raise NotImplementedError
This keeps the application independent of a specific retrieval implementation.
๐๏ธ 39. Ports & Adapters Architecture¶
flowchart LR
A["RAG Application"] --> B["Multimodal Retrieval Port"]
B --> C["Text Adapter"]
B --> D["Image Adapter"]
B --> E["Table Adapter"]
C --> F["Text Index"]
D --> G["Image Index"]
E --> H["Structured Store"]
The application layer should depend on capabilities rather than infrastructure SDKs.
๐ง 40. Multimodal Foundation Models¶
A multimodal model can process multiple input types.
Conceptually:
For RAG, retrieved evidence may therefore include:
in a single model request.
๐ 41. Multimodal Context¶
Instead of:
a prompt may contain:
TEXT:
Payment service documentation...
IMAGE:
Architecture diagram...
TABLE:
Service dependencies...
The model can reason over the combined evidence.
๐ง 42. Context Ordering¶
Context ordering matters.
A possible structure:
SYSTEM INSTRUCTIONS
USER QUESTION
RELEVANT TEXT
RELEVANT TABLES
RELEVANT IMAGES
SOURCE METADATA
RESPONSE REQUIREMENTS
The exact structure depends on the model and workload.
๐งฉ 43. Visual Context Selection¶
Do not blindly pass every retrieved image.
Use:
Example:
๐ 44. Image Re-ranking¶
Candidate images can be ranked using:
Example:
Only the strongest candidates need to reach the generation stage.
๐ง 45. Multimodal Evidence Fusion¶
Different modalities can provide different evidence.
Example:
Text:
"Payment Service uses PostgreSQL."
Image:
Architecture diagram showing
Payment Service โ PostgreSQL.
Graph:
PaymentService --USES--> PostgreSQL.
The system can combine:
to improve grounding.
๐ก๏ธ 46. Evidence Agreement¶
A production system can detect whether different evidence sources agree.
Text:
Payment Service โ PostgreSQL
Image:
Payment Service โ PostgreSQL
Graph:
Payment Service โ PostgreSQL
Agreement:
But:
requires additional validation.
โ ๏ธ 47. Conflicting Multimodal Evidence¶
Enterprise documents may contain contradictory information.
Example:
A production system should consider:
rather than simply combining both.
๐ 48. Multimodal Freshness¶
Visual documents can become stale.
Example:
may no longer represent:
Metadata should include:
๐ 49. Document Versioning¶
A useful model:
Retrieval should normally prefer:
unless the user explicitly requests historical information.
๐ง 50. Multimodal Provenance¶
Every visual evidence item should retain:
Example:
{
"asset_id": "image-928",
"document_id": "architecture-v4",
"page": 12,
"section": "Payment Architecture",
"bbox": [120, 240, 980, 740],
"version": "4.0"
}
๐ 51. Multimodal Citations¶
Text citations:
Image citations:
Table citations:
The final response should preserve the connection between the generated claim and its evidence.
๐งพ 52. Citation Example¶
Response:
Evidence:
This is stronger than simply citing:
๐ง 53. Multimodal RAG Grounding¶
Grounding means that generated claims should be supported by retrieved evidence.
For example:
The generation layer should avoid adding unsupported details.
๐จ 54. Multimodal Hallucination¶
Multimodal models can hallucinate:
For example:
This is a visual hallucination.
๐ก๏ธ 55. Multimodal Response Validation¶
Validation can compare generated claims against:
Conceptually:
Response
โ
Claim Extraction
โ
Evidence Matching
โ
Unsupported Claim Detection
โ
Correction / Rejection
๐ง 56. Table Grounding¶
If a model answers:
the system should be able to identify:
as evidence.
๐ 57. Chart Grounding¶
If a model says:
the evidence should point to:
rather than only the surrounding text.
๐งฉ 58. Multimodal Response Contract¶
A structured internal response can contain:
{
"answer": "...",
"claims": [
{
"text": "Payment Service uses PostgreSQL.",
"evidence": [
{
"type": "image",
"asset_id": "architecture-12"
},
{
"type": "text",
"chunk_id": "chunk-812"
}
]
}
]
}
This supports downstream validation and citation.
๐ 59. Multimodal Security¶
Images and documents may contain sensitive information.
Examples:
Screenshots
Credentials
Customer Data
Internal Architecture
Financial Information
Personal Information
Security Diagrams
Security controls should apply to:
๐ก๏ธ 60. Image-Level Authorization¶
A user may be allowed to access:
but not:
Therefore authorization should be evaluated at the asset level.
๐ฅ 61. Multi-Tenant Multimodal RAG¶
Tenant boundaries should be preserved across:
Example:
Tenant A
โโโ Text
โโโ Images
โโโ Tables
โโโ Graph Data
Tenant B
โโโ Text
โโโ Images
โโโ Tables
โโโ Graph Data
Cross-tenant retrieval must be prevented.
๐ง 62. Multimodal PII¶
PII may exist inside images even when metadata contains no obvious PII.
For example:
OCR can expose this information.
Therefore security and privacy scanning should consider both:
๐งช 63. Multimodal Evaluation¶
Evaluation should cover multiple layers:
Document Parsing
OCR
Image Retrieval
Text Retrieval
Table Retrieval
Cross-Modal Retrieval
Evidence Fusion
Answer Generation
Citation
๐ 64. Retrieval Metrics¶
For retrieval:
For image retrieval:
๐ง 65. Visual Question Answering Evaluation¶
For visual questions:
Example:
Question:
Which service is connected to PostgreSQL?
Image:
Architecture Diagram
Expected:
Payment Service
๐ 66. Multimodal Groundedness¶
Evaluate:
Is the answer supported by the image?
Is the answer supported by the table?
Is the answer supported by the text?
Are citations pointing to the correct evidence?
๐งช 67. Multimodal Evaluation Dataset¶
Example:
{
"question": "Which service uses PostgreSQL?",
"image": "architecture-12.png",
"expected_answer": "Payment Service",
"evidence": {
"page": 12,
"figure": 3
}
}
A production evaluation set should include:
Easy Visual Questions
Complex Diagrams
Tables
Charts
OCR Cases
Cross-Modal Questions
Conflicting Evidence
Low-Quality Images
๐จ 68. Multimodal Failure Modes¶
Common failures include:
OCR Errors
Image Retrieval Failure
Incorrect Image Interpretation
Wrong Table Extraction
Layout Loss
Chart Misinterpretation
Incorrect Cross-Modal Linking
Stale Visual Evidence
Missing Provenance
Visual Hallucination
Context Overflow
High Inference Cost
๐งฉ 69. Low-Resolution Images¶
Poor image quality can cause:
A preprocessing pipeline may use:
Only apply expensive processing where required.
๐ผ๏ธ 70. Image Cropping¶
Instead of passing a full page:
retrieve only:
This can reduce:
๐ 71. Region-Level Retrieval¶
A document image can be divided into regions:
Page
โ
โโโ Region A โ Text
โโโ Region B โ Table
โโโ Region C โ Diagram
โโโ Region D โ Caption
Each region can have independent metadata and embeddings.
๐ง 72. Visual Chunking¶
Visual chunking is analogous to text chunking.
The retrieval layer can then operate at the appropriate granularity.
๐งฉ 73. Multimodal Parent-Child Retrieval¶
Parent:
Page 12
Children:
โโโ Paragraph 12.1
โโโ Diagram 12.1
โโโ Table 12.1
โโโ Caption 12.1
A query may retrieve:
but return:
This provides richer context.
โก 74. Performance Optimization¶
Multimodal processing can be expensive.
Optimization areas include:
OCR
Image Embeddings
Visual Embeddings
Vision Model Calls
Image Storage
Network Transfer
Context Size
๐ฐ 75. Cost Optimization¶
Avoid sending every image to a multimodal model.
Use a funnel:
Broad Retrieval
โ
Metadata Filtering
โ
Text / Caption Retrieval
โ
Visual Re-ranking
โ
Top Images
โ
Vision Model
This reduces expensive inference.
โก 76. Two-Stage Multimodal Retrieval¶
flowchart TD
A["User Query"] --> B["Cheap Candidate Retrieval"]
B --> C["Top 50 Candidates"]
C --> D["Metadata / Text Filtering"]
D --> E["Top 10 Candidates"]
E --> F["Visual Re-ranking"]
F --> G["Top 3"]
G --> H["Multimodal LLM"]
This is usually more scalable than sending dozens of images directly to the model.
๐ง 77. Modality-Specific Caching¶
Cache:
For immutable documents:
๐๏ธ 78. Asset Storage¶
Original assets should generally be stored separately from embeddings.
Object Storage
โ
โโโ Original PDF
โโโ Images
โโโ Cropped Regions
โโโ Extracted Assets
Vector Store
โ
โโโ Embeddings + Metadata
The vector store should not necessarily become the primary binary asset store.
๐งฉ 79. Multimodal Metadata¶
Useful metadata:
asset_id
document_id
page
section
modality
mime_type
caption
entities
created_at
updated_at
version
tenant_id
access_policy
source_uri
๐๏ธ 80. Production Multimodal RAG Architecture¶
flowchart TD
A["Enterprise Sources"] --> B["Ingestion Layer"]
B --> C["Document Parsing"]
C --> D["Text"]
C --> E["Images"]
C --> F["Tables"]
C --> G["Audio / Video"]
D --> H["Text Embeddings"]
E --> I["Visual Embeddings"]
F --> J["Structured Representation"]
G --> K["Transcription / Visual Processing"]
H --> L["Multimodal Retrieval Layer"]
I --> L
J --> L
K --> L
L --> M["Metadata Filtering"]
M --> N["Cross-Modal Re-ranking"]
N --> O["Evidence Fusion"]
O --> P["Context Engineering"]
P --> Q["Multimodal Foundation Model"]
Q --> R["Response Validation"]
R --> S["Citation / Attribution"]
S --> T["Enterprise Response"]
๐ 81. End-to-End Multimodal RAG¶
ENTERPRISE SOURCES
โ
โโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ
โผ โผ โผ
Text Images Tables
โ โ โ
โผ โผ โผ
Text Parsing Vision/OCR Table Parsing
โ โ โ
โโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ
โผ
Multimodal Indexing
โ
โผ
Query Analysis
โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โผ โผ โผ
Text Image Table
Retrieval Retrieval Retrieval
โ โ โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โผ
Candidate Fusion
โ
โผ
Re-ranking
โ
โผ
Evidence Selection
โ
โผ
Multimodal Context
โ
โผ
Multimodal LLM
โ
โโโโโโโโโโดโโโโโโโโโ
โผ โผ
Validation Citation
โ โ
โโโโโโโโโโฌโโโโโโโโโ
โผ
Enterprise Response
๐ง 82. Multimodal RAG + Agentic RAG¶
Agents can use modality-specific tools.
Agent
โ
โโโ Text Search
โ
โโโ Image Search
โ
โโโ Table / SQL Tool
โ
โโโ Knowledge Graph
โ
โโโ OCR
โ
โโโ Vision Analysis
Example:
User:
"Analyze the architecture diagram and
identify the database used by Payment Service."
Agent
โ
Image Retrieval
โ
Vision Analysis
โ
Knowledge Graph Verification
โ
Response
๐ 83. Multimodal RAG + Knowledge Graph¶
A diagram can become graph evidence:
The graph can then be queried independently.
This creates a pipeline:
๐ 84. Multimodal RAG + SQL¶
Tables can become structured data:
This allows questions such as:
to be answered using exact structured computation rather than visual approximation.
๐ข 85. Enterprise Multimodal Knowledge Fabric¶
flowchart TD
A["Enterprise Knowledge"] --> B["Knowledge Fabric"]
B --> C["Documents"]
B --> D["Vector Store"]
B --> E["Knowledge Graph"]
B --> F["SQL"]
B --> G["Image / Media Store"]
C --> H["RAG Orchestrator"]
D --> H
E --> H
F --> H
G --> H
H --> I["Multimodal Foundation Model"]
I --> J["Validation"]
J --> K["Enterprise Response"]
๐ง 86. Multimodal Query Router¶
A production router may classify queries into:
Example:
class QueryModality:
TEXT_ONLY = "text"
IMAGE = "image"
TABLE = "table"
GRAPH = "graph"
SQL = "sql"
MULTIMODAL = "multimodal"
๐งฉ 87. Capability-Based Architecture¶
Rather than coupling the application to one multimodal provider:
class VisionProvider:
def analyze_image(self, image, prompt):
raise NotImplementedError
class OCRProvider:
def extract_text(self, image):
raise NotImplementedError
class EmbeddingProvider:
def embed_text(self, text):
raise NotImplementedError
def embed_image(self, image):
raise NotImplementedError
Cloud- or model-specific implementations can sit behind these interfaces.
๐๏ธ 88. Ports & Adapters¶
Application
โ
โโโโโโโโโโโโผโโโโโโโโโโโ
โผ โผ โผ
VisionPort OCRPort EmbeddingPort
โ โ โ
โผ โผ โผ
Adapter A Adapter B Adapter C
โ โ โ
โโโโโโโโโโโโผโโโโโโโโโโโ
โผ
AI / Cloud Services
This keeps the application architecture portable.
๐งช 89. Practical Exercise¶
Build a multimodal document collection:
Extract:
Then index them.
๐ 90. Practice Queries¶
Test:
1. Find the architecture diagram for the payment platform.
2. Which service connects to PostgreSQL?
3. What does the architecture diagram show?
4. What was the highest-revenue region?
5. Find the invoice containing customer Acme.
6. What amount appears on the invoice?
7. Which database is shown in the deployment diagram?
8. Compare the architecture in version 2 and version 3.
๐งช 91. Compare Retrieval Strategies¶
Implement:
A. Text-only RAG
B. Image-only Retrieval
C. Text + Image Retrieval
D. Text + Image + Table Retrieval
E. Text + Image + Table + Graph
Measure:
๐ 92. Example Evaluation Matrix¶
| Architecture | Retrieval | Grounding | Latency | Cost |
|---|---|---|---|---|
| Text RAG | Text | Medium | Low | Low |
| Image Retrieval | Visual | Medium | Medium | Medium |
| Text + Image | High | High | Medium | Medium |
| Text + Image + Table | High | High | Medium | Medium |
| Full Multimodal + Graph + SQL | Very High | Very High | High | High |
The exact results depend on the dataset and implementation.
๐จ 93. Common Mistakes¶
Mistake 1 โ Converting Everything to Text¶
This can destroy visual relationships.
Mistake 2 โ Sending Every Image to the LLM¶
This increases:
Mistake 3 โ Ignoring Layout¶
Spatial relationships can contain important meaning.
Mistake 4 โ Treating OCR as Complete Understanding¶
OCR provides text, not complete visual semantics.
Mistake 5 โ Ignoring Tables¶
Tables should often be represented structurally.
Mistake 6 โ Ignoring Provenance¶
Visual evidence should be traceable to:
Mistake 7 โ Ignoring Versioning¶
Old diagrams can produce incorrect answers.
Mistake 8 โ Trusting Vision Models Blindly¶
Visual models can hallucinate objects and relationships.
Mistake 9 โ Ignoring Security¶
Images can contain highly sensitive information.
Mistake 10 โ Building Multimodal Infrastructure Without a Use Case¶
Multimodal processing can be expensive.
Start with a measurable business requirement.
๐ง 94. Design Principles¶
Principle 1 โ Preserve Modality¶
Do not convert everything to text if visual structure carries meaning.
Principle 2 โ Retrieve Before Reasoning¶
Use retrieval to reduce the amount of visual and textual information sent to the model.
Principle 3 โ Use the Right Representation¶
Text โ Text Embedding
Image โ Visual Embedding
Table โ Structured Representation
Graph โ Relationship Representation
Principle 4 โ Preserve Layout¶
Page and region relationships can be critical.
Principle 5 โ Preserve Provenance¶
Every multimodal asset should be traceable.
Principle 6 โ Route by Modality¶
Do not perform expensive visual reasoning when text retrieval is sufficient.
Principle 7 โ Validate Visual Claims¶
Multimodal models can hallucinate.
Principle 8 โ Combine Modalities¶
Different modalities often provide complementary evidence.
Principle 9 โ Secure Every Representation¶
Protect:
Principle 10 โ Optimize the Expensive Path¶
Use:
before expensive multimodal inference.
๐ 95. Production Checklist¶
โ Identify multimodal use cases
โ Identify supported modalities
โ Identify source systems
โ Identify document types
โ Implement document parsing
โ Implement layout extraction
โ Implement OCR
โ Implement image extraction
โ Implement table extraction
โ Implement chart extraction
โ Implement diagram extraction
โ Preserve page information
โ Preserve bounding boxes
โ Preserve section relationships
โ Preserve captions
โ Preserve document versions
โ Generate text embeddings
โ Generate image embeddings
โ Define multimodal embedding strategy
โ Build multimodal indexes
โ Build metadata indexes
โ Implement text retrieval
โ Implement image retrieval
โ Implement table retrieval
โ Implement cross-modal retrieval
โ Implement modality routing
โ Implement candidate fusion
โ Implement re-ranking
โ Implement multimodal context assembly
โ Implement visual context selection
โ Implement context compression
โ Implement vision model integration
โ Implement response validation
โ Implement citation resolution
โ Implement provenance tracking
โ Implement authentication
โ Implement authorization
โ Implement tenant isolation
โ Protect sensitive images
โ Protect OCR output
โ Protect embeddings
โ Implement asset versioning
โ Implement freshness tracking
โ Implement deletion handling
โ Evaluate OCR quality
โ Evaluate image retrieval
โ Evaluate text retrieval
โ Evaluate table retrieval
โ Evaluate cross-modal retrieval
โ Evaluate groundedness
โ Evaluate citation accuracy
โ Monitor retrieval latency
โ Monitor vision inference latency
โ Monitor OCR latency
โ Monitor model cost
โ Monitor context size
โ Monitor failed retrievals
โ Cache embeddings
โ Cache OCR
โ Cache image analysis
โ Use candidate filtering
โ Use visual re-ranking
โ Control multimodal model calls
โ Build regression datasets
โ Test conflicting evidence
โ Test stale documents
โ Test low-quality images
โ Test security boundaries
๐ 96. Key Takeaways¶
- Multimodal RAG extends RAG beyond text-only knowledge.
- Enterprise knowledge often exists in images, tables, charts, diagrams, audio, and video.
- OCR is important for scanned documents but does not replace visual understanding.
- Layout information can be critical for preserving document meaning.
- Images can be represented using visual embeddings.
- Multimodal embeddings can enable cross-modal retrieval.
- Text-to-image retrieval allows natural-language queries to find visual evidence.
- Image-to-text retrieval allows visual inputs to retrieve textual documentation.
- Image-to-image retrieval supports visual similarity use cases.
- Tables should often retain their structural representation.
- Charts and diagrams can contain information that plain text extraction loses.
- Multimodal chunking should preserve relationships between text, images, tables, captions, and sections.
- Parent-child retrieval can return richer multimodal context.
- Caption generation can make visual assets easier to retrieve.
- Separate or unified multimodal indexes can be used depending on requirements.
- Modality-aware routing can reduce unnecessary inference cost.
- Cross-modal re-ranking can improve retrieval quality.
- Multimodal evidence should preserve provenance.
- Visual evidence should be linked to document, page, figure, or region.
- Multimodal models can hallucinate visual facts and therefore require grounding and validation.
- Conflicting visual and textual evidence should be resolved using source authority, version, and temporal metadata.
- Knowledge Graphs can represent relationships extracted from diagrams and visual documents.
- SQL can provide exact structured computation for information extracted from tables.
- Multimodal RAG can therefore work together with Vector RAG, Graph RAG, and SQL RAG.
- Security must apply to original assets, OCR, embeddings, metadata, and retrieved context.
- Multimodal RAG can be significantly more expensive than text-only RAG.
- Candidate filtering, caching, cropping, and re-ranking help control cost.
- Production Multimodal RAG requires evaluation, observability, provenance, security, and governance.
๐ง Final Mental Model¶
ENTERPRISE KNOWLEDGE
โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโผโโโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โผ โผ โผ โผ โผ
TEXT IMAGES TABLES AUDIO VIDEO
โ โ โ โ โ
โผ โผ โผ โผ โผ
Parsing OCR Extraction Transcription Processing
โ โ โ โ โ
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโผโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
โผ
MULTIMODAL INDEXING
โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โผ โผ โผ
Text Index Image Index Structured Index
โ โ โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โผ
QUERY ANALYSIS
โ
โผ
MODALITY ROUTING
โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโ
โผ โผ โผ
Text Image Table
Retrieval Retrieval Retrieval
โ โ โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโ
โผ
CANDIDATE FUSION
โ
โผ
CROSS-MODAL RANKING
โ
โผ
EVIDENCE SELECTION
โ
โผ
CONTEXT ENGINEERING
โ
โผ
MULTIMODAL FOUNDATION MODEL
โ
โโโโโโโโโโโโดโโโโโโโโโโโ
โผ โผ
Validation Citation
โ โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โผ
ENTERPRISE RESPONSE
The central idea is:
Multimodal RAG preserves and retrieves knowledge in the form in which it actually exists, rather than forcing every enterprise artifact into plain text.
A mature enterprise architecture therefore becomes:
Enterprise Knowledge
โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโ
โผ โผ โผ
Documents Images Tables
โ โ โ
โผ โผ โผ
Vector Search Visual Search SQL
โ โ โ
โโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโดโโโโโโโโโโโโโ
โผ โผ
Knowledge Graph Other Sources
โ โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โผ
Evidence Fusion
โ
โผ
Context Engineering
โ
โผ
Multimodal Foundation Model
โ
โผ
Response Validation
โ
โผ
Citation / Attribution
โ
โผ
Enterprise Response
The important architectural principle is:
RIGHT KNOWLEDGE
โ
โผ
RIGHT MODALITY
โ
โผ
RIGHT RETRIEVER
โ
โผ
RIGHT EVIDENCE
โ
โผ
MULTIMODAL REASONING
โ
โผ
VALIDATED RESPONSE
Multimodal RAG is therefore not simply:
It is a broader retrieval architecture that combines:
Multimodal Ingestion
+
Layout Understanding
+
Modality-Specific Indexing
+
Cross-Modal Retrieval
+
Evidence Fusion
+
Multimodal Reasoning
+
Provenance
+
Validation
+
Security
+
Observability
This makes Multimodal RAG particularly valuable for enterprise applications involving technical documentation, architecture repositories, financial reports, invoices, contracts, product catalogs, dashboards, engineering documents, visual knowledge bases, and other domains where critical information exists outside plain text.
๐งญ Chapter Navigation¶
Part V โ Advanced Retrieval-Augmented Generation¶
Previous:
04. SQL RAG
Next:
06. Agentic RAG
Section:
05 โ Advanced RAG Architecture
Advanced RAG Architecture Path¶
01 Advanced RAG Architecture
โ
02 Graph RAG
โ
03 Knowledge Graphs for RAG
โ
04 SQL RAG
โ
05 Multimodal RAG
โ
06 Agentic RAG
Enterprise AI Engineering Handbook
Building Production-Grade Enterprise AI Systems โ One Chapter at a Time.