Skip to content

A comprehensive guide to advanced RAG techniques including reranking, deep memory, and vector store optimization. Includes practical implementations and best practices using LlamaIndex, Langchain, etc..

Notifications You must be signed in to change notification settings

sosanzma/rag-techniques-handbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

RAG Techniques Handbook

🎯 Status: Production-Ready | 📚 Complete Techniques: 6 | 🔗 Integrated Docs: 100%

Overview

This repository provides a comprehensive collection of advanced RAG (Retrieval Augmented Generation) techniques with production-ready implementations and seamlessly integrated documentation. Each technique includes both theoretical explanations and working Python code that you can immediately use in your projects.

Key Features:

  • Production-Ready Code: All implementations are tested and optimized
  • 📖 Integrated Documentation: Theory and code seamlessly connected
  • 🚀 Quick Start Guides: Get running in 3 minutes with any technique
  • 🔧 Configurable: Extensive configuration options for customization
  • 📊 Evaluation Framework: Built-in metrics and performance assessment
  • 🤖 Multiple LLM Support: OpenAI, Cohere, and more

Currently Implemented Techniques

✅ RAG Metrics & Evaluation

Complete evaluation framework with LlamaIndex and RAGAS integration

✅ Vector Store Index Implementation

Optimized vector store operations with DeepLake integration

✅ Advanced Reranking Systems

Multiple reranking strategies with ensemble capabilities

✅ Advanced RAG Techniques

LlamaIndex-based advanced query processing and retrieval

✅ RAG Agent System

Multi-source agent-based RAG with tool integration

✅ LangSmith Integration

Complete monitoring and evaluation with LangSmith

Quick Start

Installation

# Clone the repository
git clone https://github.com/sosanzma/rag-techniques-handbook.git
cd rag-techniques-handbook

# Install dependencies
pip install llama-index==0.9.14.post3 deeplake==3.8.12 openai==1.3.8 cohere==4.37 ragas==0.0.22 pandas

# Set up environment variables
export OPENAI_API_KEY="your_openai_key"
export ACTIVELOOP_TOKEN="your_deeplake_token"
export COHERE_API_KEY="your_cohere_key"

3-Minute Example: Complete RAG Evaluation

from src.rag_metrics_evaluation_module import RAGEvaluationFramework, EvaluationConfig
import asyncio

# Configure and run comprehensive evaluation
config = EvaluationConfig(llm_model="gpt-3.5-turbo", enable_ragas=True)
evaluator = RAGEvaluationFramework(config)

# Evaluate your documents
results = asyncio.run(
    evaluator.comprehensive_evaluation(documents_path="your/docs/path")
)

print(f"📊 Retrieval MRR: {results['retrieval_metrics']['mrr']:.3f}")
print(f"✅ Faithfulness: {results['generation_metrics']['faithfulness']:.3f}")
print(f"🎯 Relevancy: {results['generation_metrics']['relevancy']:.3f}")

Project Structure

rag-techniques-handbook/
├── 📁 docs/                           # Comprehensive guides (theory + implementation)
│   ├── 📋 rag_metrics_evaluation_guide.md
│   ├── 📋 vector_store_index_implementation_guide.md
│   ├── 📋 reranking_rag_systems.md
│   ├── 📋 Advanced_RAg_techniques_LLamaIndex.md
│   ├── 📋 LlamaIndex_rag_agent.md
│   └── 📋 Langsmith.md
├── 🐍 src/                            # Production-ready implementations
│   ├── 🔬 rag_metrics_evaluation_module.py
│   ├── 🗄️ vector_store_index_implementation.py
│   ├── 🔄 reranking_rag_systems.py
│   ├── 🚀 Advanced_RAG_tenchniques_LLamaIndex.py
│   ├── 🤖 LlamaIndex_rag_agent.py
│   └── 📈 Langsmith.py
├── 📓 src/Module_04_RAG_Metrics&Evaluation.ipynb  # Jupyter notebook example
├── 📖 CLAUDE.md                       # Development documentation
└── 🗺️ README.md                       # This file

Prerequisites

  • Python: 3.8+
  • API Keys: OpenAI (required), Cohere (optional), ActiveLoop (for DeepLake)
  • Memory: 8GB+ RAM recommended for large document processing
  • Storage: Vector databases may require significant disk space

Contributing

We welcome contributions! The repository is designed for easy extension:

Current Areas for Contribution

  • Additional evaluation metrics
  • New vector store integrations
  • Performance optimizations
  • Documentation improvements
  • Example notebooks

How to Contribute

  1. Fork the repository
  2. Create a feature branch
  3. Follow the existing patterns (see any src/ file for reference)
  4. Update both implementation and documentation
  5. Submit a pull request

Resources

Documentation

External Resources

License

This project is licensed under the MIT License - see the LICENSE file for details.


🚀 Ready to get started? Pick any technique from the list above and follow its Quick Start guide. Each implementation is production-ready and includes comprehensive documentation to get you running in minutes!

About

A comprehensive guide to advanced RAG techniques including reranking, deep memory, and vector store optimization. Includes practical implementations and best practices using LlamaIndex, Langchain, etc..

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages