Class DefaultContentAggregator
-
- All Implemented Interfaces:
-
dev.langchain4j.rag.content.aggregator.ContentAggregator
public class DefaultContentAggregator implements ContentAggregator
Default implementation of ContentAggregator intended to be suitable for the majority of use cases. It's important to note that while efforts will be made to avoid breaking changes, the default behavior of this class may be updated in the future if it's found that the current behavior does not adequately serve the majority of use cases. Such changes would be made to benefit both current and future users. This implementation employs Reciprocal Rank Fusion (see ReciprocalRankFuser) in two stages to aggregate all
Collection<List<Content>>into a singleList<Content>. The Contents in both the input and output lists are expected to be sorted by relevance, with the most relevant Contents at the beginning of theList<Content>. Stage 1: For each Query, allList<Content>retrieved with that Query are merged into a singleList<Content>. Stage 2: AllList<Content>(results from stage 1) are merged into a singleList<Content>. Example: Input (query -> multiple lists with ranked contents):
After stage 1 (query -> single list with ranked contents):home animals -> [cat, dog, hamster], [cat, parrot] domestic animals -> [dog, horse], [cat]
After stage 2 (single list with ranked contents):home animals -> [cat, dog, parrot, hamster] domestic animals -> [dog, cat, horse][cat, dog, parrot, horse, hamster]
-
-
Constructor Summary
Constructors Constructor Description DefaultContentAggregator()
-
Method Summary
-
-
Method Detail
-
aggregate
List<Content> aggregate(Map<Query, Collection<List<Content>>> queryToContents)
Aggregates all Contents retrieved by all ContentRetrievers using all Querys. The Contents, both on input and output, are sorted by relevance, with the most relevant Contents appearing at the beginning of
List<Content>.
-
-
-
-