RAG-SOTA-plauyground
This project implements a Retrieval Augmented Generation (RAG) system with multiple retrieval methods, allowing users to experiment with different approaches to document retrieval and question answering.
Overview
The system provides three increasingly sophisticated approaches to document retrieval:
-
Basic Embedding-based RAG
- Uses vector embeddings (Voyage AI in memory for now) for semantic search
-
Hybrid Search RAG
- Combines vector embeddings with BM25 text search
-
Reranked Hybrid Search RAG
- Builds on hybrid search by adding Cohere's reranking
-
CONTEXTUAL Basic Embedding-based RAG
-
CONTEXTUAL Hybrid Search RAG
-
CONTEXTUAL Reranked Hybrid Search RAG
Setup
-
Create a virtual environment:
-
Install dependencies:
pip install anthropic voyageai cohere elasticsearch pandas numpy python-dotenv PyPDF2- Create a
.envfile with your API keys. I will send mine on teams on request:
ANTHROPIC_API_KEY=your_key_here
VOYAGE_API_KEY=your_key_here
COHERE_API_KEY=your_key_here
- Start Elasticsearch (required for hybrid methods):
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" elasticsearch:8.8.0Usage
The system supports various document formats:
- CSV files
- Text files
- JSON files
- PDF documents
Project Structure
rag1.py: Basic embedding-based RAGrag2.py: Hybrid search RAG (embedding + BM25)rag3.py: Reranked hybrid RAGdata/: Directory for source documentsDocumentLoader: Handles various file formats and chunkingVectorDB/HybridVectorDB/RerankedHybridVectorDB: Different retrieval implementations
Future Improvements and ToDos
- User interface improvements
- Multiple file indexing to PGvector
On this page
Languages
Python93.1%Shell5.6%Dockerfile1.3%
Contributors
Created December 15, 2024
Updated August 11, 2025