On-Demand Multimodal RAG: A Cost-Efficient Approach to Document Analysis with Selective Page Rendering

At a glance

ProblemTechnical PDFs keep key facts in diagrams, tables and equations. Text-only RAG loses them, OCR is slow, and sending the whole PDF to an LLM is very expensive.
IdeaSearch the text as usual, then turn only the few matching pages into images and send those to a multimodal LLM.
Result94.2% accuracy, 97.3% cheaper than sending the full document, 89.5% faster than OCR pipelines.
Tested onA 165-page metallurgy manual (47 diagrams, 23 tables) with 50 questions of 5 types
TechPyMuPDF, LangChain splitter, Google embedding-001, FAISS, Gemini 2.0 Flash, FastAPI, Streamlit, Docker
Published in2026 IEEE International Conference on Intelligent Electronics & Computational Systems (IECS)
Where & whenJuly 2026 · Bhopal, India
PublisherIEEE (2026)

How it works

  1. PDF
    text extracted with PyMuPDF
  2. Chunk + embed
    1000 chars, 200 overlap, page tagged
  3. Search
    FAISS top-3 chunks
  4. Pick pages
    unique page numbers
  5. Render
    only those pages, 150 DPI
  6. Answer
    Gemini 2.0 Flash reads the images

Key points

  • Indexing stays cheap: only the text is embedded, but every chunk remembers its page number
  • At question time the top 3 chunks point to a few pages; only those pages are rendered (150 DPI PNG)
  • The multimodal LLM sees the real page, so it can read the diagram, table or equation itself
  • Near full-document accuracy (94.2% vs 96.8%) at about 1/37th of the cost
  • Cost stays almost flat as documents grow: $0.012 to $0.018 per query from 50 to 2,000 pages

Results

Compared with other ways of doing it (50 questions)
ApproachAccuracyLatencyCost per query
On-Demand Multimodal RAG94.2%2.8 s$0.014
Text-only RAG67.4%1.9 s$0.003
OCR-based RAG78.6%26.7 s$0.048
Whole document to the LLM96.8%52.3 s$0.516
Hybrid88.2%31.4 s$0.124
Accuracy by question type
Question typeAccuracy
Text98%
Diagram93%
Table92%
Equation91%
Mixed (text + visuals)95%
Cost per query as the document grows
PagesThis approachWhole document
50$0.012$0.156
2,000$0.018$6.250

Architecture

Architecture diagram: On-Demand Multimodal RAG: A Cost-Efficient Approach to Document Analysis with Selective Page Rendering
More numbers and details
  • Latency split: 0.4 s retrieval, 0.6 s page rendering, 1.8 s LLM
  • Data sent per question: 0.8 MB instead of 28.4 MB for the whole document (97.2% less)
  • 10,000 questions on a 500-page document: about $160 instead of $15,630
  • 50 parallel questions finish in 8.4 s, against 142.7 s for the whole-document approach
  • Served through FastAPI (/chat, /health) with a Streamlit UI, packaged in Docker
  • Retrieval uses L2 distance in FAISS; embeddings are 768-dimensional
  • Generative AI
  • Multimodal RAG
  • Document AI
  • LLM Cost Optimization
  • Gemini
  • FAISS
All publications