Cortex automatically extracts and analyzes images from uploaded documents, making visual content searchable through RAG queries.
Overview
The image analysis system:
- Extracts images from PDF, DOCX, PPTX, XLSX, and image files
- Analyzes content using configurable vision models
- Makes images searchable through semantic search
- Integrates with RAG for comprehensive answers
Configuration
Enable Vision Model (Optional)
Add vision model configuration to your .env file:
Code
Without Vision Model
If no vision model is configured, the system uses:
- Docling descriptions - Built-in image analysis using SmolDocling (enabled by default)
- Basic metadata - Page numbers and captions
Images are still extracted and searchable, but with less detail.
Supported Vision Models
| Provider | Model | Configuration |
|---|---|---|
| OpenAI | GPT-4o | VISION_MODEL=gpt-4o |
| Anthropic | Claude 3.5 | VISION_MODEL=claude-3-5-sonnet-20241022 |
| Local | LLaVA | VISION_MODEL=llava via Ollama |
| Custom | Any | OpenAI-compatible API |
OpenAI GPT-4 Vision
Code
Anthropic Claude
Code
Local Models (Ollama)
Code
Custom Endpoints
Any OpenAI-compatible vision API:
Code
Supported File Types
Images are extracted from:
- PDF - Embedded images, charts, diagrams
- DOCX - Word document images
- PPTX - PowerPoint images
- XLSX - Excel images
- Images - PNG, JPG, JPEG, TIFF, BMP
How It Works
Processing Flow
Code
Image analysis runs asynchronously after text processing completes. A document may show status: "completed" while images are still being analyzed. Progress is tracked per-document via image_progress_current/image_progress_total fields. The Knowledge Graph pipeline (Manage → Knowledge Graph → Step 1) is aware of this — it treats documents with pending image analysis as still in-progress, showing an aggregate progress bar and blocking advancement to relationship analysis until all images are processed.
Integration with RAG
Image analyses are automatically:
- Searchable - Via semantic search
- Cited - In RAG responses with source references
- Contextual - Included in answer generation
Example query:
Code
Response includes image analyses:
Code
Usage
Upload Documents
Upload documents as usual - images are processed automatically:
Code
Query for Image Content
Ask questions about visual content:
Code
Search Images Directly
Search across all image analyses:
Code
Analysis Methods
The system uses three analysis methods:
1. Vision Model
When configured, provides detailed analysis:
- Object identification
- Text extraction (OCR)
- Chart/diagram interpretation
- Context understanding
Example output:
Code
2. Docling Description
Built-in descriptions generated during document conversion:
- Basic image classification
- Simple descriptions
- Fast and free
- Always enabled (via
do_picture_description=True)
Example output:
Code
3. Fallback
Basic metadata when other methods unavailable:
- Page number
- Caption (if present)
Example output:
Code
Programmatic Access
Python Example
Code
Extract Images to Disk
Code
Troubleshooting
No Images Extracted
Problem: No images found in document
Solutions:
- Verify document contains embedded images (not vector graphics)
- Check if images are rendered as text/shapes
- Ensure document conversion succeeds
Vision API Errors
Problem: Vision model returns errors
Solutions:
- Verify API key is valid
- Check API endpoint URL
- Confirm model name is correct
- Review API quotas and rate limits
- Check image size limits (usually ~20MB)
Poor Descriptions
Problem: Image descriptions lack detail
Solutions:
- Use more capable vision model (GPT-4o, Claude 3.5)
- Customize analysis prompt (advanced)
- Ensure images are clear and high-resolution
- Check for image corruption
Slow Processing
Problem: Image analysis takes too long
Solutions:
- Increase
VISION_MAX_CONCURRENT(default 2) to process more images in parallel — but note each in-flight image spawns a multi-call chain, and provider concurrent-request limits are usually the binding constraint - Use a faster vision model
- Reduce image resolution before upload
- Consider local vision model (Ollama/LLaVA)
Performance Considerations
Processing Time
- Each image adds 2-5 seconds processing time
- Depends on vision model response time
- Images within a document are processed concurrently (controlled by
VISION_MAX_CONCURRENT, default 2)
API Costs
Vision model usage incurs costs:
- OpenAI GPT-4o: ~$0.01-0.03 per image
- Claude 3.5: ~$0.003-0.015 per image
- Local models: Free (but requires GPU)
Optimization Tips
- Use Docling descriptions for simple images
- Process only necessary documents with vision model
- Consider batch processing during low-usage periods
Advanced Configuration
Custom Analysis Prompts
Modify the analysis prompt in vision_analyzer.py:
Code
Pipeline Options
Docling is configured with image description enabled by default:
Code
This enables Docling's built-in vision model (SmolDocling) to generate image descriptions during conversion.
Best Practices
Document Preparation
- Use high-resolution images when possible
- Ensure text in images is legible
- Include descriptive captions in documents
Vision Model Selection
- GPT-4o: Best for complex charts, diagrams, mixed content
- Claude 3.5: Excellent for text extraction and detailed descriptions
- Local models: Good for privacy-sensitive or cost-conscious use cases
Query Formulation
Ask specific questions about visual content:
- ✅ "What does the revenue trend chart show?"
- ✅ "Explain the architecture diagram"
- ✅ "What are the key findings in the scatter plot?"
- ❌ "Tell me about the document"
Related Guides
- Document Processing - How documents are converted and chunked
- RAG Queries - Querying your knowledge base
- Configuration - System configuration options