metadata
title: VDoc-RAG
emoji: π
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
π VDoc-RAG (Visually-Rich Document Retrieval-Augmented Generation)
VDoc-RAG is an intelligent document Q&A system that answers questions from PDFs, resumes, reports, and other visually-rich documents using RAG (Retrieval-Augmented Generation) technology.
π Live Demo: https://huggingface.co/spaces/adi9128/vdoc_rag
β¨ Key Features
| Feature | Description |
|---|---|
| π€ Document Upload | Upload PDF files for instant processing |
| π Smart Q&A | Ask natural language questions about your documents |
| π§ RAG Pipeline | Retrieval-Augmented Generation with ChromaDB vector store |
| π OCR + Table/Chart Extraction | Tesseract OCR with visual element detection |
| π― Confidence Scoring | Cosine similarity scores for retrieved chunks |
| π Feedback System | Mark answers as correct/incorrect for improvement |
| π Document Isolation | Each upload clears previous data for privacy |
| π¨ Modern UI | Clean gradient design with responsive layout |
π Live Deployment
The app is deployed on HuggingFace Spaces using Docker:
- URL: https://huggingface.co/spaces/adi9128/vdoc_rag
- SDK: Docker (Python 3.11)
- Port: 7860
π» Local Development
Prerequisites
Install these tools and add them to PATH:
Setup
# Clone the repository
git clone https://github.com/YOUR_USERNAME/vdoc-rag.git
cd vdoc-rag
# Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/Mac
# Install dependencies
pip install -r requirements.txt
# Set environment variables
# Create .env file with:
GEMINI_API_KEY=your_gemini_api_key_here
# Run the server
uvicorn app.main:app --host 127.0.0.1 --port 8000
Open β http://127.0.0.1:8000
π₯οΈ Web Interface
| Route | Description |
|---|---|
/ |
Main interface - Upload documents & ask questions |
/feedback_dashboard |
View feedback statistics |
/benchmark_dashboard |
Embedding model evaluation metrics |
π Project Structure
vdoc-rag/
βββ app/
β βββ main.py # FastAPI server & routes
β βββ indexer.py # ChromaDB vector store wrapper
β βββ embeddings.py # Sentence-transformer embeddings
β βββ ingest.py # PDF processing & OCR
β βββ reader.py # LLM (Gemini) integration
β βββ chart_reasoner.py # Chart/graph understanding
β βββ feedback_manager.py # User feedback collection
β βββ visual_highlight.py # PDF region highlighting
β βββ cache_manager.py # Response caching
β βββ templates/ # HTML templates
β βββ index.html
β βββ feedback_dashboard.html
β βββ benchmark_dashboard.html
βββ Dockerfile # HuggingFace Spaces deployment
βββ requirements.txt # Python dependencies
βββ TESTING_GUIDE.md # Step-by-step testing guide
βββ README.md
π§ Technology Stack
| Component | Technology |
|---|---|
| Backend | FastAPI + Uvicorn |
| Vector Database | ChromaDB (persistent) |
| Embeddings | Sentence-Transformers (all-MiniLM-L6-v2) |
| LLM | Google Gemini API |
| OCR | Tesseract + Poppler |
| PDF Processing | pdf2image + PyMuPDF |
| Frontend | Jinja2 + TailwindCSS |
| Deployment | Docker on HuggingFace Spaces |
π Privacy & Document Isolation
- Stateless Design: Each page refresh shows a clean interface
- Document Isolation: Uploading a new document clears all previous data
- No Persistent User Tracking: Documents are processed in-memory per session
- Shared Instance Note: HuggingFace free tier uses a single server instance
π How It Works
- Upload: PDF is processed with OCR and chunked into text segments
- Embed: Chunks are converted to vectors using Sentence-Transformers
- Index: Vectors are stored in ChromaDB for semantic search
- Query: User questions are embedded and matched against stored chunks
- Generate: Top matching chunks are sent to Gemini LLM for answer generation
- Display: Answer with confidence scores and source attribution
π§ͺ Testing
See TESTING_GUIDE.md for step-by-step instructions.
π¨βπ» Author
Made with β€οΈ by Aditya
π License
This project is open source and available for educational and research purposes.