From 13cf7d20882393fd04e1218ffc90de751b59bb77 Mon Sep 17 00:00:00 2001 From: xiaoyi Date: Mon, 12 Oct 2026 08:23:24 +0800 Subject: [PATCH] =?UTF-8?q?chore(retrieval):=20qstrust=20=E9=80=90?= =?UTF-8?q?=E6=9D=A1=E6=97=A5=E5=BF=97=E9=BB=98=E8=AE=A4=E9=9D=99=E9=9F=B3?= =?UTF-8?q?=EF=BC=88ZHIYI=5FQSTRUST=5FVERBOSE=3D1=20=E5=BC=80=E5=90=AF?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 一次召回可命中上百条,全量打印是生产噪音(实测单次查询 176 行)。 诊断能力保留,改为环境变量开关。 --- go/internal/storage/lancedb_ipc.go | 2 +- go/internal/storage/recall.go | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/go/internal/storage/lancedb_ipc.go b/go/internal/storage/lancedb_ipc.go index 227366c..762e8a1 100644 --- a/go/internal/storage/lancedb_ipc.go +++ b/go/internal/storage/lancedb_ipc.go @@ -269,7 +269,7 @@ func (rc *RustLanceDBClient) Search(table string, vector []float32, topK int, na if qsTrusted { // QualityScore from LLM (0-1) + computed importance, capped at 1.0 finalQuality = math.Min(0.4*computedImportance+0.6*r.QualityScore, 1.0) - } else { + } else if qstrustVerbose { log.Printf("[qstrust-ipc] 不可信质量分已剔除 id=%s rawQS=%.6f → 仅用 importance %.4f", r.ID, r.QualityScore, computedImportance) } diff --git a/go/internal/storage/recall.go b/go/internal/storage/recall.go index b6f3c13..c3b9900 100644 --- a/go/internal/storage/recall.go +++ b/go/internal/storage/recall.go @@ -97,6 +97,11 @@ func (p *RecallPipeline) SetMissRecorder(mr MissRecorder) { p.recordMiss = mr } +// qstrustVerbose 控制"不可信质量分已剔除"的逐条日志。 +// 默认关闭:一次召回可命中上百条,全量打印会淹没生产日志。 +// 诊断时置 ZHIYI_QSTRUST_VERBOSE=1。 +var qstrustVerbose = os.Getenv("ZHIYI_QSTRUST_VERBOSE") == "1" + // RecallMeta RecallWithMeta 返回的召回元数据(t_949840b1:candidates_scanned 名实相符)。 // CandidatesScanned = 粗检索候选池真实大小(LanceDB ANN 检索返回 + 去重 + // 原始对话过滤之后的候选数,在 rerank/MMR 截断之前捕获)。 @@ -252,8 +257,12 @@ func (p *RecallPipeline) recallUncached(query, namespace string, topK int, diver // 存量分数不可信(0=未打分 / 0.755=历史常量 bug,见 models.IsReliableQuality) // → 不拿假分数参与排序,权重全部让给关键词分。 // 注意这是**中性**处理:既不奖励也不惩罚,只是不采信。 - log.Printf("[qstrust] 不可信质量分已剔除 id=%s rawQS=%.6f → 回退纯关键词分 %.4f", - candidates[i].ID, qsForTrust, kwScore) + if qstrustVerbose { + // 默认静音:每次召回会命中上百条,全量打印是生产噪音。 + // 需要诊断时置环境变量 ZHIYI_QSTRUST_VERBOSE=1。 + log.Printf("[qstrust] 不可信质量分已剔除 id=%s rawQS=%.6f → 回退纯关键词分 %.4f", + candidates[i].ID, qsForTrust, kwScore) + } candidates[i].QualityScore = kwScore } }