Hybrid search and reranking
What are hybrid search and reranking, and why do they improve RAG?
TL;DR
Dense (vector) search matches meaning but often misses exact terms: error codes, product SKUs, names, acronyms. Keyword search (BM25) nails exact terms but misses paraphrases. Hybrid search runs both and merges the results, usually with Reciprocal Rank Fusion (RRF), so you get the best of each. Reranking is a second stage: take the top ~20–100 candidates and re-score each one against the query with a cross-encoder model that reads the query and the chunk together. It's much more accurate than comparing two separate embeddings, but too slow to run over the whole corpus, so it only reorders the shortlist.
Key points
- RRF: score = Σ 1/(k + rank) across the result lists (k is often 60). It needs no score normalization between BM25 and cosine.
- Bi-encoder vs cross-encoder: a bi-encoder embeds query and document separately (fast, indexable); a cross-encoder scores the pair jointly (accurate, slow).
- Typical pipeline: hybrid retrieve top 50 → rerank → keep top 5 for the prompt.
- Rerankers: hosted APIs (such as Cohere Rerank) or open models (BGE reranker); an LLM can also rerank, at higher cost.
- Query transformations help too: rewriting conversational questions into standalone ones, multi-query expansion, or HyDE (embed a hypothetical answer instead of the question).
- Reranking adds latency (often tens to a few hundred ms); measure whether the quality gain is worth it.
Example
Query: "error E1042 when syncing"
Vector search: generic "sync troubleshooting" pages
BM25: the page that literally mentions E1042
Hybrid + RRF: E1042 page ranked first, related sync pages next
Reranker: confirms the E1042 page as most relevantCommon follow-ups
- How do you weight vector vs keyword results? RRF, or a weighted sum of normalized scores tuned on an evaluation set.
- Where does a reranker fit with metadata filters? Filter first (permissions, tenant), then retrieve, then rerank.
What interviewers look for
Tip
Why dense search alone misses exact terms, how fusion merges lists, and why a cross-encoder reranker is accurate but used only on a shortlist.
- Red flag: sending the raw top-k vector results to the LLM for every query type.