All posts

RAG hybrid search and reranking: how to fix retrieval quality before you blame the model

When a RAG system gives wrong answers, the cause is usually retrieval, not the LLM. How hybrid search, contextual chunks and reranking each help, what they cost, and how to measure it.

CodeKrypt 5 min read

Your RAG assistant answers confidently and wrongly. The instinct is to try a bigger model or rewrite the prompt. Usually the model was never shown the right passage. RAG hybrid search and reranking are the two standard fixes for that, and they are cheaper than a model upgrade. This post explains what each does, what it costs, and how to find out whether you need it.

The numbers below come from public sources, linked inline. Several are from vendors or single-dataset benchmarks, so treat them as indicative and test on your own documents.

Why does RAG retrieve the wrong passages?

Plain vector search turns text into embeddings and returns the nearest chunks. That is good at meaning and weak at exact tokens. A query for an error code, a contract clause number or a SKU may land near passages that are on-topic but do not contain the string. On the other side, keyword search (BM25) matches exact terms but misses a paraphrase.

A second, separate problem is context loss at chunking time. A chunk that says "revenue grew 3% over the previous quarter" does not say which company or which quarter, so no retriever can match it to the question.

Fix these in the right order. A reranker can only reorder what retrieval returned, so recall comes first and precision second.

What does hybrid search add over vector search alone?

Hybrid search runs both retrievers and fuses the results. The common fusion method is Reciprocal Rank Fusion (RRF). Denser's 2026 guide calls k=60 a reliable no-tuning baseline and suggests building an evaluation set of 50–200 queries with known relevant documents before tuning further.

How big is the gain? It depends on the data. The same guide cites a furniture e-commerce benchmark (WANDS) where BM25 alone scored 0.6983 NDCG and dense search 0.6953, a basic RRF hybrid scored 0.7068, and a heavily tuned hybrid reached 0.7497. Most of the lift in that example came from tuning, not from fusing. One dataset is not a promise for yours.

What does reranking do, and what does it cost?

A reranker (a cross-encoder) reads the query and each candidate passage together and scores relevance directly, which is more precise than comparing two precomputed embeddings. The pattern is to retrieve a wide set, say 100–150 candidates, then rerank down to the handful you give the LLM.

The cost is time. The Denser guide puts reranking at roughly 100–300 ms of extra latency per query and suggests skipping it when your total latency budget is under 500 ms. A hosted reranker also adds a per-query charge and another vendor in the data path, which matters for the points in the DPDP Act post.

Is contextual retrieval worth the extra indexing cost?

Anthropic's contextual retrieval write-up addresses the chunk-context problem: before indexing, a model prepends a short description of where each chunk sits in its document. Their results measured the top-20 retrieval failure rate (1 minus recall@20):

SetupTop-20 failure rateReduction vs baseline
Baseline embeddings5.7%–
Contextual embeddings3.7%35%
Contextual embeddings + contextual BM252.9%49%
Above + reranking (150 candidates to top 20)1.9%67%

Caveats: these are Anthropic's figures on their own test sets, and the gains vary by domain. The one-time cost to generate the context is given as $1.02 per million document tokens under their stated assumptions (800-token chunks, 8k-token documents) with prompt caching. Prices change, so recompute for your corpus size. Because it is a one-time indexing cost rather than a per-query cost, it is often easier to justify than a reranker on every request.

Retrieval pipeline: keyword and vector search, fusion, reranker, LLMKeyword (BM25)Vector searchFusion (RRF)RerankerLLM answerWide recall first, precision second

Which fix should you try first?

SymptomLikely causeFirst thing to try
Misses exact IDs, names, codesVector-only retrievalAdd BM25 and fuse with RRF
Right document found, wrong passage on topWeak rankingAdd a reranker
Chunks are ambiguous out of contextContext lost in chunkingContextual chunks
Right passage never appears in top 100Chunking, embeddings or filtersInspect chunks and metadata filters
Right passage retrieved, answer still wrongGeneration, not retrievalPrompt and model evaluation

If you run a multi-customer product, retrieval filters are also an isolation boundary; see multi-tenant RAG data isolation before you add a second index.

How do you know retrieval is the problem?

Measure it separately from the answer. Collect 50–200 real questions, mark which documents should be retrieved, and compute recall@k for the retriever alone. If the right passage is in the top 20 less often than you can accept, fix retrieval. If it is there and answers are still wrong, look at generation. Then keep that set in your regression suite; the approach is the same as in LLM evals in CI. For the wider question of whether RAG is the right tool at all, see RAG or fine-tuning.

What to do next

  1. Build the labeled query set before changing anything.
  2. Measure recall@k for your current retriever.
  3. Add BM25 with RRF if exact-term queries fail.
  4. Add a reranker only if the right passage is retrieved but ranked low, and check the latency against your budget.
  5. Consider contextual chunks if your documents lose meaning when split.

If you are building a retrieval-backed product and want the pipeline designed and measured rather than guessed, that is the work our AI SaaS service covers.

Sources

CodeKrypt avatar

CodeKrypt

Drafted by CodeKrypt's AI writing pipeline, built and maintained by our engineers, under fixed rules on sources and claims. How we write

Frequently asked questions

What is hybrid search in RAG?
It runs a keyword search (usually BM25) and a vector search over the same documents, then merges the two ranked lists, commonly with Reciprocal Rank Fusion. Keyword search catches exact terms such as product codes and names; vector search catches paraphrases.
Do I need a reranker?
Often, but measure first. A reranker re-scores the top candidates by reading the query and each passage together, which usually improves precision. It adds latency, and it cannot recover a document that retrieval never returned.
How many labeled queries do I need to tune retrieval?
One 2026 guide suggests 50 to 200 representative queries with known relevant documents. That is enough to compare fusion and reranker settings on your own data instead of trusting a vendor benchmark.
Will better retrieval fix hallucinations?
It removes one cause: the model never being shown the right passage. It does not stop a model from misreading a passage it was given, so keep an answer-level evaluation as well.

Related reading

Chat on WhatsApp