Files
nexus/wiki/concepts/Reciprocal-Rank-Fusion.md

53 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Reciprocal Rank Fusion (RRF)"
type: concept
tags: [search, ranking, fusion, algorithm]
sources: [semantic-memory-search]
last_updated: 2026-04-22
---
## Aliases
- RRF
- Reciprocal Rank Fusion
## Definition
Reciprocal Rank Fusion倒数排名融合是一种多检索器结果融合算法通过对各检索器返回结果的排名取倒数并进行加权求和生成统一的融合排名。无需训练简单高效是混合搜索的标准融合策略。
## Formula
```
RRF_score(d) = Σ 1 / (k + rank_i(d))
其中:
- d = 文档
- rank_i(d) = 检索器 i 对文档 d 的排名从1开始
- k = 平滑参数(通常 k=60作用是减少高排名文档的压倒性优势
```
## Why k=60?
k=60 是一个经验值,来源于 BM25 的默认参数 k1=1.2、b=0.75 的理论推导。选择 k=60 使得排名差异在高位次rank 1 vs rank 2时有明显影响但在低排名rank 50 vs rank 51时影响减弱兼顾早期精确和长尾包容。
## Example
假设有两个检索器对同一查询的结果:
| 文档 | 向量检索排名 | BM25 排名 |
|------|------------|----------|
| A | 1 | 3 |
| B | 2 | 1 |
| C | 3 | 2 |
k=60 时:
- RRF(A) = 1/(60+1) + 1/(60+3) = 0.01639 + 0.01587 = **0.03226**
- RRF(B) = 1/(60+2) + 1/(60+1) = 0.01613 + 0.01639 = **0.03252**
- RRF(C) = 1/(60+3) + 1/(60+2) = 0.01587 + 0.01613 = **0.03200**
最终排名B > A > C
## Connections
- [[Hybrid Search]] — RRF 是混合搜索的标准融合算法
- [[semantic-memory-search]] — memsearch 使用 RRF 融合向量和 BM25 结果
- [[Knowledge-Base-RAG]] — RRF 用于提升知识库检索质量