diff --git a/go/internal/storage/recall.go b/go/internal/storage/recall.go index 471dd61..ea390ce 100644 --- a/go/internal/storage/recall.go +++ b/go/internal/storage/recall.go @@ -1138,7 +1138,35 @@ func (p *RecallPipeline) recallUncached(ctx context.Context, query, namespace st return nil, RecallMeta{CandidatesScanned: poolSize, Truncated: truncated, Status: "partial", PartialReason: "deadline_exceeded"}, nil } stMMR := time.Now() - finalIndices := MMRSelect(reranked, candidates, topK*2, diversity) + // 2026-11-16 t_rerank_hold:rerank「保位」——把**重排前向量序**的前 N 条钉死在头部, + // 只让其余条目参与 cross-encoder/MMR 竞争。 + // 背景:真 rerank 上线后主尺 0.2639→0.5258(+99%),但 6 道 n_da=1 的窄 how-to 题 + // 从 1.00 掉到 0(cross-encoder 把唯一答案那一批压出了 top5)。11-12 离线重放同结论: + // 全重排 0.3724 < 保 top3 0.3900。默认 0 ⇒ MMRSelect 原样调用,逐位等价现状。 + hold := envInt("ZHIYI_RERANK_HOLD", 0) + var finalIndices []int + if hold > 0 && hold < len(candidates) { + keep := hold + if maxKeep := topK * 2; keep > maxKeep { + keep = maxKeep + } + finalIndices = make([]int, 0, topK*2) + for i := 0; i < keep; i++ { + finalIndices = append(finalIndices, i) + } + rest := make([]models.RerankResult, 0, len(reranked)) + for _, r := range reranked { + if r.Index >= keep { + rest = append(rest, r) + } + } + if need := topK*2 - len(finalIndices); need > 0 { + finalIndices = append(finalIndices, MMRSelect(rest, candidates, need, diversity)...) + } + log.Printf("[recall][hold] rerank 保位前 %d 条(共 %d 候选,池 %d)", keep, len(candidates), len(finalIndices)) + } else { + finalIndices = MMRSelect(reranked, candidates, topK*2, diversity) + } // RRF 开启时多取一倍候选进融合池:只在 topK 内部重排不会改变 top5 的**集合**(等于没效果), // 第 6~10 名必须有机会被词面秩抬进前 5,融合才可能有增益。门控关 ⇒ poolN==topK,逐位等价现状。