Reranking in RAG: why the first search result is often wrong
A reranker rereads the top 50-150 search hits next to the question and reorders them, fixing the ranking mistakes fast first-stage retrieval makes in RAG.
The first search result in a RAG system is often wrong because first-stage retrieval is built for speed: it compares a precomputed vector or counts matching terms, and never reads the question and the passage together. A reranker fixes that by taking the top 50 to 150 hits, scoring each one side by side with the question using a slower and more accurate model, and passing only the best few to the language model. It cannot find documents the first stage missed, but it is usually the cheapest way to get the right chunk from position 9 into position 1.
That last sentence is the whole job description. Everything below is about when a reranker earns its latency, which kind to choose, and how to tell whether it helped.
A wrong answer with the right document in the list
As an illustration, take an HR assistant over a company's policy documents. An employee asks: "Can I carry forward unused leave if I resign in March?"
Vector search returns ten chunks. At the top is the general leave policy paragraph, which talks about carry-forward at length. Second is a paragraph on notice periods. Ninth is the one that actually answers the question: a short clause in the exit policy saying unused leave is encashed on resignation, not carried forward. The model reads the top five, sees a confident paragraph about carry-forward limits, and tells the employee they can carry 15 days into the next year. The answer is fluent, cites a real document, and is wrong.
Nothing was missing. The right clause was retrieved. It was simply ranked below text that shared more vocabulary and topic with the question without answering it. This is the most common shape of a retrieval failure that people blame on the model, and it is the exact failure a reranker exists for.
Why fast retrieval ranks badly
Vector search uses what the Sentence Transformers documentation calls a bi-encoder. Each document is turned into one embedding ahead of time, without knowing what anyone will ask. At query time the question gets its own embedding and the index returns the nearest documents. That design is what makes search over millions of chunks fast, but it means a whole passage has to be squeezed into a single point before the question exists. A passage that is generally about leave sits close to every leave question, whether or not it answers this one.
BM25 has a different blind spot. It scores term overlap, weighted by how rare each term is. "Carry forward", "leave" and "resign" all appear in the general policy, so it scores well. Negation, conditions and "only if" clauses mean nothing to it.
A cross-encoder works the other way round. It feeds the question and one passage into the same transformer together, so every word of the question can attend to every word of the passage, and it outputs a single relevance score. The Sentence Transformers documentation is direct about the trade: cross-encoders "achieve better performances than Bi-Encoders", but they "do not scale well for large datasets", and because a cross-encoder "does not produce a sentence embedding", there is nothing to index. Its own example makes the cost concrete. Clustering 10,000 sentences with a cross-encoder would mean scoring about 50 million pairs, which it puts at roughly 65 hours; a bi-encoder embeds the same sentences in about 5 seconds.
So you cannot search with a cross-encoder, but you can afford to run one over a short list. That is the two-stage pattern: a fast retriever for recall, a careful reranker for order.
What the evidence says reranking buys
The result that made this standard practice came early. In January 2019, Nogueira and Cho fine-tuned BERT as a passage reranker and reported that it topped the MS MARCO passage retrieval leaderboard, beating the previous best by 27% (relative) in MRR@10. MRR@10 rewards getting the first relevant passage near the top, which is precisely the property RAG depends on.
A more recent and more RAG-shaped number comes from Anthropic's contextual retrieval write-up, published in September 2024. They measured retrieval failure as the share of relevant chunks not found in the top 20. Their contextual embeddings combined with contextual BM25 brought that failure rate from 5.7% to 2.9%. Adding a reranker on top brought it to 1.9%, a 67% reduction against the 5.7% baseline. Their setup retrieved the top 150 chunks, reranked them, and kept 20. These are their experiments on their datasets, not a promise for yours, but the direction matches what the 2019 paper found on a very different benchmark.
Notice what the reranker added on top of hybrid retrieval: about a third of the remaining failures went away. That is a fair way to think about it. The first stage does most of the work; the reranker cleans up the order it got slightly wrong.
Choosing a reranker
There are three families worth knowing, and they trade accuracy against cost in different ways.
Cross-encoders are the default. Small ones are cheap enough to run on every query. The Sentence Transformers model table for MS MARCO shows how little you lose by going small: ms-marco-MiniLM-L6-v2 scores 74.30 NDCG@10 on TREC DL 19 at 1,800 documents per second, while the twice-as-deep ms-marco-MiniLM-L12-v2 scores 74.31 at 960 documents per second. The tiniest, ms-marco-TinyBERT-L2-v2, reaches 9,000 documents per second but drops to 69.84. The page does not say what hardware produced those speeds, so treat them as relative, not as a latency budget. As a rough illustration of the relative cost: on whatever machine produced that table, 150 candidates would take about 83 ms with the L6 model and about 156 ms with the L12 model, for a gain in the second decimal place. I would start with the six-layer model and only move up if your own evaluation shows a difference.
Late-interaction models such as ColBERT sit between the two stages. Khattab and Zaharia's design encodes queries and documents separately, as a bi-encoder does, but keeps one vector per token and compares them with a cheap "late interaction" step. Because document representations can be computed offline, the paper reports it running two orders of magnitude faster than BERT-based rerankers, with four orders of magnitude fewer FLOPs per query, while staying competitive in quality. The price is storage: many vectors per passage instead of one.
LLM rerankers hand the question and a batch of passages to a general model and ask for a ranking. The RankGPT paper (Sun et al., EMNLP 2023) found that properly instructed models such as ChatGPT and GPT-4 gave "competitive, even superior results" compared with supervised rerankers on standard benchmarks. It also showed the ranking skill could be distilled: a 440M-parameter student beat a 3B supervised model on BEIR. That second finding is the more practical one for most teams, because a full LLM call per query for ranking is slow and expensive.
| Cross-encoder | Late interaction (ColBERT) | LLM reranker | |
|---|---|---|---|
| How it scores | Question and passage in one pass | Separate token vectors, compared cheaply | Instructed model ranks a batch |
| Precompute documents | No | Yes | No |
| Query-time cost | Moderate, grows with candidates | Low | High |
| Extra storage | None | Many vectors per passage | None |
| Best fit | Default second stage | Large collections, tight latency | Hard queries, offline labelling, teacher for a smaller model |
Adding one to an existing pipeline
If you already have RAG in production, the change is small, and it should be made in this order so each step can be checked on its own.
- Measure recall at depth before touching anything. For a few hundred labelled queries, check how often the right chunk appears anywhere in the top 50, 100 and 150 from your current retriever. This number caps what any reranker can do.
- Raise the candidate depth to the point where recall stops improving much, within your latency budget.
- Add a small cross-encoder that scores every candidate against the original question (not a rewritten one, unless you have checked the rewrite helps).
- Keep the top 5 to 20 by reranker score and pass them to the model in that order.
- Compare recall at your final k, and the answer quality on the same queries, against the version without the reranker.
Step 4 has a detail people skip. Liu et al. showed in "Lost in the Middle" that model performance is often highest when the relevant information is at the beginning or end of the context and drops when it sits in the middle of a long one, even for long-context models. A reranker gives you an ordering you can trust, so use it: put the best chunk first, and do not pad the prompt with 20 chunks when 6 would do.
Where reranking goes wrong
The first trap is expecting a reranker to fix recall. It only reorders what it is given. If the exit clause was never in the 150 candidates because the chunk boundary cut it in half, no reranker will rescue it. Our guide to chunking strategies covers that end of the problem, and hybrid search covers getting both exact codes and paraphrases into the candidate list in the first place.
The second is input length. Cross-encoders have a maximum input size, and the question plus a long chunk can exceed it. Anything past the limit is cut off silently, so a passage whose answer sits in its last paragraph gets scored on its first. Check your model's limit against your chunk sizes, and make sure the question goes first so it is never the part that is truncated.
The third is treating the score as a probability. A reranker score of 0.4 does not mean the same thing for every question. Teams add a threshold ("drop anything under 0.5") and then find that a whole class of short or unusual queries returns nothing. If you want a cut-off, set it from your evaluation set and check it per query type, or keep a fixed top k and let the model judge.
The fourth is domain mismatch. The public cross-encoders above were trained on MS MARCO, which is web search queries. Internal jargon, product codes and mixed Hindi-English queries are a different distribution. That does not mean they fail, but it means the published scores tell you little about your data until you test on it.
The last one is a security mistake. If permission filtering happens after reranking, or only on one retrieval path, the reranker may promote a chunk the user is not allowed to see, and it will arrive at the top with a high score. Filter before you rerank, on every path. In CloudOEngine, data sources and the AI runtime with RAG share one permission model and one audit trail, so the access rule on a source document is the one retrieval sees, rather than a second copy kept in sync by hand.
How to tell it helped
Offline, the numbers to watch are recall at your final k and MRR, measured separately for each query type you care about. A reranker that lifts the average but loses on code lookups is a common result, because cross-encoders trained on natural language can underrate a passage whose only match is an exact identifier. Our article on evaluating LLM applications covers how to build the labelled set and keep it as a regression test.
Online, latency is the other half. Log the reranker's time per query alongside the candidate count, because both grow together and a quiet change to chunk size can double them.
When a user reports a bad answer, you need to see the list before and after reranking for that exact query: which chunk was ninth, which moved to first, and what the model was given. In CloudOEngine every agent step and tool call is traced and inspectable, so you can open the run behind a wrong answer and see the passages that reached the model before deciding whether retrieval, reranking or the prompt was at fault.
How CloudOEngine helps
CloudOEngine is one platform and one console for connecting data (databases, files and camera streams), running pipelines, and running AI. Its AI runtime includes an LLM gateway, agents with tool access, and RAG, so the documents you index and the assistant that searches and ranks them sit on the same platform as the sources they came from.
Reranking makes the order of evidence matter more, which makes two things important: who is allowed to see each chunk, and what the model actually read. Data, pipelines and AI in CloudOEngine share one permission model and one audit trail, so a document's access rule is defined once. Governance is included, not upsold: tenant isolation, role-based access, audit logs and per-tenant encrypted secrets.
Agents in CloudOEngine run real tools, such as filing a ticket, and every step and tool call is traced and inspectable. When an answer is wrong, you can open that run and look at the evidence before changing candidate depth or swapping reranker models. Where an agent's next step is an action rather than an answer, Autopilot can require a person to approve it, in the app or through an email approve link, before it runs.
CloudOEngine connects to your sources through 500+ connectors and is built in Bengaluru, India.
Book a demo or see the AI runtime.
Frequently asked questions
What is reranking in RAG?
Reranking is a second retrieval stage. A fast search returns a long list of candidate chunks, then a slower, more accurate model scores each candidate against the question and reorders them, and only the top few go to the language model.
What is the difference between a bi-encoder and a cross-encoder?
A bi-encoder turns the question and each document into separate vectors and compares them, so document vectors can be computed and indexed ahead of time. A cross-encoder reads the question and one document together and outputs a single relevance score, which is more accurate but has to run once per pair at query time, so it cannot search a whole collection.
How many results should I rerank?
Enough that the right chunk is almost always somewhere in the list, but few enough to fit your latency budget. Anthropic's contextual retrieval experiments retrieved 150 chunks and kept the top 20 after reranking; the Sentence Transformers documentation uses the top 100 as its example. Measure recall at your candidate depth on your own queries before choosing.
Does reranking add latency?
Yes, because the reranker runs on every candidate for every query. The cost grows with the number of candidates, their length and the size of the reranker model, so small cross-encoders and shorter candidate lists are the usual levers.
Can a reranker fix bad retrieval?
Only partly. A reranker can only reorder what the first stage returned, so if the right chunk is not in the candidate list at all, no reranker will find it. Fix recall first with better chunking or hybrid search, then add a reranker to fix the order.
Can I use an LLM as a reranker?
Yes. The RankGPT paper (Sun et al., EMNLP 2023) found that properly instructed LLMs such as GPT-4 gave competitive or better ranking than supervised methods on standard benchmarks. LLM reranking is slower and costlier per query, and the same paper showed the ranking skill could be distilled into a much smaller model.
Sources
- Passage Re-ranking with BERT (Nogueira and Cho, 2019)
- Anthropic: Introducing Contextual Retrieval (19 Sep 2024)
- Sentence Transformers: Cross-Encoder applications (bi-encoder vs cross-encoder)
- Sentence Transformers: Pretrained Cross-Encoder models (MS MARCO table)
- ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT (Khattab and Zaharia, SIGIR 2020)
- Is ChatGPT Good at Search? Investigating Large Language Models as Re-Ranking Agents (Sun et al., EMNLP 2023)
- Lost in the Middle: How Language Models Use Long Contexts (Liu et al., 2023)
