RerankerFactory
Factory for creating Reranker instances.
Supports multiple backends:
- Cohere: Cloud-based cross-encoder reranking API
- LLM: Use existing LLMClient for reranking with structured prompts
- None: Passthrough that preserves original order
Usage:
// Cohere reranker from explicit config
val reranker = RerankerFactory.cohere(config)
// LLM-based reranker
val llmReranker = RerankerFactory.llm(llmClient)
// From provided config
val reranker = RerankerFactory.fromConfig(Some(config))
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
RerankerFactory.type
Members list
Type members
Classlikes
Value members
Concrete methods
Create a Cohere reranker from config.
Create a Cohere reranker from config.
Value parameters
- config
-
Provider configuration
Attributes
- Returns
-
Cohere reranker
Create a Cohere reranker from individual parameters.
Create a Cohere reranker from individual parameters.
Value parameters
- apiKey
-
Cohere API key
- baseUrl
-
API base URL (default: https://api.cohere.ai)
- model
-
Reranking model (default: rerank-english-v3.0)
Attributes
- Returns
-
Cohere reranker
Create a reranker from an optional typed configuration.
Create a reranker from an optional typed configuration.
Value parameters
- config
-
Optional provider configuration
Attributes
- Returns
-
Optional reranker (None if disabled)
Create an LLM-based reranker.
Create an LLM-based reranker.
Uses a language model to score document relevance on a 0-1 scale. This is more flexible than Cohere (works with any LLM) but slower and may be more expensive depending on the model.
Value parameters
- batchSize
-
Number of documents to score per LLM call (default: 10)
- client
-
LLM client for generating scores
- systemPrompt
-
Custom system prompt (optional)
Attributes
- Returns
-
LLM-based reranker
Concrete fields
No-op reranker that passes through results unchanged.
No-op reranker that passes through results unchanged.
Useful for testing or when reranking is disabled. Results preserve original order with monotonically decreasing scores.