Building a Production Hybrid RAG: Why I Threw Out the LangChain Recipe

· Source: LLM on Medium · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering, Cloud Computing & IT Infrastructure · Depth: Advanced, long

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

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

Topics

Code references

Best for: Machine Learning Engineer, AI Engineer, MLOps Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by LLM on Medium.