Building AI Agents with Multimodal Models: Part 3

Search for a command to run...

No comments yet. Be the first to comment.
Notes from my certification - Building AI Agents with Multimodal Models from Nvidia deep learning institute
Video Understanding & Graph-RAG: AI That Watches, Remembers, and Reasons This is Part 4 (Final) of a 4-part series based on learnings from NVIDIA's "Building AI Agents with Multimodal Models" certification. The Final Frontier: Understanding Video We...
Language models can answer medical questions with surprising accuracy. But do they actually encode medical knowledge in identifiable, interpretable ways? Or is it all just statistical soup? Using Neuronpedia, we ran a simple experiment to find out. W...

When a medical Vision Language Model(VLM) looks at a chest X-ray and says "cardiomegaly present," what's actually happening inside the model? It's a black box. Billions of parameters. Dense activation vectors where every dimension encodes a tangled m...

Off late a lot of my research time is studying why medical models systems fail. Not the obvious failures where the model outputs gibberish, but the subtle ones where the output looks clinically appropriate, follows proper documentation structure, use...

When a doctor examines a chest X-ray and says "I see signs of pneumonia in the lower right lung," you can ask them to point at exactly what they're seeing. They can circle the cloudy region, explain why it looks abnormal, and walk you through their r...

Data does not just appear. Something creates it. A coin flip. A measurement device. A biological process. A human decision. Understanding that something, the mechanism that generates observations, is the key to understanding uncertainty. This mechani...
On this page
This is Part 3 of a 4-part series based on learnings from NVIDIA's "Building AI Agents with Multimodal Models" certification.
Think about a typical business document. It might have:
For humans, navigating this is intuitive. But for AI, a PDF is just a jumble of pixels or raw text blobs with no inherent structure. Teaching AI to extract meaningful information from documents is one of the most practical applications of multimodal AI.
This is where Optical Character Recognition (OCR) meets Retrieval Augmented Generation (RAG) to create intelligent document processing systems.
The Analogy: Imagine you're teaching a child to read. First, they learn to recognize individual letters. Then words. Then sentences. Eventually, they understand that text flows in certain directions and formats.
Optical Character Recognition follows a similar journey:
Modern OCR goes far beyond simple text extraction. It understands document structure.
NVIDIA's training demonstrates a comprehensive pipeline for extracting multimodal data from PDFs. Let's break it down.
Before extracting content, you need to identify what's in the document.
The Analogy: Before renovating a house, you walk through each room and catalog what's there. "Living room has a couch, TV, and bookshelf. Kitchen has appliances and a dining table."
Document partitioning creates an inventory of elements:
Tools like the unstructured library do this automatically, identifying element types and their locations.
Once you have text, you need to break it into digestible pieces for the AI. But how you chunk matters enormously.
Naive Chunking (Bad Approach): Split text every 500 characters regardless of content.
Problem: You might split a sentence mid-thought, separate a header from its content, or break apart related concepts.
Chunk 1: "The quarterly revenue reached $5.2 million, an increase of 23%"
Chunk 2: "compared to the previous quarter. Key drivers included..."
Semantic Chunking (Better Approach): Split at natural boundaries like titles, section breaks, or paragraph endings.
Chunk 1: [Header: Financial Results]
"The quarterly revenue reached $5.2 million, an increase of 23%
compared to the previous quarter."
Chunk 2: [Header: Key Drivers]
"Key drivers included expanded market presence and new product
launches in the enterprise segment..."
The semantic approach preserves meaning and context. When the AI retrieves this chunk later, it gets complete thoughts.
Tables are notoriously tricky. They encode relationships through spatial position, not linear text.
The Challenge:
| Product | Q1 Sales | Q2 Sales |
|---------|----------|----------|
| Widget | $50,000 | $65,000 |
| Gadget | $30,000 | $45,000 |
If you just extract text left-to-right, you get: "Product Q1 Sales Q2 Sales Widget $50,000 $65,000..."
This loses all the relational information. Which number belongs to which product?
The Solution: Use specialized table extraction models that understand grid structure. NVIDIA's pipeline uses models like Microsoft's Table Transformer to:
The extracted HTML preserves structure:
<table>
<tr><td>Product</td><td>Q1 Sales</td><td>Q2 Sales</td></tr>
<tr><td>Widget</td><td>$50,000</td><td>$65,000</td></tr>
</table>
Documents often contain figures that carry critical information.
The Approach:
This enables queries like "Show me all the architecture diagrams in this documentation."
Now you've extracted all this content. How do you make it useful?
The Analogy: Imagine you're a researcher with a library of 10,000 books. When someone asks you a question, you don't read all 10,000 books. You:
RAG does exactly this with AI.
User Question
│
▼
┌─────────────┐
│ Embedding │ ← Convert question to vector
└─────────────┘
│
▼
┌─────────────┐
│ Retrieval │ ← Find similar chunks in vector database
└─────────────┘
│
▼
┌─────────────┐
│ Context │ ← Combine retrieved chunks
└─────────────┘
│
▼
┌─────────────┐
│ LLM │ ← Generate answer using context
└─────────────┘
│
▼
Answer
Take all your extracted chunks and convert them to embeddings:
Chunk 1 ──> [Encoder] ──> [0.2, 0.8, 0.1, ...]
Chunk 2 ──> [Encoder] ──> [0.5, 0.3, 0.9, ...]
Chunk 3 ──> [Encoder] ──> [0.1, 0.7, 0.4, ...]
...
Store these embeddings in a vector database like Milvus, Pinecone, or FAISS.
When a user asks a question:
question = "What was Q2 revenue?"
question_embedding = encoder.encode(question)
similar_chunks = vector_db.search(question_embedding, k=5)
Feed the retrieved context plus the question to an LLM:
Context: [Retrieved chunks about Q2 revenue]
Question: What was Q2 revenue?
Answer: Based on the financial report, Q2 revenue was $65,000 for
the Widget product line and $45,000 for Gadgets, totaling $110,000.
The LLM generates an answer grounded in your actual documents, not its training data.
For intelligent document analysis, you need to detect where different elements are located.
The Model: NVIDIA provides specialized models like nv-yolox-page-elements trained specifically for document analysis.
What It Detects:
How It Works:
Page Image ──> [YOLOX Model] ──> Detected Regions:
• Table at (100, 200, 500, 400) - Confidence: 0.95
• Chart at (100, 450, 500, 650) - Confidence: 0.89
• Title at (50, 50, 400, 80) - Confidence: 0.97
This enables intelligent routing: text goes to OCR, tables go to table extractors, charts go to visual analysis models.
Real documents can be hundreds of pages. Processing all at once is impractical.
The Solution: Batch processing with memory management.
# Process in batches of 10 pages
for start_page in range(0, total_pages, 10):
end_page = min(start_page + 10, total_pages)
batch = extract_pages(document, start_page, end_page)
process_batch(batch)
save_results(batch)
clear_memory() # Prevent memory overflow
Each batch is processed independently, results are saved, and memory is cleared before the next batch.
Let's walk through processing NVIDIA's Grace-Blackwell datasheet (a real example from the training):
Input: 20-page PDF with specifications, architecture diagrams, and performance tables
Processing Steps:
Result: System retrieves relevant table chunks and generates accurate answer with source citations.
Document processing is inherently multimodal: Text, tables, images all carry information
Smart chunking preserves meaning: Semantic boundaries beat arbitrary character limits
Tables need special handling: Spatial structure encodes relationships that linear text loses
Object detection enables routing: YOLOX identifies what's where so appropriate extractors can be used
RAG grounds AI in your data: Retrieved context prevents hallucination and enables factual answers
Batch processing handles scale: Process large documents in manageable chunks to control memory
In Part 4, we'll explore the most exciting frontier: Video Understanding and Graph-RAG. You'll learn how AI can watch, understand, and answer questions about video content, and how knowledge graphs enable complex reasoning that simple vector search cannot achieve.
This content is inspired by NVIDIA's Deep Learning Institute course: Building AI Agents with Multimodal Models. For hands-on experience, consider enrolling in their official courses.