tutorials

Better Retrieval: The Upgrades Every Production RAG Makes First

11 min read

A customer typed a part number into the support chat. The system answered confidently, quoting a paragraph about a similar product’s return policy. The part number appeared verbatim in the catalog PDF, on page two. The retriever never found it, because a vector index does not rank verbatim.

This is Post 1 in the Retrieval Patterns series. If you haven’t read the intro yet, start there - it maps the nineteen patterns and the failure each one fixes. This post goes deep on the first family: the patterns that fix the retrieval stage itself.

What the baseline gets wrong

Single-pass vector search fails in two directions, and the failure reports sound identical. “The answer was wrong” covers both.

The first direction is recall: the right chunk never made the candidate list. Part numbers, error codes, statute names, and any string the user typed verbatim fall here, because an embedding trained on meaning treats “error 0x8004” as roughly the same as “error 0x8005”. The second direction is precision: the right chunk made the list but ranked ninth, below five near-misses the model happily used instead.

Three patterns cover both, and they are usually the first upgrades a production system buys. Each fixes a different slice of the stage, so they stack rather than compete.

Hybrid retrieval

Two retrievers run in parallel over the same query. Vector search finds chunks that mean the right thing; keyword search, usually BM25, finds chunks that say the right thing. A fusion step, most often reciprocal rank fusion, merges the two ranked lists: each method’s ranking votes, and chunks that rank high on either list float to the top.

A search for the part number CBX-2200 found by two converging search paths, versus a prose-only corpus where a second dusty index finds nothing

Where it earns its keep. Corpora full of identifiers: part catalogs, error registries, legal citations, internal codebases, any corpus where the user types the exact string that matters. Also mixed query traffic, where half the questions are prose and half are codes.

Example. A shopper who types "CBX-2200 battery" wants the page that says CBX-2200, and keyword search finds it. A shopper who types "replacement power cell for the handheld unit" means the same product, and vector search finds it. Either retriever alone misses one of them.

Where it doesn’t. You now run two indexes with two update cycles and two ways to be stale. The fusion weights need tuning on your traffic, and both retrievals run on every query, so cost roughly doubles on the retrieval line.

Counterexample. On a forty-page FAQ of pure prose, where nobody ever types a code, the second index mostly buys a second update cycle to babysit.
Paper or production? paper
production

BM25 predates RAG by decades, reciprocal rank fusion is standard search practice, and every serious retrieval deployment we see runs some version of this pair. Hybrid search is the single most common first fix.

Two-stage reranking

Retrieval happens twice on purpose. The first pass is the fast one: the vector index returns a wide shortlist, twenty to a hundred candidates, using the cheap approximate match it was built for. The second pass is the careful one: a reranker reads the query and each candidate together and re-scores the shortlist for actual relevance.

The split exists because the two passes are good at different things. Embedding-based retrieval compares two vectors computed independently, which is fast enough to scan millions of chunks and coarse enough to miss fine distinctions. The cross-encoder in the second pass processes query and chunk jointly, which is slow and precise. First pass decides what deserves a careful look; second pass gives it.

A reranker lifting the right document from position six to the top of a ranked list, versus a redundant rescan of an already-correct result

Where it earns its keep. The near-miss problem: the right chunk is in the candidate list but buried under similar-looking wrong ones. Precision-critical domains are where this matters, because a near-right answer is a wrong answer with extra confidence.

Example. Ask a legal corpus about the indemnity cap and the first pass returns a dozen liability clauses; the reranker is the pass that notices which one caps indemnity.

Where it doesn’t. The second pass adds real latency, roughly tens to low hundreds of milliseconds depending on shortlist size, and another model to operate.

Counterexample. A docs site whose first pass already lands the right page on top pays latency on every query for a ranking nobody needed.
Paper or production? paper
production

Inherited from search - two-stage retrieval is how web search worked before LLMs existed; RAG adopted it for the same near-miss problem.

Semantic caching

Semantic caching sits in front of the pipeline and stores past question-answer pairs by meaning. A new question gets embedded and compared to the cache; if a stored question is similar enough, the cached answer goes out and the whole pipeline, retrieval and generation included, is skipped.

Caching earns its place differently from the other two in this post: it upgrades cost and latency while answer quality stays where it was, which is why it sits last. A cache multiplies whatever the system already is, including its mistakes.

Three differently phrased questions collapsing into one cached answer, versus a stale cached answer served while the product shelf sits empty

Where it earns its keep. Repetitive traffic: support portals and FAQ bots where a large share of queries are rephrased repeats of a few hundred questions. Every hit skips the whole pipeline, so cost and latency both drop.

Example. "How do I reset my password", "forgot my password", and "can't log in" arrive as three different strings and leave as one cached answer with zero model calls.

Where it doesn’t. A cached answer does not know the corpus changed; the refund-policy incident from the series intro is a cache-hit waiting to happen if invalidation is lazy. Storing user questions raises privacy questions of its own, one-off query traffic gets overhead without hits, and a wrong answer can propagate through the cache faster than it would have on its own.

Counterexample. A storefront that cached "is the CBX-2200 in stock" keeps answering yes for two days after it sells out, because the cache has no way to know the catalog changed.
Paper or production? paper
production

Shipping in LLM gateways and API layers. The failure mode to watch is the operational one: cache invalidation has no owner the way index lifecycle events had none.

How the three compare

The three patterns fix different slices of the retrieval stage, and the easiest way to keep them apart is what each one does to the candidate pool.

Hybrid retrieval
widens the pool
more of the right chunks get in
Two-stage reranking
re-orders the pool
the right chunks rise to the top
Semantic caching
skips the pool
the answer never reaches retrieval - it is already in memory

They also stack in a deliberate order. Hybrid comes first because a reranker can only re-order what a retriever found. Reranking comes second because re-ranking a pool that was never wide enough buys nothing. Caching comes last and only after quality is proven, because a cache faithfully multiplies whatever sits behind it, including the mistakes.

The three cards compress that into the shortest honest comparison we can make.

Hybrid retrieval widens the pool
  • Fixes: the right chunk never made the candidate list - verbatim strings like part numbers and error codes that an embedding flattens into near-matches
  • Slots: replaces the single retrieval call; both retrievers run in parallel before ranking
  • Costs: a second index with its own update cycle, plus fusion weights tuned on your traffic
  • Latency: small parallel cost per query - both retrievals fire at once
  • Reach for it when: the corpus carries identifiers - codes, names, part numbers - and users type them verbatim
  • Skip it when: the corpus is short prose and the questions are conversational
Two-stage reranking re-orders the pool
  • Fixes: the right chunk was retrieved but buried below similar-looking near-misses
  • Slots: after the first pass; re-scores only the shortlist, twenty to a hundred candidates
  • Costs: a second model to operate, plus a pass that scales with the shortlist size
  • Latency: adds tens to low hundreds of ms, paid on the shortlist only, not per document
  • Reach for it when: answers are close-but-wrong and the right chunk exists somewhere in the results
  • Skip it when: the first pass already lands the right chunk on top
Semantic caching skips the pool
  • Fixes: repeat queries billed as new - the pipeline re-runs retrieval and generation for a question it already answered
  • Slots: in front of the pipeline; a hit bypasses retrieval and generation together
  • Costs: a cache store plus an invalidation policy someone has to own - the part that goes stale quietly
  • Latency: near-instant on hits; a small embed-and-compare overhead on misses
  • Reach for it when: traffic is repetitive - support and FAQ workloads with rephrased repeats - and answers are already good
  • Skip it when: answers must reflect the latest data, or every query is a one-off

Two of the fields deserve a second look before the section closes. “Costs” is engineering cost, not vendor spend: hybrid means a second index to keep fresh, reranking means a second model to operate, and caching means an invalidation policy someone has to own. And latency only tells you what each pattern adds at query time. None of the three touches the corpus itself, and that is the point of the next section.

The failure this group still won’t fix

Every pattern here assumes the index hands it chunks worth finding. Hybrid retrieval fuses two lists drawn from the same index. A reranker re-orders what the index returns. A cache replays what the pipeline already produced.

Counterexample. A pricing PDF was replaced in March, and the old version never left the index. Hybrid finds it on both lists, the reranker promotes it as the best match, and the cache has served it for a week. Every upgrade ran correctly, on the wrong page.

If the corpus was chunked badly, if a superseded document still lives in the index, or if the page the user needs was never loaded, the failure is upstream of everything in this post and no retrieval upgrade reaches it. The companion post, Why RAG Dies on the Real Corpus, maps those failures stage by stage and gives the check-first table for telling a retrieval bug from a corpus bug. That check comes first: there is no fixing a retrieval problem you do not have.

Next in the series, the corpus stops being the suspect. Post 2 covers the question side: HyDE, branched queries, speculative prefetch, and SEAKR deciding whether to retrieve at all - the patterns for when the index is fine and the phrasing is the problem.


Working With Flytebit

At FLYTEBIT TECHNOLOGIES, RAG development is a structured engagement rather than a workshop and a tool licence.

Hybrid plus reranking is the first layer we reach for, and the check-first table from the companion post is how we decide whether retrieval is even the stage that owns the bug. Teams that skip the check tend to buy the bigger model first and learn what the index cost them at invoice time. The feasibility study runs that check on your corpus before the budget does.

We run these pipelines in our own products. PASSR reviews every pull request against retrieved repository context, where function names and error strings are exactly the verbatim identifiers hybrid retrieval exists for. DOCKR regenerates documentation when the codebase changes, and a stale keyword index there means docs built on yesterday’s structure. TESTR builds test cases from retrieved source behavior, where a near-miss chunk is a test written against the wrong code path.


Ready to get started?



Key Takeaways

  • The baseline fails two ways in the same stage. Recall failures keep the right chunk out of the candidate list; precision failures bury it below near-misses. The same “wrong answer” report covers both.
  • Hybrid retrieval fixes recall. Vector search finds meaning, keyword search finds verbatim strings, and reciprocal rank fusion merges the two lists. The cost is a second index with its own update cycle.
  • Two-stage reranking fixes precision. A fast approximate pass builds the shortlist; a slower cross-encoder pass re-scores it. The expensive model only ever sees dozens of candidates, not the corpus.
  • Semantic caching cuts repeat spend once quality holds. Add it after answers are good and traffic repeats; a cache happily serves a wrong answer faster, and it cannot know the corpus changed.
  • Check the stage before buying the upgrade. All three patterns assume the index hands them chunks worth finding. A badly chunked or stale corpus is upstream of everything here, which is why the companion post’s check-first table comes first.

The series intro:

👉 Retrieval Patterns: From Naive RAG to Agentic Retrieval

Frequently Asked Questions

What is hybrid search in RAG?

Hybrid search runs two retrievers in parallel: vector search for meaning and keyword search (usually BM25) for exact strings, then merges the two ranked lists into one. Vector search alone misses part numbers, error codes, and names that the user typed verbatim. Keyword search alone misses phrasing the user got wrong. Hybrid covers both failure modes at the cost of maintaining two indexes.

Is a reranker worth the extra latency?

Usually yes, and the latency is smaller than it sounds. A reranker only scores the shortlist the first pass returned, typically the top twenty to fifty chunks, so the expensive model runs on dozens of items, not the corpus. If your answers are close-but-wrong and the right chunk exists somewhere in the results, reranking is the single change with the best payoff.

What is the difference between reranking and hybrid search?

They fix different failure modes and stack well. Hybrid search fixes recall: the right chunk never made the candidate list because the wording did not match the index. Reranking fixes precision: the right chunk made the list but ranked below near-misses. Hybrid widens the pool; reranking re-orders it.

When should I add semantic caching to a RAG system?

After the answers are good, not before. Semantic caching reuses past answers for similar questions, so it multiplies whatever quality the system already has, including its mistakes. Add it when a large share of traffic is rephrased repeats, which is common in support and FAQ workloads. Skip it when every query is different or the answers must always reflect the latest data.

Which retrieval upgrade should I add first?

Hybrid search plus reranking covers the majority of retrieval failures in production systems, so that pair is the honest default. Hybrid fixes the misses and reranking fixes the ranking. Reach for caching only once quality is stable, since a cache happily serves a wrong answer faster.

#RAG#RetrievalAugmentedGeneration#HybridSearch#Reranking#AIEngineering#TutorialSeries
Jayaveer Bhupalam

Written by

FLYTEBIT Technologies

Founder · Chief Technology Officer · AI & Digital Transformation Leader

Ready to Transform Your Business with AI?

Let's discuss how Agentic AI and intelligent automation can help you achieve your goals.