feat(recall): 新增召回来源诊断信号#280
Merged
Merged
Conversation
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.
背景
Linear issue:LINK-195
当前 RAG 召回链路中,sparse / dense 因分数阈值过滤或无命中返回空列表时,会被
RecallPipeline视为合法成功路,不进入failed_sources。当最终融合候选只剩 BM25 时,对外仍容易被理解为“三路成功的 hybrid 召回”,缺少可观测信号说明本次实际已经退化为 BM25-only。本 PR 按
.specs/link-195/brief.md与已冻结 acceptance 的结论收敛范围:只新增诊断信号供前端、纯召回 JSON、日志和后续模块消费;不改 prompt、生成策略、rerank、Java 落库或错误码。改动内容
召回诊断模型
RecallDiagnostics,包含:source_modedegradedactive_sourcesper_source_countsempty_sourcesfailed_sourcessource_mode:hybrid:bm25 / sparse / dense 都有候选贡献bm25_only:只有 bm25 有候选贡献missing_sparse:bm25 + dense 有候选,sparse 无候选missing_dense:bm25 + sparse 有候选,dense 无候选reason字段不在首版实现中返回。Pipeline 行为
RecallPipeline在完整三路启用且结果落入四态时构造recall_diagnostics。failed_sources仍只表示异常失败路。source_mode,避免扩大 LINK-195 范围。source_mode、active_sources、per_source_counts、empty_sources、failed_sources。对外响应
POST /api/v1/rag/stream的成功终态带出recall_diagnostics:answer_donerecall_donePOST /api/v1/recall成功 JSON 响应带出同构recall_diagnostics。error终态不新增该字段,保持现有错误契约。文档同步
已同步:
docs/api/http_contracts.mddocs/internals/recall_pipeline.mddocs/internals/recall_generation.mddocs/internals/recall_http_api.md非目标
本 PR 明确不做以下事情:
ChatTurnMessage契约。测试
已执行:
结果:
文档同步检查:
结果:
风险与说明
recall_diagnostics是新增字段;旧消费方忽略该字段即可保持兼容。degraded=true不是错误,只表示召回来源结构退化,不能等同于请求失败。emptysource mode。.specs/link-195/为本地 spec-as-test 过程产物,按项目规范不进入提交。