org.llm4s.reranker.LLMReranker
See theLLMReranker companion object
class LLMReranker(client: LLMClient, batchSize: Int, systemPrompt: Option[String]) extends Reranker
LLM-based reranker using a language model to score documents.
Uses a structured prompt to ask the LLM to rate document relevance on a scale of 0 to 1. This is slower and more expensive than cross-encoder rerankers (like Cohere) but works with any LLM.
Usage:
val llmClient = /* build LLMClient with your ProviderConfig */
val reranker = LLMReranker(llmClient)
val request = RerankRequest(
query = "What is Scala?",
documents = Seq("Scala is a programming language", "Python is popular"),
topK = Some(5)
)
val response = reranker.rerank(request)
Value parameters
- batchSize
-
Number of documents to score per LLM call
- client
-
LLM client for generating scores
- systemPrompt
-
Custom system prompt (optional)
Attributes
- Companion
- object
- Graph
-
- Supertypes
Members list
In this article