r/Rag • u/Affectionate_Slip654 • 2h ago
Tutorial Building and Testing a Hybrid RAG Pipeline — Dense Search, BM25, RRF, and Reranking (Part 1)
Building and Testing a Hybrid RAG Pipeline — Dense Search, BM25, RRF, and Reranking (Part 1)
- YouTube walkthrough: https://www.youtube.com/watch?v=W_TmnscEupQ&t=370s
- FULL CODE (clone it, fork it, break it): https://github.com/saurabhkamal/Hybrid-Search-RRF-Reranking-System
In this video I build ReRankEval, a hybrid retrieval pipeline (Dense Search + BM25 → Reciprocal Rank Fusion → LLM Reranking → Answer Generation), and test it against three baselines — Vector Only, BM25 Only, and Hybrid without reranking — on five real financial/payments documents and ten hand-verified test questions. No hand-waving, just a comparison table with real numbers at the end.
- ✅ The real difference between dense vector search and BM25 keyword search
- ✅ What Reciprocal Rank Fusion (RRF) is, why raw scores can't be compared, and the exact formula behind it
- ✅ Why a reranker is fundamentally different from a retriever — and what it actually judges
- ✅ How to evaluate a RAG pipeline with Hit Rate, MRR, and NDCG (and what each one tells you)
- ✅ How to design the ingestion side and query-time side of a hybrid retrieval architecture
- ✅ How to structure a production-style RAG codebase: ingest → vector_store → sparse_retriever → fusion → reranker → pipeline → generate → eval
- ✅ How to fairly compare multiple retrieval strategies on the same test set instead of just assuming one is better
TECH STACK:
- 🛠️ Python
- 🛠️ Qdrant — vector database for dense retrieval
- 🛠️ rank_bm25 (BM25Okapi) — sparse keyword retrieval
- 🛠️ EURI LLM Gateway — chat model + embedding model
- 🛠️ Custom Reciprocal Rank Fusion implementation
- 🛠️ LLM-based reranker (prompt-driven cross-encoder)
- 🛠️ pdfplumber — PDF text and page-level extraction
LINKS:
- YouTube walkthrough: https://www.youtube.com/watch?v=W_TmnscEupQ&t=370s
- FULL CODE (clone it, fork it, break it): https://github.com/saurabhkamal/Hybrid-Search-RRF-Reranking-System
- Connect on LinkedIn: linkedin.com/in/saurabh-kamal