项级分解日志(ZHIYI_DECOMP=1):cosine / bias / pre / spec_f / final

牧尘 2026-11-24 17:0x 判决:判决性实验先于手术文本。

问题:生日案 0.956 压过真答案,胜负差来自偏置(加法项)还是 cosine(词面重合)?
  来自偏置 ⇒ 偏置手术适用
  来自 cosine ⇒ 病三比偏置深,刀重开

实现:Step 3.7 前快照 Score(=cosine),specificity 之后反推 pre=final/f,输出:
  cosine=原始向量分 / bias=四项加法偏置和 / pre=cosine+bias / spec_f / final

门控 ZHIYI_DECOMP=1,默认关 ⇒ 逐位等价现状。
判读:|bias| > |cosine 差| ⇒ 偏置决定胜负;反之 cosine 决定。
This commit is contained in:
小唯
2026-11-24 17:02:39 +08:00
parent dfbcd2af8a
commit 227e5f3453
+37
View File
@@ -1172,6 +1172,21 @@ func (p *RecallPipeline) recallUncached(ctx context.Context, query, namespace st
}
}
// ── 项级分解快照(2026-11-24 17:0x 牧尘判决:判决性实验先于手术文本)──
//
// 问题:「生日案 0.956 压过真答案」的胜负差,来自偏置(加法项)还是 cosine(词面重合)?
// 来自偏置 ⇒ 偏置手术适用;来自 cosine ⇒ 病三比偏置深,刀重开。
// 本快照记录 Step 3.7 之前的分数 —— 此时 Score = cosine(fusionW=1.0 时 Step 3.6 不改值),
// 之后所有 += 都是条目先验偏置,最后 × specificityFactor。
// 门控 ZHIYI_DECOMP=1,默认关 ⇒ 逐位等价现状。
var decompBase []float64
if os.Getenv("ZHIYI_DECOMP") == "1" {
decompBase = make([]float64, len(reranked))
for i := range reranked {
decompBase[i] = reranked[i].Score
}
}
// Step 3.7: 来源加权偏置(2026-10-09 P0 修正)
//
// 修前的错位:λ 只加在 Step 4 之后的**展示分**上,而候选的取舍早已由 rerank+MMR 定死
@@ -1305,6 +1320,28 @@ func (p *RecallPipeline) recallUncached(ctx context.Context, query, namespace st
}
}
// ── 项级分解输出(2026-11-24 17:0x)──
// 格式:cosine=原始向量分 / bias=四项加法偏置之和 / pre=cosine+bias / spec=具体性因子 / final
// 判读:|bias| > |cosine 差| ⇒ 胜负由偏置决定(手术适用);反之由 cosine(词面重合)决定(刀重开)
if decompBase != nil {
for i := 0; i < len(reranked) && i < 5; i++ {
idx := reranked[i].Index
if idx < 0 || idx >= len(candidates) {
continue
}
final := reranked[i].Score
// 反推 pre:若被 specificity 乘过,final = pre × f
f := specificityFactor(candidates[idx].Content, &candidates[idx])
pre := final
if f != 0 && f != 1.0 {
pre = final / f
}
cos := decompBase[i]
log.Printf("[recall][decomp] q=%q pos=%d id=%s cosine=%.6f bias=%+.6f pre=%.6f spec_f=%.4f final=%.6f",
query, i, candidates[idx].ID, cos, pre-cos, pre, f, final)
}
}
// Step 4: MMR diversity
if tr != nil {
tr.Stage("rerank_fusion", stRerank, len(reranked))