YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

πŸ” Advanced RAG Research Assistant

Production-grade Retrieval-Augmented Generation with hybrid retrieval, graph-based reasoning, and rigorous evaluation

πŸ”¬ What This Project Does

A 3-tier RAG system that goes far beyond basic "vector search β†’ LLM" tutorials:

Tier What It Does How It's Different
Tier 1: Basic Dense vector search β†’ LLM Baseline (what tutorials teach)
Tier 2: Hybrid BM25 + Dense + RRF fusion + Cross-encoder reranking β†’ LLM Production-grade retrieval
Tier 3: Graph LightRAG knowledge graph + multi-hop reasoning β†’ LLM Research-grade, multi-hop Q&A

All three tiers are evaluated with RAGAS metrics to prove the improvements aren't just theoretical.

πŸ“Š Results (RAGAS Evaluation)

Metric Tier 1 (Basic) Tier 2 (Hybrid) Tier 3 (Graph)
Faithfulness ~X.XX ~X.XX ~X.XX
Answer Relevancy ~X.XX ~X.XX ~X.XX
Context Recall ~X.XX ~X.XX ~X.XX
Context Precision ~X.XX ~X.XX ~X.XX

(Fill in after running evaluation β€” these numbers go in your resume!)

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Advanced RAG Pipeline                          β”‚
β”‚                                                                   β”‚
β”‚  πŸ“„ Documents                                                     β”‚
β”‚   β”‚                                                               β”‚
β”‚   β”œβ”€β”€β–Ά πŸ”€ Chunking (recursive, 512 tokens, 50 overlap)          β”‚
β”‚   β”‚                                                               β”‚
β”‚   β”œβ”€β”€β–Ά πŸ“Š TIER 1: Dense Retrieval                                β”‚
β”‚   β”‚    └── BGE-small embeddings β†’ FAISS index β†’ Top-K            β”‚
β”‚   β”‚                                                               β”‚
β”‚   β”œβ”€β”€β–Ά πŸ“Š TIER 2: Hybrid Retrieval                               β”‚
β”‚   β”‚    β”œβ”€β”€ BM25 (sparse) ──┐                                     β”‚
β”‚   β”‚    β”œβ”€β”€ BGE (dense) ─────── RRF Fusion β†’ Cross-encoder β†’ Top-Kβ”‚
β”‚   β”‚    └── Reciprocal Rank Fusion                                 β”‚
β”‚   β”‚                                                               β”‚
β”‚   └──▢ πŸ“Š TIER 3: Graph Retrieval (LightRAG)                    β”‚
β”‚        β”œβ”€β”€ Entity Extraction β†’ Knowledge Graph                    β”‚
β”‚        β”œβ”€β”€ Local queries (specific entities)                      β”‚
β”‚        β”œβ”€β”€ Global queries (abstract themes)                       β”‚
β”‚        └── Hybrid mode (best of both)                             β”‚
β”‚                                                                   β”‚
β”‚  ❓ Query                                                         β”‚
β”‚   β”‚                                                               β”‚
β”‚   β”œβ”€β”€β–Ά Retrieve relevant contexts (any tier)                     β”‚
β”‚   β”œβ”€β”€β–Ά Rerank with cross-encoder                                 β”‚
β”‚   β”œβ”€β”€β–Ά Generate answer with LLM (Groq API / HF Inference)       β”‚
β”‚   └──▢ Evaluate with RAGAS (faithfulness, relevancy, recall)     β”‚
β”‚                                                                   β”‚
β”‚  πŸ–₯️ Gradio Interface                                             β”‚
β”‚   β”œβ”€β”€ Chat tab (ask questions)                                    β”‚
β”‚   β”œβ”€β”€ Upload tab (add documents)                                  β”‚
β”‚   β”œβ”€β”€ Compare tab (side-by-side tier comparison)                  β”‚
β”‚   └── Eval tab (RAGAS scores)                                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Component Tool Why
Dense Embeddings BAAI/bge-small-en-v1.5 (33MB) Best quality/size ratio, CPU-fast
Sparse Retrieval rank_bm25 Classic term-matching, complements dense
Fusion Reciprocal Rank Fusion (RRF) No tuning needed, robust across domains
Reranker cross-encoder/ms-marco-MiniLM-L6-v2 Best CPU reranker (74.3 NDCG@10)
Graph RAG LightRAG (34K GitHub stars) Entity-relationship graphs for multi-hop
LLM Groq API (free, Llama 3.3 70B) Zero cost, fast, high quality
Evaluation RAGAS Standard RAG evaluation framework
Frontend Gradio β†’ HF Spaces Free deployment, no GPU needed
Vector Store FAISS (CPU) Fast, no server needed

πŸ“ Project Structure

project2_advanced_rag/
β”œβ”€β”€ README.md                  # This file
β”œβ”€β”€ requirements.txt           # Dependencies  
β”œβ”€β”€ rag_engine.py             # Core RAG engine (all 3 tiers)
β”œβ”€β”€ evaluation.py              # RAGAS evaluation pipeline
β”œβ”€β”€ app.py                     # Gradio web interface
β”œβ”€β”€ ingest_sample_data.py      # Download & index sample documents
β”œβ”€β”€ config.py                  # Configuration (API keys, model names)
└── sample_data/               # Sample documents for demo
    └── README.md

πŸš€ How to Run

Quick Start (5 minutes)

# 1. Install dependencies
pip install -r requirements.txt

# 2. Set up API key (free!)
#    Go to https://console.groq.com β†’ Get API key
export GROQ_API_KEY="your-key-here"

# 3. Index sample documents
python ingest_sample_data.py

# 4. Launch the app
python app.py
# Opens at http://localhost:7860

Deploy on HF Spaces (Free)

# 1. Create a new Space on huggingface.co
# 2. Upload all files
# 3. Add GROQ_API_KEY to Space secrets
# 4. It deploys automatically!

πŸ’‘ Key Concepts You'll Learn

  • Dense vs Sparse Retrieval: Why you need both
  • Reciprocal Rank Fusion: How to combine multiple retrievers
  • Cross-encoder Reranking: Why bi-encoders aren't enough
  • Knowledge Graphs: Entity extraction and relationship mapping
  • Multi-hop Reasoning: Answering questions that span multiple documents
  • RAGAS Evaluation: Measuring RAG quality scientifically

πŸ“„ Based On

πŸ”‘ Getting Free API Keys

Service What For Link
Groq LLM (Llama 3.3 70B) console.groq.com
HuggingFace Embeddings (optional, runs locally) huggingface.co/settings/tokens
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Papers for Neha12210/project2-advanced-rag