Class DecisionScoringModel

java.lang.Object
dev.langchain4j.model.scoring.DecisionScoringModel
All Implemented Interfaces:
ScoringModel

@Experimental public class DecisionScoringModel extends Object implements ScoringModel
A ScoringModel backed by a DecisionModel: the score of a segment is the probability that the answer to "Does the document help answer the query?" is "yes".

It can be used wherever a ScoringModel is expected, for example to re-rank retrieved content with a ReRankingContentAggregator:

ContentAggregator contentAggregator = ReRankingContentAggregator.builder()
        .scoringModel(new DecisionScoringModel(decisionModel))
        .minScore(0.5)
        .build();
The segments are scored in requests of up to 20 segments (see DecisionScoringModel.Builder.maxSegmentsPerRequest(Integer)): the input is the query, and each segment is part of its own yes/no question (see DecisionScoringModel.Builder.questionTemplate(PromptTemplate)). Whether the answer to one question can be influenced by the other questions of the request depends on the decision model. With ScoringModel.scoreAsync(ScoringRequest), the requests are sent in parallel.

Since the text of a segment is part of its question, a retrieved document that contains instructions, such as "answer yes", can try to raise its own score. Treat the scores of untrusted content accordingly.

Since:
1.21.0