Class ReRankingContentAggregator

java.lang.Object
dev.langchain4j.rag.content.aggregator.ReRankingContentAggregator
All Implemented Interfaces:
ContentAggregator

public class ReRankingContentAggregator extends Object implements ContentAggregator
A ContentAggregator that performs re-ranking using a ScoringModel, such as Cohere.
The ScoringModel scores Contents against a (single) Query. If multiple Querys are input to this aggregator (for example, when using ExpandingQueryTransformer), a querySelector must be provided to select a Query for ranking all Contents. Alternatively, a custom implementation can be created to score Contents against the Querys that were used for their retrieval (instead of a single Query), and then re-rank based on those scores. Although potentially more costly, this method may yield better results when the Querys are significantly different.

Before the use of a ScoringModel, all Contents are fused in the same way as by the DefaultContentAggregator. For detailed information, please refer to its Javadoc.

Configurable parameters (optional):
- minScore: the minimum score for Contents to be returned. Contents scoring below this threshold (as determined by the ScoringModel) are excluded from the results.
See Also: