Memo::RRF
Reciprocal Rank Fusion (RRF) for combining ranked search results
NOTE: This is a client utility - kept for backwards compatibility (used by Copious). For new code, consider TF-IDF weighted semantic scoring instead.
TODO: Add TF-IDF weighting option to semantic search - boost scores based on term relevance rather than merging separate ranked lists.
RRF merges multiple ranked lists by computing a score based on rank position: score = 1 / (k + rank)
Where k is a constant (typically 60) that reduces the impact of high ranks.
Benefits over simple score merging:
- Rank-based, not score-based (handles different scoring scales)
- No score normalization needed
- Proven effective in information retrieval (IR research)
Example:
keyword_results = [
RRF::Item.new(id: 1, score: 10.0),
RRF::Item.new(id: 2, score: 8.0),
]
semantic_results = [
RRF::Item.new(id: 2, score: 0.95),
RRF::Item.new(id: 3, score: 0.85),
]
merged = RRF.merge([keyword_results, semantic_results])
# Result: [id=2 (in both lists), id=1, id=3]
Constants
DEFAULT_K = 60
Default k constant for RRF algorithm