Re-ranking
RAG Strategy (Source: Ottomator Agents)
What It Is
A two-stage retrieval process:
- Stage 1: Perform a broad Vector Search to find a larger set of candidates (20-50+).
- Stage 2: Use a specialised Ranking engine to filter and rank these candidates against the query, passing only the top K (e.g., 5) to the LLM.
As your content in RAG grows, the chances of getting the correct content get lower, and this has a degrading effect on the model since LLMs tend to use that context and build upon it and confidently hallucinate, so no context is better than bad context. Since we can't keep on increasing the chunk numbers to not blow out the Context Window, we can rerank the fetched data and only send the chunks that rank at the top.
We have three categories of rerankers for RAG: (1) Cross-encoder models, (2) LLM-based rerankers, and (3) built-in/vector-DB or framework integrations.
Cross-encoder rerankers (ML models)
These take a (query, document) pair and output a relevance score, and are the current workhorse for RAG reranking.
- Cohere Rerank (API): strong out-of-the-box quality, popular in production RAG; often cited as a big “bang for buck” upgrade over plain vector search.
- BGE / m3 / E5 cross-encoders on Hugging Face: open-source rerankers you can self-host and plug into FAISS, Chroma, Qdrant, etc.
- ColBERT / ColBERT-v2: late-interaction architecture that works very well as a reranker and has LlamaIndex integrations.
- OpenSearch cross-encoder reranking: built-in pipeline step that applies a cross-encoder rerank processor to initial search results.
Typical pattern: retrieve top-100 with a Bi-encoder/vector DB, rerank down to top-10 with cross-encoder, send those to the LLM.
LLM-based rerankers
Here you prompt an LLM to rank or score a list of candidate passages.
- Prompting styles: pointwise (score each passage), listwise (return ordered list), or pairwise (compare two at a time, highest quality but slowest).
- Frameworks:
- RankLLM: specialized reranking framework that supports listwise LLM reranking and cross-encoders; integrates with FAISS/Chroma and LangChain.
- DIY with tools like Instructor + Pydantic to structure LLM outputs into ranked lists.
These can capture richer semantics but add latency and cost; often used when you already pay for a strong LLM and want maximum relevance for a small top-K.
Built-in/vector-DB and platform rerankers
Many hosted/vector systems now bake reranking in as a switch or parameter.
- Pinecone:
inference.rerankAPI that takes initial vector results, and returns reranked docs with relevance scores. - Mosaic AI Vector Search (Databricks): reranking as a one-parameter toggle in the vector search API, reported average +15pp agent quality boost.
- Vectorize: retrieval endpoint with
rerank=truethat performs two-stage retrieval+rerank and returns both similarity and relevance scores.
These are good if you already use the respective platform and want minimal integration work.
RAG libraries with rerank support
If you’re using a RAG framework, many have first-class rerank hooks.
- LlamaIndex: pluggable reranker interface; common examples use ColBERT or cross-encoders.
- LangChain: integrates with RankLLM and Hugging Face / Cohere rerankers; you can insert a rerank step in the retriever pipeline.
- RAGAS + custom rerankers: while RAGAS is mainly for evaluation, many guides show adding a reranker step and then using RAGAS to measure the gain.
These are convenient if you’re already orchestrating your agents with those libraries.
Practical selection guidelines
- Tight latency / self-hosted: start with a small open-source cross-encoder (e.g., BGE-reranker) over top-50–100 candidates.
- Cloud-first, minimal infra: Cohere Rerank or platform-native rerankers in Pinecone, Mosaic, or Vectorise.
- Maximum quality, low QPS: LLM-based listwise rerank via RankLLM or custom prompts, possibly on top of a cross-encoder.
Pros & Cons
- ✅ Pros: Significantly better precision. Allows more potential knowledge to be considered without overwhelming the LLM's context.
- ❌ Cons: Slightly slower than pure vector search. Increases compute cost per query.
