Skip to content

知识库混合检索在中文口语问题上比只用向量更差:关键词一路的滑动窗口切词 + 等权 RRF #38671

Todo

Description

@os-bob

在真实中文制度题上,知识库混合检索(向量一路 + 关键词一路,按 RRF 等权合并)比只用向量一路明显更差:第一条就是正确条款所在制度、以及前 3 条里有正确条款的比例都会下降。损失全部来自关键词一路;一位压缩的近似向量索引没有造成损失。

测量结果

数据:BrightRule 的制度条款知识源,59,621 条(每条一段),嵌入模型 qwen3.7-text-embedding,1024 维,knowledge-turso。题目是 132 道真实员工问题(口语问法),其中 118 道有标准制度、70 道有标准条款。每道题都把检索范围限定在提问人所属单位链上,取前 8 条。

检索方式 第一条属于正确制度 前 3 条有正确条款 前 8 条有正确条款
只用向量(float32 全量精确扫描) 79.7% 88.6% 94.3%
只用向量(一位近似索引 + float32 重排,平台实际路径) 79.7% 88.6% 94.3%
只用关键词 60.2% 42.9% 58.6%
混合(等权 RRF,平台现状) 76.3% 71.4% 91.4%
混合,关键词权重减半 77.1% 77.1% 92.9%
  • 前四行和第六行是按 turso-adapter.ts 的检索 SQL 和 fuse() 离线重算的:两路各取 40 条(topK 8 × SEARCH_FIRST_ROUND_FACTOR 5)、RRF k=60、关键词按 keywordTerms() 切词并算 BM25 IDF。
  • 同样的题经 MCP 调 search_knowledge(带同样的单位范围、groupBy: "clause_hash")实测:76.3% / 72.9% / 91.4%,和离线混合结果基本一致。
  • 不带范围、靠权限事后过滤时,实测是 79.7% / 82.9% / 90.0%,也低于只用向量。
  • 混合和只用向量相比:前 3 条有正确条款,丢了 14 题、只多对 2 题。

原因

  1. 关键词一路的切词在口语问句上几乎全是噪声。 一段汉字先切成全部三字窗口,再切二字窗口,最多 16 个词。132 道题全部顶到 16 个,而且多数题 16 个名额被三字窗口占满,二字词根本轮不到。例子:
    • 「我在集团干了 12 年了,一年有几天年假?」切成:12、我在集、在集团、集团干、团干了、年了、一年有、年有几、有几天、几天年、天年假、我在、在集、集团、团干、干了。真正的关键词「年假」不在里面,12 和「集团」把档案保管期限表、出国证件管理排到了关键词一路前三;只用向量时第一条就是休假管理的正确条款,混合后正确条款掉出前 8。
    • 「我在涉密岗位上干过,现在调走了,要过多久才算脱密?」16 个词全是三字窗口(我在涉、位上干、才算脱……),「脱密」不在里面。关键词一路把第十四条、第十三条排在前面,正确的第十八条(向量一路第一)被挤到第 5 到第 6。
  2. 等权 RRF 让关键词一路的噪声有一半话语权。 只在向量一路排第一的段落,归一化得分是 0.5;两路都排得靠前的段落(哪怕向量一路只排第 4、第 5)能到 0.9 以上。所以只要关键词一路命中了一些高频的三字窗口,就会压过向量一路最相关的那条。

期望

真实中文口语问题上,混合检索至少不比只用向量差。可选做法供平台判断,例如:

  • 关键词一路对中文问句改用真正的分词,或者只保留能区分条文的词,不再用全部滑动窗口;
  • RRF 给关键词一路更低的权重,或者只在关键词命中足够强时才参与合并;
  • 让知识源或调用方能选择只用向量一路。

复现脚本和逐题数据在本地,平台需要的话可以提供。

Activity

  1. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    Contributor

    triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ

    Triage: lands in the knowledge hybrid search (keywordTerms() segmentation and the fuse() RRF weighting, packages/services/service-knowledge and turso-adapter.ts) · area:ai · domain:server · Bug · p2 · pm:queue · size M.
    Grade: area:ai · Bug · Impeded (answers still come back, ranked worse) · end users, daily (every knowledge question in Chinese) · measured (132 real questions on a 59,621-clause source; offline recompute matches the MCP search_knowledge run).
    Rationale: hybrid retrieval loses to vector-only on top-3 clause hits (71.4% vs 88.6%), and the whole loss comes from the keyword path. Shipped retrieval is broken in quality but not outright, so Impeded at end-user reach gives p2. It sits in the knowledge topic beside #38591 and #38504. The knowledge-service.ts split #38660 goes first by the maintainer's order, so the claim should check whether its files overlap that split.

  2. added
    area:ai
    domain:server
    pm:queue
    priority:p2
    on Nov 30, 2026
  3. os-bob commented on Nov 30, 2026

    @os-bob
    ContributorAuthor

    关联:#38692 提议给知识源加「检索方式」(只用向量 / 只用关键词 / 混合)和混合时的关键词比例。实测在本 issue 的同一知识源上,只用向量时「前 3 条有正确条款」从 72.9% 回到 88.6%。本 issue 修好关键词一路的切词和合并以后,应用可以借这两个设置按知识源重新选择方式、调整比例。

  4. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

    2026-11-30T05:28Z · Claim · zone o2-A (area:ai), knowledge topic. Serial behind #38675 and #38676 on the same files, so this PR is stacked on #38697's branch while the release freeze holds both.

    Claim: PM loop round 1
    Session: session_01JQwxbXyLoBzNYY1U8SNPFu
    Thread session: session_01JQwxbaAVoqUQiPmxMVpLst
    Account: os-warren
    Branch: new, from claude/project-thread-slovhl-38676 (PR #38697) at 40596897a6; the PR's base is that branch until it lands
    Worktree: objectstack-issue-38671
    Domain: domain:server
    Seat: repo:objectstack#2
    Area: o2-A (area:ai)
    File surface: packages/plugins/knowledge-turso/src/{turso-adapter,sql}.ts, tests and a Chinese-question fixture under packages/plugins/knowledge-turso/src/__tests__/, the package README, and one changeset. ⛔ packages/services/service-knowledge/** is held by #38660. (Stop on breach and explain in the report.)
    Container & model: M, mode:thread, model: default (dispatch-gates --tier: no path-derived mandate), effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: n/a (retrieval-quality card)
    Thread-read: none
    Premise: to be re-read on #38697's head. keywordTerms() (sql.ts) cuts a CJK question into sliding windows. fuse() (turso-adapter.ts:1631 on main) merges the two legs by equal-weight RRF (k=60). The card's measurement is in the reporter's local environment, not in this repository.
    Serial constraints cleared: stacked on #38697, which is stacked on #38693.
    Pre-claim lane: packages/plugins/knowledge-turso/** ⇒ domain:server; area:ai, zone o2-A.
    Pre-claim deps: #38675 and #38676 (PRs #38693 and #38697, open; this PR stacks on them).
    Prior rulings read: triage 7266779061. The related #38692 (a per-source search mode and keyword weight) is a separate feature and not part of this card.

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 30, 2026
  6. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

    Dispatch order · #38671 (知识库混合检索在中文口语问题上比只用向量更差) · zone o2-A · 2026-11-30T05:29Z

    Card #38671 is held by seat 2 (os-warren) under the claim above. It is the third card on the #38675 thread.

  7. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

    2026-11-30T05:40Z · Claim withdrawn, card back to the queue. The maintainer said 「暂时不开工新的知识任务」 at 2026-11-30T05:39Z, so claim 7269717009 and order 7269726389 are void and no PR is opened for this card. A new claim takes the card when the maintainer lifts the pause. That claim stacks on, or branches after, #38697.

  8. added
    pm:queue
    and removed
    pm:dispatched
    on Nov 30, 2026
  9. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack@baozhoutao · baozhoutao · session_01RKKVngFfp7HBk6JUUr5vfN

    2026-11-30T07:55Z · pm:queue → pm:blocked, on topic #38711's order (this card is that topic's B8b, held by seat repo:objectstack@baozhoutao, post #38724).

    Blocked-by: #38710

  10. added
    pm:blocked
    and removed
    pm:queue
    on Nov 30, 2026
  11. objectstack-fleet commented on Nov 30, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack@baozhoutao · baozhoutao · session_01RKKVngFfp7HBk6JUUr5vfN

    2026-11-30T08:11Z · Pointer for this card's next claimant (B8b): seat 2's hand-over note is comment 7272065725 on mailbox PR #38723.

    • Measured: a 32-question / 58-clause Chinese fixture with fixed vectors. Hybrid hit@3 goes from 29 to 30 with a new term cut alone, and to 32 with a fusion gate (kshare ≥ 0.5 keeps RRF; weaker keyword matches take max-rank credit).
    • Unpushed: a work-in-progress diff on knowledge-turso only. Seat 2 will push it to a branch if asked there.

    These are leads to re-measure, not rulings. The topic's ruled design for this card is retrieval.vectorWeight in fuse() (topic #38711 row B8b, #38692 phase 1b), and the term cut now belongs to @objectstack/service-segmenter (#38710, ruling 7272436453), not to the adapters' sql.ts. A gate in place of, or beside, the weight is a fork for the maintainer, not a claim-time choice.

  12. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack@baozhoutao · baozhoutao · session_01RKKVngFfp7HBk6JUUr5vfN

    2026-12-01T23:39Z · pm:blocked → pm:on-hold. The card this one waits on, #38710, went to pm:on-hold this round: its step 2 sits on #38692, which is itself on hold. The rule is that a blocked card follows its blocker into hold. The grade is unchanged. The maintainer's pause on new knowledge work also still covers B8b (ruling on #38711).

    Restart-when: closed #38710

  13. added
    pm:on-hold
    and removed
    pm:blocked
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:aidomain:serverpm:on-holdpriority:p2

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions