CoolFace
Apppublic

RathnavelRahul/omni-modal-rag

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

πŸš€ Omni-Modal RAG System

<div align="center">

Python Next.js FastAPI License

An intelligent document analysis system powered by AI that can process PDFs, images, and audio files to answer your questions.

Live Demo β€’ Features β€’ Quick Start β€’ Architecture

</div>


πŸ“‹ Table of Contents


🎯 About

Omni-Modal RAG is a Retrieval-Augmented Generation system that enables intelligent document analysis across multiple modalities. Upload documents, images, or audio files, and ask questions in natural language to get accurate, AI-powered answers.

What makes it special?

  • β€”Multi-modal support: Process PDFs, images (with OCR), and audio files
  • β€”Hybrid search: Combines semantic embeddings + keyword search + knowledge graph
  • β€”Real-time streaming: See AI responses as they're generated
  • β€”Clean, structured answers: Bullet-point format for easy reading

✨ Features

FeatureDescription
πŸ“„ PDF ProcessingExtract and analyze text from PDF documents
πŸ–ΌοΈ Image OCRExtract text from images using Tesseract
🎡 Audio TranscriptionTranscribe audio using OpenAI Whisper
πŸ” Hybrid SearchVector + keyword + knowledge graph retrieval
πŸ’¬ Streaming ChatReal-time AI responses with SSE
πŸ“Š Knowledge GraphEntity extraction and relationship mapping
🎨 Modern UIBeautiful dark-themed React interface

πŸ› οΈ Tech Stack

Backend

  • β€”FastAPI - High-performance async Python API
  • β€”LangChain - LLM orchestration
  • β€”FAISS - Vector similarity search
  • β€”spaCy - NLP and entity extraction
  • β€”Tesseract - OCR for images
  • β€”Whisper - Audio transcription
  • β€”NetworkX - Knowledge graph

Frontend

  • β€”Next.js 14 - React framework
  • β€”TypeScript - Type-safe JavaScript
  • β€”Tailwind CSS - Utility-first styling
  • β€”Lucide Icons - Beautiful icons

AI Models

  • β€”Qwen2.5-72B-Instruct - LLM for response generation
  • β€”all-MiniLM-L6-v2 - Text embeddings

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Frontend (Next.js)                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  Upload  β”‚  β”‚   Chat   β”‚  β”‚ Sidebar  β”‚  β”‚  Message Display β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚ HTTP/SSE
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Backend (FastAPI)                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚                      API Routes                             β”‚ β”‚
β”‚  β”‚   /upload  β”‚  /chat  β”‚  /files  β”‚  /feedback               β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                              β”‚                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                    Processing Pipeline                     β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚   PDF    β”‚  β”‚  Image   β”‚  β”‚  Audio   β”‚  β”‚  Chunking β”‚  β”‚  β”‚
β”‚  β”‚  β”‚ Extractorβ”‚  β”‚   OCR    β”‚  β”‚ Whisper  β”‚  β”‚  & Index  β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                              β”‚                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                   Retrieval System                         β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚  Vector  β”‚  β”‚ Keyword  β”‚  β”‚Knowledge β”‚  β”‚   HyDE    β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  Store   β”‚  β”‚  Search  β”‚  β”‚  Graph   β”‚  β”‚ Generator β”‚  β”‚  β”‚
β”‚  β”‚  β”‚ (FAISS)  β”‚  β”‚  (BM25)  β”‚  β”‚(NetworkX)β”‚  β”‚           β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                              β”‚                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                    LLM Integration                         β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚  β”‚
β”‚  β”‚  β”‚  Agent Orchestrator β”‚  β”‚  HuggingFace API Client   β”‚   β”‚  β”‚
β”‚  β”‚  β”‚    (ReAct Loop)     β”‚  β”‚   (Qwen2.5-72B-Instruct)  β”‚   β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow

User Query β†’ Hybrid Retrieval β†’ Context Assembly β†’ LLM Generation β†’ Response
     ↓              ↓                  ↓                ↓              ↓
  "What is X?"   Vector+BM25      Top-K chunks     Qwen2.5-72B    Bullet points
                + Graph Walk      + Related         + Prompt       + Clean format

πŸš€ Quick Start

Prerequisites

  • β€”Python 3.10+
  • β€”Node.js 18+
  • β€”Git
  • β€”Tesseract OCR (for image processing)

1. Clone the Repository

bash
git clone https://github.com/YOUR_USERNAME/omni-modal-rag.git
cd omni-modal-rag

2. Backend Setup

bash
# Navigate to backend
cd backend

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Download spaCy model
python -m spacy download en_core_web_sm

# Create .env file
cp .env.example .env
# Edit .env and add your HUGGINGFACE_API_KEY

3. Get HuggingFace API Key

  1. 1.Go to huggingface.co/settings/tokens
  2. 2.Create a new token with "Read" permissions
  3. 3.Copy the token to your .env file

4. Frontend Setup

bash
# Navigate to frontend
cd ../frontend

# Install dependencies
npm install

5. Run the Application

Terminal 1 - Backend:

bash
cd backend
python -m uvicorn main:app --reload --port 8000

Terminal 2 - Frontend:

bash
cd frontend
npm run dev

Open http://localhost:3000 in your browser!


🐳 Docker Deployment

Manual Deployment

For detailed instructions on pushing to GitHub and deploying to the cloud (Railway/Render), please see our Deployment Guide.

Using Docker Compose (Local)

bash
# Build and run
docker-compose up --build

# Run in background
docker-compose up -d

Manual Docker Build

bash
# Build backend
docker build -t omni-rag-backend ./backend

# Build frontend
docker build -t omni-rag-frontend ./frontend

# Run containers
docker run -d -p 8000:8000 --env-file .env omni-rag-backend
docker run -d -p 3000:3000 omni-rag-frontend

πŸ“‘ API Reference

Upload File

http
POST /api/upload
Content-Type: multipart/form-data

file: <binary>

Chat (Streaming)

http
POST /api/chat
Content-Type: application/json

{
  "message": "What are the key findings?",
  "session_id": "optional-session-id"
}

List Files

http
GET /api/files

Delete File

http
DELETE /api/files/{file_id}

βš™οΈ Configuration

Environment Variables

VariableDescriptionDefault
HUGGINGFACE_API_KEYHuggingFace API tokenRequired
HF_MODEL_IDLLM model to useQwen/Qwen2.5-72B-Instruct
EMBEDDING_MODELEmbedding modelsentence-transformers/all-MiniLM-L6-v2
MAX_FILE_SIZE_MBMax file upload size10
PORTBackend port8000

πŸ“ Project Structure

omni-modal-rag/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ agents/           # LLM orchestration
β”‚   β”œβ”€β”€ graph/            # Knowledge graph
β”‚   β”œβ”€β”€ ingestion/        # Document processing
β”‚   β”œβ”€β”€ llm/              # LLM client
β”‚   β”œβ”€β”€ retrieval/        # Search & retrieval
β”‚   β”œβ”€β”€ routes/           # API endpoints
β”‚   β”œβ”€β”€ synthesis/        # Response building
β”‚   β”œβ”€β”€ utils/            # Utilities
β”‚   β”œβ”€β”€ main.py           # FastAPI app
β”‚   β”œβ”€β”€ config.py         # Configuration
β”‚   └── requirements.txt  # Python dependencies
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/              # Next.js pages
β”‚   β”œβ”€β”€ components/       # React components
β”‚   β”œβ”€β”€ types/            # TypeScript types
β”‚   └── package.json      # Node dependencies
β”‚
β”œβ”€β”€ docker-compose.yml    # Docker orchestration
β”œβ”€β”€ Dockerfile            # Multi-stage build
└── README.md             # This file

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. 1.Fork the repository
  2. 2.Create your feature branch (git checkout -b feature/AmazingFeature)
  3. 3.Commit your changes (git commit -m 'Add some AmazingFeature')
  4. 4.Push to the branch (git push origin feature/AmazingFeature)
  5. 5.Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘€ Author

Arman Shalik J


<div align="center">

⭐ If you found this project helpful, please give it a star! ⭐

</div>