Repository navigation
fix(knowledge): 活动代次过滤不再列举每个文件 - #1206
Closed
PlankBevelen wants to merge 1 commit into
Closed
PlankBevelen wants to merge 1 commit into
PlankBevelen wants to merge 1 commit into
Conversation
Owner
|
感谢 PR,思路是合理的。确认一下:是否已在真实 Milvus 上做过查询验证,以及是否完全没有数据迁移方面的顾虑? |
Owner
|
感谢 @PlankBevelen 发现活动文件 ID 导致过滤表达式膨胀。替代 PR #1216 通过参数绑定缩短表达式,并在 Milvus 截取 top-k 前排除同代残留。替代提交的适用 CI 已通过,相关复现和验证见 #1216。 |
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.
同分支的 #1197 因描述编码损坏被关闭。这次用 GitHub CLI 重新提交,代码没有改。
简介
每次向量、BM25、混合检索和图检索,都会把知识库里每个未删除文件的
file_id写进 Milvus 过滤表达式。文件一多,表达式会超长,检索失败。旧代次又不能放行,否则会占满 top-k。这次仍按每个文件的
active_generation限定可见范围。全体文件同一代次时只写generation == N;否则以文件数最多的代次为多数,用file_id not in排除例外,只有少数代次才列出文件。空知识库仍是file_id in []。排序不变。具体改动与影响
非平凡 bug 修复。入口是
_build_active_generation_expr,向量、关键词、混合和图检索都复用它。不改打分,不给现有集合新增字段。每个文件各有独立代次时,例外列表仍然很长。
实现依据与设计取舍
关键行为与实现边界
可见集合仍是 PostgreSQL 里未删除文件的当前代次。事实在
backend/yuxi/modules/knowledge/implementations/milvus.py。没有新增
active字段。现有集合的可检索检查不包含这个列,查询里写active == true会让未迁移的集合失败。决策记录
2026-11-24-milvus-active-generation-filter.md。没有先写 proposal:过滤式的收窄和测试在同一变更里完成。
验证情况
行为验证
单代次不列出每个 file_id:
test_single_generation_does_not_list_every_file。表达式出现file-4会失败。Passed。少数代次才被点名:
test_minority_generation_is_the_only_explicit_file_list。Passed。文件数相同时取较小代次:
test_tied_generations_prefer_the_lower_generation。Passed。空知识库不命中:
test_empty_knowledge_base_matches_no_file。Passed。提交检查
在 Linux 容器中执行
test/unit/knowledge/test_milvus_active_generation_expr.py。Passed。工程契约脚本和完整
test/unit:Not run。独立审阅、风险与事故反馈
独立审阅
没有另开不继承实现上下文的 Reviewer。实现者对照 diff 和上述测试自查。
未验证范围与已知风险
没有对真实 Milvus 发查询。代次极度分散时表达式仍可能超长。
事故反馈
未达到复盘门槛。