vdoc_rag / README.md
aditya9128
Update README and add comprehensive TESTING_GUIDE
148cf8e
|
Raw
History Blame Contribute Delete
4.97 kB
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:


πŸ’» 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

  1. Upload: PDF is processed with OCR and chunked into text segments
  2. Embed: Chunks are converted to vectors using Sentence-Transformers
  3. Index: Vectors are stored in ChromaDB for semantic search
  4. Query: User questions are embedded and matched against stored chunks
  5. Generate: Top matching chunks are sent to Gemini LLM for answer generation
  6. 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.