Reranking
Reranking is a second search step that takes a shortlist of results from a fast first search and reorders it with a slower, more accurate model, so that the most relevant items come first.
Searching millions of documents has to be fast, so the first stage of most search systems uses a quick method: keyword matching, or comparing embeddings that were worked out in advance for every document. This kind of embedding model, called a bi-encoder, turns the query and each document into vectors separately. It is fast but imprecise, and its shortlist often includes items that only look relevant.
A reranker fixes the order. Typically a cross-encoder, it reads the query and one candidate document together and outputs a single relevance score. Because it looks at both at once, it judges relevance more accurately, but it is far too slow to run over a whole collection. So systems retrieve perhaps 100 candidates with the fast method, then rerank only those.
Neural reranking took off after Rodrigo Nogueira and Kyunghyun Cho posted Passage Re-ranking with BERT in January 2019. Their simple setup went to the top of the MS MARCO passage retrieval leaderboard, improving the standard MRR@10 measure by 27 per cent relative to the previous best. Rerankers are now sold as services; Cohere's Rerank API, for example, takes a query and a list of documents and returns them with relevance scores, most relevant first.
Reranking matters most in retrieval-augmented generation, where only a handful of passages fit into the model's context. Imagine a staff chatbot asked whether unused holiday can be carried over. The first search returns 100 passages that mention holiday. The reranker moves the paragraph on carrying over leave to the top, above the bank holiday calendar, so the answer is built on the right text.
In practice a reranker adds a little cost and delay to every query, and it can only reorder what the first stage found. If the right document never made the shortlist, no reranker will rescue it. It is a cheap way to improve answer quality when the first-stage search is roughly right but the order is poor.
A reranker is a model that scores how relevant each item on a search shortlist is to the query, and reorders the list by that score. It is used after a faster first search, so it only has to handle a small number of candidates. Many rerankers are cross-encoders built on transformer models. A bi-encoder turns the query and each document into vectors separately, so document vectors can be stored in advance and compared quickly. A cross-encoder reads the query and a document together and gives one score, which is more accurate but much slower. Search systems often use a bi-encoder to retrieve and a cross-encoder to rerank. Not always, but it often helps. If your retrieval step finds the right passages but not in the best order, a reranker can make sure the most relevant ones reach the model's limited context. If retrieval misses the right passages entirely, fix retrieval first. Ranking is the general task of ordering items by relevance or preference. Reranking is a second pass that takes an existing ranked shortlist and reorders it with a more accurate but more expensive model.Common questions
What is a reranker?
What is the difference between a bi-encoder and a cross-encoder?
Do I need reranking for RAG?
Is reranking the same as ranking?
Search for "retrieve and rerank", "cross-encoder reranking" or "reranker RAG" to see how two-stage search is built. The original research papers on arXiv, the documentation of open-source libraries such as Sentence Transformers and the API documentation of reranking services are the most reliable sources. Treat vendor accuracy claims with care unless they name the benchmark and the first-stage search they were tested with.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.