CoolFace
Apppublic

dev-models/MultiModel-Rag

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
App README

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

πŸ€– Multimodal RAG Assistant (Docling-Powered)

![Python](https://www.python.org/) ![Streamlit](https://streamlit.io/) ![Docling](https://github.com/DS4SD/docling) ![MongoDB](https://www.mongodb.com/products/platform/atlas-vector-search) ![Groq](https://groq.com/)

A state-of-the-art Multimodal Retrieval-Augmented Generation (RAG) system built for the modern document era. This assistant doesn't just read textβ€”it understands tables, charts, diagrams, and complex layouts using IBM's Docling and Visual Language Models.


πŸš€ The WOW Factor

  • β€”πŸ§  Deep Document Intelligence: Powered by Docling, the system extracts semantic structures (headers, tables, lists) with extreme precision.
  • β€”πŸ‘οΈ Visual Understanding: Every image in your PDF is "seen" by a VLM (Llama-3-Vision) to generate rich textual descriptions for vector indexing.
  • β€”πŸ” Hybrid Search Engine: A high-performance retrieval pipeline combining CLIP (Dense) and BM25 (Sparse) to ensure zero-miss retrieval.
  • β€”πŸ–ΌοΈ Visual RAG Capabilities: Directly query for charts or diagrams. The assistant "shows" you the relevant visuals alongside textual answers.
  • β€”πŸ’‘ Intelligent Query Guidance: Automatically analyzes document structure to suggest the most relevant questions for the user.
  • β€”βš‘ Blazing Fast Generation: Uses Groq's Llama-3.3-70B for near-instant, high-quality responses with full streaming support.

πŸ› οΈ Architecture Overview

The system is built on a modular, production-ready foundation:

text
rag-app/
β”œβ”€β”€ 🌐 app.py              # Streamlit Premium Interface
β”œβ”€β”€ βš™οΈ config.py           # Centralized configuration
β”œβ”€β”€ πŸ“¦ backend/            # Domain-driven modules
β”‚   β”œβ”€β”€ πŸ› οΈ parser.py       # Docling Engine + VLM Describer
β”‚   β”œβ”€β”€ 🧠 rag.py          # Hybrid Search + RAG Orchestrator
β”‚   β”œβ”€β”€ πŸ’Ύ database.py     # MongoDB Atlas Vector Store integration
β”‚   └── πŸ€– models.py       # CLIP, LLM, and VLM Connectors
β”œβ”€β”€ πŸ“ rag_data/           # Parsed JSON persistence
β”œβ”€β”€ 🐳 Dockerfile          # Multi-stage optimized build
└── πŸ“‹ requirements.txt    # Optimized dependency tree

πŸ—οΈ Core Technology Stack

LayerTechnologyPurpose
ParsingDoclingHigh-fidelity PDF structural parsing & OCR
VLMGroq (Llama-4-Scout)Image captioning for multimodal indexing
EmbeddingsCLIP (ViT-L/14)Joint Text-Image vector space
Vector DBMongoDB AtlasScalable vector search & metadata storage
LLMLlama-3.3-70BFinal answer generation (via Groq)
UIStreamlitModern, responsive chat interface

🚦 Getting Started

1. Prerequisites

2. Configure Environment

Create a .env file in the root directory:

env
# MongoDB Credentials
MONGO_USER=your_username
MONGO_PASSWORD=your_password
MONGO_HOST=your_cluster_url.mongodb.net
MONGO_DB=rag_assistant

# API Keys
GROQ_API_KEY=gsk_your_key_here

# Optional: Full URI (overrides components above)
# MONGO_URI=mongodb+srv://...

3. Quick Run (Docker)

bash
docker compose up --build

4. Local Setup

bash
# Install dependencies
pip install -r requirements.txt

# Launch app
streamlit run app.py

πŸ“ˆ Search Optimization

  • β€”Dense Retrieval (CLIP): Captures semantic meaning and visual similarity.
  • β€”Sparse Retrieval (BM25): Ensures keyword matches (names, technical terms) are never missed.
  • β€”Hybrid Weighting: Fine-tuned alpha parameter balances the two search methods for optimal precision-recall.

πŸ›‘οΈ Security & Scalability

  • β€”Safe Parsing: Docling runs in a secure, resource-limited container environment.
  • β€”Vector Search Indexing: Optimized for MongoDB Atlas Search, enabling enterprise-grade scaling.
  • β€”Streaming Responses: Uses Server-Sent Events (SSE) logic for smooth user experience.