Spaces:
Sleeping
Sleeping
|
Download README.md from EbiAraz/RAG-PDF-Project: direct link, hf CLI and curl.
- Browser
- Download file 5.94 kB
-
https://huggingface.co/spaces/EbiAraz/RAG-PDF-Project/resolve/main/README.md
- Command line
-
hf download hf://spaces/EbiAraz/RAG-PDF-Project/README.md
-
curl -L -o README.md https://huggingface.co/spaces/EbiAraz/RAG-PDF-Project/resolve/main/README.md
5.94 kB
A newer version of the Gradio SDK is available: 6.31.0
metadata
title: RAG PDF Assistant
emoji: π
colorFrom: blue
colorTo: indigo
sdk: gradio
app_file: app.py
pinned: true
RAG PDF Assistant
A production-ready Retrieval Augmented Generation (RAG) system for interactive PDF analysis and question answering using semantic search and large language models.
π Hosted on HuggingFace Spaces | π¦ Models from HuggingFace Hub | β‘ Production Ready
Live UI
Live app (running): Open RAG PDF Assistant
Space page: Hugging Face Space Repository
π― Features
- π€ PDF Upload - Upload any PDF or use the bundled sample
- π Smart Retrieval - FAISS-based vector similarity search over PDF content
- π€ AI-Powered Answers - FLAN-T5 language model generation (HuggingFace)
- π Multilingual Support - 100+ languages via multilingual embeddings
- β‘ Fast Performance - ~0.5-1 second per query after model load
- π¨ User-Friendly UI - Gradio web interface (no coding needed)
- β Production Ready - Full error handling, model caching, and validation
π Quick Start
Option 1: Local Installation
# Clone repository
git clone https://github.com/YOUR_USERNAME/rag_pdf_project.git
cd rag_pdf_project
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run the application
python app.py
Open your browser to: http://127.0.0.1:7860
Option 2: HuggingFace Spaces (Cloud)
- Create a new Gradio Space on HuggingFace
- Upload this repository
- The app will deploy automatically!
π Usage
Web UI (Recommended)
- Load PDF: Click "Use Default PDF" or upload your own
- Ask Questions: Type your question
- Get Answers: RAG-powered answers appear instantly
CLI Interface
python main.py
ποΈ Architecture
PDF Upload
β
PDF Loader (PyPDF)
β
Text Chunking (300-word chunks)
β
Embedding (HuggingFace: Multilingual-MiniLM, 384-dim)
β
FAISS Vector Index (L2 distance)
β
User Question
β
Query Embedding + Retrieval (Top-3 chunks)
β
Prompt Building
β
HuggingFace FLAN-T5 Generation (200 tokens max)
β
Answer Display
π Project Structure
rag_pdf_project/
βββ app.py # Gradio web UI
βββ main.py # CLI interface
βββ requirements.txt # Dependencies
βββ README.md # This file
βββ .gitignore # Git configuration
β
βββ configs/
β βββ settings.py # Model & parameter config
β
βββ data/documents/
β βββ 1.pdf # Sample PDF
β
βββ ingestion/ # PDF processing
β βββ build_index.py
β βββ pdf_loader.py
β βββ chunker.py
β
βββ retrieval/ # Vector search
β βββ embedder.py
β βββ retriever.py
β βββ vector_store.py
β
βββ generation/ # Answer generation
β βββ llm.py
β βββ prompt_builder.py
β
βββ pipeline/
βββ rag_pipeline.py
π§ Configuration
Edit configs/settings.py:
# HuggingFace Embedding Model
EMBED_MODEL = 'paraphrase-multilingual-MiniLM-L12-v2'
# HuggingFace Generation Model
GEN_MODEL = 'google/flan-t5-small'
# Chunking
CHUNK_SIZE = 300 # words
# Retrieval
TOP_K = 3 # chunks
# Generation
MAX_NEW_TOKENS = 200 # tokens
π€ HuggingFace Integration
Models Used
| Component | Model | Source |
|---|---|---|
| Embedding | paraphrase-multilingual-MiniLM-L12-v2 |
SentenceTransformers |
| Generation | google/flan-t5-small |
|
| Tokenizer | Auto | HuggingFace |
Deploy to HuggingFace Spaces
# 1. Login to HuggingFace
huggingface-cli login
# 2. Create Space
huggingface-cli repo create rag-pdf-assistant --type space --space-sdk docker
# 3. Push code
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/rag-pdf-assistant
git push hf main
π Performance
| Metric | Value |
|---|---|
| First Query | 1.5-2 seconds |
| Subsequent Queries | 0.5-1 second |
| Model Size | ~2GB |
| Memory Usage | 4-6GB |
π§ͺ Testing
python app.py
# Click "Use Default PDF"
# Ask: "What is this document about?"
π Documentation
- QUICK_START.md - Basic usage
- TECHNICAL_DOCS.md - Deep architecture
- EXAMPLES_AND_TESTS.md - Examples & debugging
π¦ Dependencies
- transformers - HuggingFace T5 models
- sentence-transformers - Multilingual embeddings
- faiss-cpu - Vector search
- pypdf - PDF extraction
- gradio - Web UI
- numpy - Numerical computing
π Deployment
Local
python app.py
Docker
FROM python:3.10
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]
HuggingFace Spaces β
Just push to HuggingFace!
π License
MIT License
π Acknowledgments
- HuggingFace - Models and transformers
- Facebook Research - FAISS
- Google - FLAN-T5
- SentenceTransformers - Embeddings
- Gradio - Web interfaces
Built with β€οΈ using HuggingFace models
Made with Transformers β’ SentenceTransformers β’ FAISS β’ Gradio