Class DecisionDocumentReranker.Builder
java.lang.Object
org.springframework.ai.rag.postretrieval.document.DecisionDocumentReranker.Builder
- Enclosing class:
- DecisionDocumentReranker
Builder for
DecisionDocumentReranker.- Since:
- 2.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intHow many documents are judged at once unless an executor is given.static final DurationThe timeout unless one is given. -
Method Summary
Modifier and TypeMethodDescriptionbuild()concurrency(int concurrency) How many documents to judge at the same time.Where the per-document calls run, for example a pool shared with the rest of the application or one backed by virtual threads.minimumScore(double minimumScore) Drops documents whose score is below this value.options(@Nullable DecisionOptions options) Options sent with every prompt, such as the model to use.question(YesNoQuestion question) Replaces the relevance question.How long one request waits for all its documents to be judged, no matter how many there are.topK(int topK) virtualThreads(boolean virtualThreads) Runs the per-document calls on virtual threads instead of platform threads, keeping theconcurrency limit.
-
Field Details
-
DEFAULT_CONCURRENCY
public static final int DEFAULT_CONCURRENCYHow many documents are judged at once unless an executor is given.- See Also:
-
DEFAULT_TIMEOUT
The timeout unless one is given.
-
-
Method Details
-
question
Replaces the relevance question. Write it aboutqueryandpassage, which are the two fields of the input.- Parameters:
question- the question- Returns:
- this builder
-
options
Options sent with every prompt, such as the model to use.- Parameters:
options- the options, ornullfor the model's defaults- Returns:
- this builder
-
topK
- Parameters:
topK- how many documents to keep after reordering- Returns:
- this builder
-
minimumScore
Drops documents whose score is below this value. At zero nothing is dropped and the reranker only reorders. Unscored documents are never dropped by it.- Parameters:
minimumScore- the lowest score worth keeping, between 0 and 1- Returns:
- this builder
-
timeout
How long one request waits for all its documents to be judged, no matter how many there are. Documents still unjudged when the time is up are kept unscored, after the scored ones. Calls already running finish; calls still waiting in the queue are skipped. If you supply your ownexecutor, it must not block when a call is submitted, because that blocked time cannot be cut short.- Parameters:
timeout- the timeout, positive- Returns:
- this builder
-
concurrency
How many documents to judge at the same time. The limit is per instance, so it caps the calls in flight across all requests going through this reranker, which is what a provider rate limit needs. Ignored when anexecutoris given; the executor then sets its own limit.- Parameters:
concurrency- the number of calls in flight together, at least 1- Returns:
- this builder
-
virtualThreads
Runs the per-document calls on virtual threads instead of platform threads, keeping theconcurrency limit. Needs JDK 21 or later; on an older JDKbuild()fails. Ignored when anexecutoris given.- Parameters:
virtualThreads- whether to use virtual threads- Returns:
- this builder
-
executor
Where the per-document calls run, for example a pool shared with the rest of the application or one backed by virtual threads.- Parameters:
executor- the executor- Returns:
- this builder
-
build
-