Technical Article

Hybrid Search and Reranking in Production RAG

Dense vector search excels at capturing conceptual meaning and thematic intent. However, production RAG pipelines quickly begin to stumble when engineers treat vector similarity as the sole mechanism for finding evidence across diverse user queries.

While a conceptual search for "cancellation policies" performs exceptionally well with vector embeddings, queries containing exact error codes (such as ERR_AUTH_1042), software versions (v2.7.1), or specific identifiers frequently fail in purely dense indices. Rare tokens and exact alphanumeric strings carry high informational entropy that dense vector embeddings often smooth over and dilute.

The Power of Multi-Signal Retrieval

A resilient retrieval architecture executes parallel queries across both dense vector indices and sparse lexical indices (such as BM25). By preserving top candidate results from both paradigms, the system captures both semantic intent and exact keyword matches.

Because dense cosine similarities and sparse BM25 scores operate on entirely different mathematical scales, combining them directly is notoriously problematic. Techniques such as Reciprocal Rank Fusion (RRF) solve this by merging candidate lists based on positional rank rather than raw score magnitudes, producing a unified candidate pool without requiring complex score calibration.

Two-Stage Retrieval: Recall First, Precision Second

The initial retrieval stage should never attempt to assemble the final LLM prompt. Its sole responsibility is maximizing recall: casting a wide net to ensure the correct evidence is not discarded early, even if the candidate pool is larger and noisier than what the model should process.

Once high-recall candidates are gathered, a second stage takes over:

  • A cross-encoder reranker assesses the smaller candidate set with high attention to query-document token interactions.
  • The reranker re-scores and re-orders the candidates according to deep contextual relevance.
  • The context builder selects only the top-ranked passages to occupy the prompt's attention budget.

Layered Architecture over Monolithic Retrieval

This multi-stage architecture changes how retrieval is engineered. Lexical search, vector search, and cross-encoder reranking do not compete for a single role; they work in layered harmony. Fast, computationally cheap signals maximize recall across large corpora, while deeper, more expensive models refine precision on a focused subset.

In production RAG, the objective is never to prove that embeddings alone are sufficient. The objective is to build a robust pipeline where complementary retrieval mechanisms offset each other's inherent blind spots.