# Reranking Retrieved Results

> Retrieve broadly, then use a cross-encoder or LLM reranker to put the truly relevant chunks at the top before generation. Free notes, key concepts, resources...

Canonical: https://www.internhack.in/roadmaps/tracks/ai-engineer/reranking
Last updated: 2026-11-28

Retrieve broadly, then use a cross-encoder or LLM reranker to put the truly relevant chunks at the top before generation.

Intermediate · about 3 hours · difficulty 3/5

Learn first: [Hybrid Search: Keywords Plus Vectors](https://www.internhack.in/roadmaps/tracks/ai-engineer/hybrid-search)

First-stage retrieval (vector or hybrid) is fast but coarse. A **reranker** takes the query plus, say, the top 50 candidates and scores each pair carefully, then you keep the best 5 to 10 for the prompt.

### Why rerankers are more accurate

Embedding models encode query and document **separately** (bi-encoders), so they cannot compare them word by word. **Cross-encoder** rerankers read the query and the chunk **together**, which captures fine-grained relevance at the cost of more compute per pair. That is why they are only applied to a shortlist.

### Options

- Hosted rerank APIs (for example from Cohere, Voyage, Jina).
- Open cross-encoder models via sentence-transformers or other open rerankers, run locally.
- **LLM-as-reranker**: ask a small model to score or order candidates. Flexible, slower and pricier.

### Tuning

- Candidate count (retrieve 20 to 100) versus latency.
- Final k: fewer, better chunks often produce better answers than many mediocre ones.
- A minimum relevance score to drop junk and let the model say "not found".

### Pitfalls

Rerankers add latency (tens to hundreds of milliseconds). Measure end-to-end impact; if first-stage retrieval never finds the right chunk, reranking cannot help.

### Good enough to move on

You can add a reranker to your pipeline and show improved precision in the top results on your test questions.

## Key concepts

- **Bi-encoders vs cross-encoders**
- **Hosted rerank APIs**
- **Open-source cross-encoders**
- **LLM-based reranking**
- **Candidate count and final k**
- **Relevance thresholds**

## Mini project

Add a cross-encoder reranker over the top 30 hybrid results in your RAG app, and measure precision at 5 and latency before and after.

## Check yourself

Why not simply use a cross-encoder to score every document in the corpus?

## Free resources

- [Sentence Transformers: cross-encoders](https://www.sbert.net/docs/cross_encoder/usage/usage.html) (SBERT)
- [Cohere docs: rerank](https://docs.cohere.com/docs/rerank-overview) (Cohere)

Previous: [Hybrid Search: Keywords Plus Vectors](https://www.internhack.in/roadmaps/tracks/ai-engineer/hybrid-search) · Next: [Citations and Grounded Answers](https://www.internhack.in/roadmaps/tracks/ai-engineer/citations-grounding)

## More in Retrieval-Augmented Generation

- [RAG Fundamentals](https://www.internhack.in/roadmaps/tracks/ai-engineer/rag-basics)
- [Document Ingestion and Parsing](https://www.internhack.in/roadmaps/tracks/ai-engineer/document-ingestion)
- [Hybrid Search: Keywords Plus Vectors](https://www.internhack.in/roadmaps/tracks/ai-engineer/hybrid-search)
- [Reranking Retrieved Results](https://www.internhack.in/roadmaps/tracks/ai-engineer/reranking)
- [Citations and Grounded Answers](https://www.internhack.in/roadmaps/tracks/ai-engineer/citations-grounding)
- [Evaluating Retrieval Quality](https://www.internhack.in/roadmaps/tracks/ai-engineer/retrieval-evaluation)
- [Advanced RAG Patterns](https://www.internhack.in/roadmaps/tracks/ai-engineer/advanced-rag)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [AI Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/ai-engineer)
