Reapply "fix(recall): V2 关键词分必须进入最终排序(原被 rerank 整段丢弃)"
This reverts commit 9236d8d4b4.
This commit is contained in:
@@ -455,10 +455,15 @@ func (p *RecallPipeline) recallUncached(query, namespace string, topK int, diver
|
||||
docs[i] = c.Content
|
||||
docVecs[i] = c.Vector
|
||||
}
|
||||
reranked, err := p.reranker.RerankWithVectors(queryVec, docs, docVecs, topK*2)
|
||||
// V2: 重排候选放宽 —— 实测相关记忆 cosine 排名 #126,topK*2(=20) 处就被切掉了。
|
||||
rerankN := topK * 2
|
||||
if recallV2Enabled() && rerankN < 150 {
|
||||
rerankN = 150
|
||||
}
|
||||
reranked, err := p.reranker.RerankWithVectors(queryVec, docs, docVecs, rerankN)
|
||||
if err != nil {
|
||||
log.Printf("[recall] 向量重排跳过(%v),回退文本重排", err)
|
||||
reranked, err = p.reranker.Rerank(query, docs, topK*2)
|
||||
reranked, err = p.reranker.Rerank(query, docs, rerankN)
|
||||
}
|
||||
if err != nil {
|
||||
// 重排不可用时降级:直接使用向量搜索的原始排序
|
||||
@@ -468,6 +473,21 @@ func (p *RecallPipeline) recallUncached(query, namespace string, topK int, diver
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3.6 (V2, 2026-10-14): 关键词分融入**最终**排序。
|
||||
// 为什么必须放在 rerank 之后:Step 3.5 的 BM25 融合作用在 candidates 上,
|
||||
// 而紧接着的 rerank 会按 cosine 重新打分并只留 rerankN 条 ⇒ 关键词分被整段丢弃
|
||||
// (实测:V2 开着与关着结果逐条相同,就是这么丢的)。
|
||||
if recallV2Enabled() {
|
||||
for i := range reranked {
|
||||
idx := reranked[i].Index
|
||||
if idx < 0 || idx >= len(candidates) {
|
||||
continue
|
||||
}
|
||||
kw := ComputeBM25ScoreV2(query, candidates[idx].Content)
|
||||
reranked[i].Score = reranked[i].Score*0.7 + kw*0.3
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3.7: 来源加权偏置(2026-10-09 P0 修正)
|
||||
//
|
||||
// 修前的错位:λ 只加在 Step 4 之后的**展示分**上,而候选的取舍早已由 rerank+MMR 定死
|
||||
|
||||
Reference in New Issue
Block a user