Overview
This pipeline goes beyond standard text-only RAG — it is multimodal, meaning it can read, understand, and search through images, charts, and tables found inside PDF documents, by turning unsearchable pixels into searchable concepts before anything gets embedded.
Pipeline Architecture
The system runs in four distinct phases:
- Ingestion & Parsing (Unstructured.io) —
partition_pdf(strategy="hi_res")breaks the document into elements, separating raw text, HTML-converted tables, and base64-encoded images. - AI Vision Summarization (OpenAI) — Any chunk containing an image or table is routed to
gpt-4o-mini, which writes a detailed text description of what it sees. This description replaces the image in the pipeline entirely. - Embedding & Indexing (Cohere + ChromaDB) — Raw text and the generated image descriptions are embedded with Cohere's
embed-english-v3.0(optimized for semantic search) and persisted to a local ChromaDB store. - Retrieval & Chat (Groq) — On a user question, the system retrieves the top 3-5 relevant chunks from ChromaDB and passes the pre-processed text (never raw images) to Groq's
llama-3.3-70b-versatilefor a fast, conversational answer.
Key Features
- Zero-Latency Persistence: Because visual processing results are saved to ChromaDB, a PDF is only ever visually processed once — reopening a database for chat requires no re-scanning.
- Triple-Cloud Cost Optimization: Each provider is used for exactly what it's best (and cheapest) at — vision, embeddings, and chat are deliberately split across three different APIs rather than over-relying on one expensive model for everything.
- Rate-Limit Protection: Built-in
time.sleepsafeguards prevent token exhaustion (HTTP 429) when batch-processing large documents.