Class ReciprocalRankFuser
java.lang.Object
dev.langchain4j.rag.content.aggregator.ReciprocalRankFuser
Implementation of Reciprocal Rank Fusion.
A comprehensive explanation can be found here.
A comprehensive explanation can be found here.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfuse
(Collection<List<Content>> listsOfContents) Fuses multipleList<Content>
into a singleList<Content>
using the Reciprocal Rank Fusion (RRF) algorithm with k=60.fuse
(Collection<List<Content>> listsOfContents, int k) Fuses multipleList<Content>
into a singleList<Content>
using the Reciprocal Rank Fusion (RRF) algorithm.
-
Constructor Details
-
ReciprocalRankFuser
public ReciprocalRankFuser()
-
-
Method Details
-
fuse
Fuses multipleList<Content>
into a singleList<Content>
using the Reciprocal Rank Fusion (RRF) algorithm with k=60.- Parameters:
listsOfContents
- ACollection
ofList<Content>
to be fused together.- Returns:
- A single
List<Content>
, the result of the fusion.
-
fuse
Fuses multipleList<Content>
into a singleList<Content>
using the Reciprocal Rank Fusion (RRF) algorithm.- Parameters:
listsOfContents
- ACollection
ofList<Content>
to be fused together.k
- A ranking constant used to control the influence of individual ranks from different ranked lists being combined. A common value used is 60, based on empirical studies. However, the optimal value may vary depending on the specific application and the characteristics of the data. A larger value diminishes the differences between the ranks, leading to a more uniform distribution of fusion scores. A smaller value amplifies the importance of the top-ranked items in each list. K must be greater than or equal to 1.- Returns:
- A single
List<Content>
, the result of the fusion.
-