Repository navigation
Fix #2: stop citing UTI material for leg/joint pain - #18
Open
xiaoyao-666-coder wants to merge 2 commits into
Open
xiaoyao-666-coder wants to merge 2 commits into
xiaoyao-666-coder wants to merge 2 commits into
Conversation
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
“腿关节持续疼痛”/“腿关节时长疼痛”会把《尿频尿急尿痛的就医提示》当作最相关资料引用进回答,还追问发热、腰背部疼痛、血尿等无关症状。
根因
BM25 是单字 + 2–4 字 n-gram 重叠匹配:查询里真正有区分度的词(腿、关节、膝盖)在 15 条知识里一条都不存在,唯一能匹配上的只是泛化词——尿路感染文档含“疼痛”,感冒/咳嗽/腹泻文档含“持续”。排序完全由泛化词驱动,尿路感染文档以 0.551 的融合分排第一,
draft()再把它当作“和你描述最相关的资料”原文贴进回答。HybridRetriever.search没有任何相关度门槛,不论分数多低都返回 top_k。修复
backend/app/retrieval.py):新增GENERIC_MATCH_TOKENS(疼痛、持续、几天、严重、症状、怎么办、难受等只描述症状属性、不命名主题的词)。search()在融合前过滤候选:查询与文档的重叠词必须至少含一个非泛化词,否则不进入引用。过滤点在search(),一次覆盖 BM25 与 Milvus 远程命中两条通道。backend/app/workflow.py、models.py):retrieve()增加retrieval_insufficient标志(疾病/用药/检查/科室/FAQ 意图实际检索且返回空时置真);draft()在 0 引用且该标志为真时走新分支answer_source="insufficient-data",明确说知识库没有与描述直接相关的资料、现有资料覆盖不到这个主题,并给通用就医建议(症状持续/加重及时线下就诊,胸痛、呼吸困难、意识改变立即就医)。验证
backend/tests/test_leg_pain_citation.py(8 个测试):检索层“腿关节持续疼痛/腿关节时长疼痛/膝盖疼了几天”零引用;“尿频尿急并伴排尿疼痛”仍首位返回尿路感染文档;端到端腿关节疼痛回答含资料不足的明确表述且不含“尿路感染/尿频”,answer_source="insufficient-data"。MEDGUIDE_MODE=test python -m pytest -q backend/tests529 passed(基线 521 + 8 新)。已知局限
Closes #2