Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Reranker Module
The Reranker module provides concrete implementations for reranking search results to improve relevance.Import
Quick Example
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.
| Parameter | Type | Default | Description |
|---|---|---|---|
llm | Any | None | Custom LLM instance (Agent) |
model | str | "gpt-4o-mini" | Model for scoring |
batch_size | int | 5 | Documents per batch |
- 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
model_name | str | "cross-encoder/ms-marco-MiniLM-L-6-v2" | Cross-encoder model |
Requires
sentence-transformers package: pip install sentence-transformersCohereReranker
Uses Cohere’s rerank API for high-quality reranking.
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | COHERE_API_KEY env | Cohere API key |
model | str | "rerank-english-v3.0" | Rerank model |
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 version of rerank (calls sync internally).
Example: Full RAG Pipeline
Example: Using with Agent
Reranker Selection Guide
| Use Case | Recommended |
|---|---|
| Best accuracy | CohereReranker |
| Local/offline | CrossEncoderReranker |
| Already using LLM | LLMReranker |
| Fast, no dependencies | Skip reranking |
Environment Variables
CLI Usage
Related
- Retrieval Module - Retrieve documents
- Vector Store Module - Store documents

