Interface ScoringModel
- All Known Implementing Classes:
CohereScoringModel, JinaScoringModel, OnnxScoringModel, VertexAiScoringModel, VoyageAiScoringModel, WatsonxScoringModel
public interface ScoringModel
Represents a model capable of scoring a text against a query.
Useful for identifying the most relevant texts when scoring multiple texts against the same query.
The scoring model can be employed for re-ranking purposes.
Useful for identifying the most relevant texts when scoring multiple texts against the same query.
The scoring model can be employed for re-ranking purposes.
-
Method Summary
Modifier and TypeMethodDescriptiondefault ScoringRequestParametersThe model's default per-call parameters, applied byscoreAsync(ScoringRequest)to every request and overridden by any parameters set on the request itself.default CompletableFuture<ScoringResponse> doScoreAsync(ScoringRequest request) The provider hook behindscoreAsync(ScoringRequest).score(TextSegment segment, String query) Scores a givenTextSegmentagainst a given query.Scores a given text against a given query.scoreAll(List<TextSegment> segments, String query) Scores all providedTextSegments against a given query.default CompletableFuture<ScoringResponse> scoreAsync(ScoringRequest request) Scores thedocumentsof the given request against itsquerywithout blocking the calling thread — the asynchronous/reactive counterpart ofscoreAll(List, String), used by the non-blocking RAG flow (seeReRankingContentAggregator).
-
Method Details
-
score
-
score
Scores a givenTextSegmentagainst a given query.- Parameters:
segment- TheTextSegmentto be scored.query- The query against which to score the segment.- Returns:
- the score.
-
scoreAll
Scores all providedTextSegments against a given query.- Parameters:
segments- The list ofTextSegments to score.query- The query against which to score the segments.- Returns:
- the list of scores. The order of scores corresponds to the order of
TextSegments.
-
scoreAsync
Scores thedocumentsof the given request against itsquerywithout blocking the calling thread — the asynchronous/reactive counterpart ofscoreAll(List, String), used by the non-blocking RAG flow (seeReRankingContentAggregator).This applies the model's
default parametersand dispatches todoScoreAsync(ScoringRequest); a model becomes genuinely non-blocking by overriding the latter.- Parameters:
request- the documents to score, the query, and the per-call parameters.- Returns:
- a
CompletableFutureof the scores, in the order ofScoringRequest.documents(). - Since:
- 1.20.0
-
doScoreAsync
The provider hook behindscoreAsync(ScoringRequest). The default returns a failed future carryingAsyncNotSupportedException: a scoring model that is not genuinely asynchronous does not pretend to be. A model backed by remote HTTP I/O opts in by overriding this with a genuinely async call (no thread parked), and should abort its in-flight call when the returned future is cancelled (best-effort). A model that has not opted in fails loudly on the async path rather than silently blocking a carrier thread.- Parameters:
request- the (already defaults-applied) request to score.- Returns:
- a
CompletableFutureof the scores, in the order ofScoringRequest.documents(). - Since:
- 1.20.0
-
defaultRequestParameters
The model's default per-call parameters, applied byscoreAsync(ScoringRequest)to every request and overridden by any parameters set on the request itself. The default isScoringRequestParameters.EMPTY.- Since:
- 1.20.0
-