Class ReciprocalRankFusion
RRF is a simple, parameter-light method for combining rankings.
For each item, the fused score is the sum across all rankings of
1 / (k + rank), where rank is 1-based and k is a constant
(default 60) that mitigates the impact of high rankings.
Reference: Cormack, Clarke & Buettcher, "Reciprocal Rank Fusion outperforms Condorcet and individual Rank Learning Methods", SIGIR 2009.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault k constant. 60 is the standard value from the RRF paper. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an RRF combiner with the default k=60.ReciprocalRankFusion(int k) Creates an RRF combiner with a custom k value. -
Method Summary
Modifier and TypeMethodDescriptionfinal List<ScoredEntry> fuse(int topK, List<ScoredEntry>... rankedLists) Fuses multiple ranked lists into a single ranked list.final List<ScoredEntry> fuseNormalized(int topK, List<ScoredEntry>... rankedLists) Fuses ranked lists and normalizes the fused scores to0.0..1.0.intk()Returns the k constant used by this combiner.
-
Field Details
-
DEFAULT_K
public static final int DEFAULT_KDefault k constant. 60 is the standard value from the RRF paper.- See Also:
-
-
Constructor Details
-
ReciprocalRankFusion
public ReciprocalRankFusion()Creates an RRF combiner with the default k=60. -
ReciprocalRankFusion
public ReciprocalRankFusion(int k) Creates an RRF combiner with a custom k value.- Parameters:
k- the rank constant (must be positive)
-
-
Method Details
-
fuse
Fuses multiple ranked lists into a single ranked list.Each input list should be sorted by relevance (most relevant first). The fused score for each entry is the sum of
1/(k+rank)across all lists where it appears.- Parameters:
topK- maximum number of results to returnrankedLists- the ranked result lists to fuse- Returns:
- fused and re-scored entries, sorted by descending fused score
-
fuseNormalized
@SafeVarargs public final List<ScoredEntry> fuseNormalized(int topK, List<ScoredEntry>... rankedLists) Fuses ranked lists and normalizes the fused scores to0.0..1.0.The normalization ceiling is the score an entry would receive at rank one in every non-empty input list:
activeLists * (1 / (k + 1)). Empty lists therefore do not dilute the score, while an entry present at rank one in every active list receives1.0. The publicfuse(int, List[])method keeps exposing raw RRF scores for callers that rely on the standard formula.- Parameters:
topK- maximum number of results to returnrankedLists- the ranked result lists to fuse- Returns:
- fused entries with bounded scores, sorted by descending score
-
k
public int k()Returns the k constant used by this combiner.
-