Building a Production Hybrid RAG: Why I Threw Out the LangChain Recipe
Summary
A production-ready hybrid RAG system, detailed in a new open-source project, demonstrates how to move beyond basic tutorials to achieve deployable performance, reducing hallucination rates from 12% to 3%. Key architectural decisions include using Reciprocal Rank Fusion (RRF) for combining dense and sparse retrieval, which is parameter-free and score-agnostic, outperforming individual components with 89% accuracy on mixed queries. It employs cross-encoder reranking with `ms-marco-MiniLM-L-6-v2` for improved relevance (5-8% keyword recall, 7 points NDCG@5) on top-15 candidates after bi-encoder retrieval. The system incorporates explicit abstention logic, first-class citations, and a rigorous evaluation framework using metrics like RAGAS Faithfulness and BERTScore F1. Adaptive routing, semantic caching, and separate guardrail passes for PII/toxicity are also implemented, alongside comprehensive production hardening for observability, scaling, and CI/CD.
Key takeaway
For MLOps Engineers building RAG systems, relying solely on basic tutorials is insufficient for production. You should prioritize robust architectural decisions like Reciprocal Rank Fusion, cross-encoder reranking, and explicit abstention logic to achieve reliable performance and reduce hallucination rates. Implement a comprehensive evaluation framework early to quantify improvements and ensure system stability, avoiding "shipping on vibes."
Key insights
Production RAG requires robust engineering beyond basic tutorials, focusing on hybrid retrieval, rigorous evaluation, and operational resilience.
Principles
- Reciprocal Rank Fusion (RRF) combines retrieval ranks, not scores, for robustness.
- Cross-encoders provide cleaner relevance signals than bi-encoders for reranking.
- Explicit abstention logic prevents hallucinations and enables monitoring.
Method
The proposed RAG pipeline involves bi-encoder retrieval (top-3k), RRF for fusing dense/sparse rankings (top-15), cross-encoder reranking, LLM generation with abstention, and structured citation output. Adaptive routing and semantic caching optimize performance.
In practice
- Implement RRF with `k=60` for combining dense and sparse retrieval.
- Use `ms-marco-MiniLM-L-6-v2` as a cross-encoder for reranking top-15 candidates.
- Add explicit LLM prompt instructions for abstaining on out-of-scope questions.
Topics
- Hybrid RAG
- Reciprocal Rank Fusion
- Cross-Encoder Reranking
- LLM Evaluation Frameworks
- Production MLOps
- Semantic Caching
Code references
Best for: Machine Learning Engineer, AI Engineer, MLOps Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by LLM on Medium.