Skip to content

[bug] recall 中 codebase 结果 min-max 归一化导致得分恒为 10,挤占 learnings #80

Description

@jeff-r2026

现象

teamai recall 把 codebase 图谱结果与 learnings 结果合并排序时,对 codebase 的 BM25 分数做了 min-max 归一化,导致得分最高的 codebase 结果永远等于 10,与其真实相关度无关。弱相关的 codebase 命中也会被钉死在 10 分,从而系统性地挤占 learnings 结果。

实测:构造一个临时 teamwiki,无论 codebase 页内容相关度如何,top 结果都显示 Score: 10.0

根因

// src/recall.ts:287-304
const maxCodeScore = codeResults.length > 0 ? Math.max(...codeResults.map(r => r.score)) : 1;
const normalizer = maxCodeScore > 0 ? 10 / maxCodeScore : 1;
...
score: cr.score * normalizer, // 最高分恒为 10

而 learnings 真实分数(IDF + vote + domain/type 加权,src/utils/search-index.ts:658-691)强命中约 20、弱命中仅 4~8。结果是:3 条 codebase(10 / ~8 / ~6)可占满 top-5 中多席,分数低于 10 的 marginal learnings 被压制。

建议

  • 取消 min-max 归一化,改用绝对阈值maxCodeScore < τ 时不并入)或对数/sigmoid 压缩;
  • 或者将 codebase 命中作为独立 [codebase] 区块输出,不与 learnings 同池竞争排序。

附带:codebase 结果当前被误标为 [docs] 类型标签(src/recall.ts:300),建议改为独立 codebase 类型。

严重程度:高(影响 recall 结果质量)。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions