Files
SuperBizAgent-java/mvp/issues/rag/rag-l0-domain-entity-hint.md

72 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# RAG 将 L0 降级为领域和实体 Hint
**状态**:待规划
**严重程度**:中
**发现时间**:2026-07-05
**范围**:L0 检索、metadata filter、业务可解释性
---
## 背景
当前 L0 是基于 frontmatter / keyword 的轻量检索。它具备可解释性,但不适合作为最终相关性判断。
在引入 Spring AI VectorStore / Retriever 后,L0 更适合从“召回主链路”调整为“检索前处理和解释信号”。
---
## 问题
当前 L0 如果唯一命中,容易被过度信任:
```text
L0 unique hit -> 直接返回 / 优先采信
```
这会带来误召回风险,尤其是关键词过泛、frontmatter 质量不稳定时。
---
## 改造方向
L0 保留,但职责调整为:
1. **Domain detector**
- 识别 query 所属 category/domain。
- 用于 Spring AI retriever metadata filter。
2. **Entity extractor**
- 识别组件名、服务名、指标名、错误码、接口名。
- 用于 query augmentation。
3. **Explainability signal**
- 记录 matched keywords。
- 解释为什么进入某个知识域。
目标链路:
```text
query / payload
-> L0 domain/entity hint
-> metadata filter + query augmentation
-> vector retriever
-> post processor
```
---
## 验收标准
- L0 不再默认作为最终检索结果直接返回。
- L0 命中的 domain/category 能传给 retriever filter。
- L0 命中的实体能进入增强 query 或工具调用记录。
- `tool_invocation` 能展示 L0 matched keywords 和使用方式。
---
## 相关文件
- `src/main/java/com/superbiz/agent/service/KnowledgeIndexService.java`
- `src/main/java/com/superbiz/agent/tool/LookupKnowledgeTool.java`
- `src/main/java/com/superbiz/agent/service/VectorSearchService.java`