Reranker Module
The Reranker module provides concrete implementations for reranking search results to improve relevance.Import
Quick Example
For reranker registry lookups, call
register_default_adapters() once at startup — importing reranker classes no longer auto-registers them (PraisonAI 4.6.156+). See Registering the built-in adapters.Features
- LLM-based relevance scoring with any model
- Cross-encoder neural reranking
- Cohere Rerank API integration
- Batch processing for efficiency
- Async support
Classes
LLMReranker
Uses an LLM to score document relevance to a query.
How it works:
- Prompts the LLM to rate relevance on a 0-10 scale
- Normalizes scores to 0-1 range
- Sorts by score descending
CrossEncoderReranker
Uses sentence-transformers cross-encoder for accurate relevance scoring.
Requires
sentence-transformers package: pip install sentence-transformersCohereReranker
Uses Cohere’s rerank API for high-quality reranking.
Requires
cohere package: pip install cohereMethods
rerank(query, documents, top_k=None)
Rerank documents by relevance to query.
Parameters:
query(str): Search querydocuments(List[str]): Documents to reranktop_k(int, optional): Number of results to return
List[RerankResult] - Reranked documents with scores
arerank(query, documents, top_k=None)
Async reranking that offloads the blocking body via asyncio.to_thread(...), so calling it from an event loop no longer freezes it. Authors of custom rerankers on a natively-async provider should override arerank and await the native call directly — see Native async in custom retrievers / rerankers.
Example: Full RAG Pipeline
Example: Using with Agent
Reranker Selection Guide
Environment Variables
CLI Usage
Related
- Retrieval Module - Retrieve documents
- Vector Store Module - Store documents

