Skip to main content
Rerankers take the initial results from vector search and re-score them using a more powerful model. This second pass significantly improves relevance, especially when the initial retrieval returns many similar results.

How Reranking Works

The vector database finds candidates quickly using embedding similarity. The reranker then reads each candidate alongside the query and produces a more accurate relevance score.

CohereReranker

Uses Cohere’s reranking API:
str
default:"rerank-multilingual-v3.0"
Cohere reranking model. Options: rerank-multilingual-v3.0, rerank-english-v3.0.
str
Cohere API key. Defaults to the COHERE_API_KEY environment variable.
int
Maximum number of results to return after reranking. If not set, returns all reranked results.
Requires the cohere package. Install with pip install cohere.

Using with Knowledge

Set rerank=False to skip reranking for a specific query:

Standalone Usage

Creating a Custom Reranker

Subclass Reranker:

When to Use Reranking

A common pattern is to retrieve more candidates than needed (e.g., top_k=20) and let the reranker select the best 5. This gives the reranker more material to work with.