A production-ready Retrieval-Augmented Generation (RAG) system for intelligent question-answering over multiple PDF documents. Features hybrid retrieval (vector + keyword search), cross-encoder re-ranking, semantic chunking, and a Gradio web interface.
Architecture
Python
LLM
Model Description
This system implements an advanced RAG pipeline that combines multiple state-of-the-art techniques for optimal document retrieval and question answering:
Core Models Used
Component
Model
Purpose
Embeddings
BAAI/bge-large-en-v1.5
1024-dim normalized embeddings for semantic search
Open rag.ipynb in Jupyter Notebook or Google Colab
Run all cells sequentially
Enter your Groq API key in the Setup tab
Upload PDF documents
Ask questions in the Chat tab
Example Queries
python
1# Single Document Analysis2"What is the main contribution of this paper?"3"Explain the methodology in detail"4"What are the limitations mentioned by the authors?"56# Multi-Document Comparison7"Compare the approaches discussed in these papers"8"What are the key differences between the methodologies?"
Technical Specifications
Performance Benchmarks
Operation
Typical Duration
Model initialization
30-60 seconds
PDF ingestion (per doc)
10-30 seconds
Simple queries
5-8 seconds
Complex queries
10-15 seconds
Full document summary
30-90 seconds
Configuration Parameters
Parameter
Default
Description
max_chunk_size
1000
Maximum characters per semantic chunk
similarity_threshold
0.5
Cosine similarity for chunk grouping
chunk_size
800
Fallback text splitter chunk size
chunk_overlap
150
Character overlap between chunks
fetch_factor
2
Multiplier for initial retrieval pool
lambda_mult
0.6
MMR diversity parameter
cache_max_size
100
Maximum cached query responses
Limitations
Requires active internet connection for Groq API calls
PDF quality affects text extraction accuracy
Large documents may take longer to process
Query cache does not persist between sessions
Optimized for English language documents
Training Details
This is a retrieval system, not a trained model. It orchestrates pre-trained models:
Embeddings: Uses pre-trained BAAI/bge-large-en-v1.5 without fine-tuning
Re-ranker: Uses pre-trained BAAI/bge-reranker-v2-m3 without fine-tuning
LLM: Uses Llama 3.3 70B via Groq API with zero-shot prompting
Evaluation
The system was evaluated qualitatively on academic papers and technical documents for:
Answer relevance and accuracy
Source attribution correctness
Cross-document comparison quality
Response structure and readability
Environmental Impact
Hardware: Developed and tested on Google Colab (NVIDIA T4 GPU)
Inference: Primary compute via Groq API (cloud-hosted)
Local model loading: ~2GB VRAM for embeddings + re-ranker
Citation
bibtex
1@software{multi_doc_rag_system,
2 title = {Multi-Document RAG System},
3 year = {2024},
4 description = {Production-ready RAG system with hybrid retrieval and cross-encoder re-ranking},
5 url = {https://huggingface.co/your-username/your-repo}
6}