# RAG 检索质量报告 ## 1. 目的 这份报告回答一个面试关键问题: ```text 迁移到 Spring AI VectorStore 后,怎么证明检索质量没有退化? ``` 这不是完整 benchmark,而是针对当前 Milvus/Zilliz collection 的代表性 live smoke comparison。 ## 2. 验证设置 服务端点: ```text GET http://127.0.0.1:9900/api/search/similar ``` collection: ```text biz ``` 对比模式: ```text retrieval.vector-store.mode=sdk retrieval.vector-store.mode=spring-ai ``` 每个 case: ```text topK=3 ``` ## 3. 测试案例 | Case | Query | 目的 | |---|---|---| | `err-timeout` | `ERR_TIMEOUT` | 精确错误码检索 | | `payment-service-timeout` | `payment-service timeout` | 服务超时排障 | | `mysql-connection-pool` | `MySQL connection pool is exhausted. How should I diagnose it?` | 数据库排障 | | `high-cpu-payment` | `HighCPUUsage payment-service` | AIOps 告警式检索 | | `rag-l0-l1` | `Should L0 keyword matching decide the final retrieval result?` | 抽象 RAG 设计问题 | | `database-filter` | `mysql timeout`, category=`database` | metadata filter 行为 | ## 4. 对比摘要 | Case | SDK 数量 | VectorStore 数量 | Top1 一致 | TopK 重叠 | 结论 | |---|---:|---:|---|---:|---| | `err-timeout` | 3 | 3 | 是 | 3/3 | 文档和顺序一致 | | `payment-service-timeout` | 3 | 3 | 是 | 3/3 | 文档和顺序一致 | | `mysql-connection-pool` | 3 | 3 | 是 | 3/3 | 文档和顺序一致 | | `high-cpu-payment` | 3 | 3 | 是 | 3/3 | AIOps 核心 query 一致 | | `rag-l0-l1` | 3 | 1 | 是 | 1/3 | VectorStore 尾部结果更少 | | `database-filter` | 0 | 0 | 不适用 | 不适用 | filter 行为一致,taxonomy 有问题 | ## 5. 代表性结果 ### ERR_TIMEOUT SDK: ```text 1. ERR_TIMEOUT score=0.5659486 label=l2_distance 2. ERR_GATEWAY_TIMEOUT score=0.6048740 label=l2_distance 3. Error handling score=0.7735061 label=l2_distance ``` VectorStore: ```text 1. ERR_TIMEOUT score=0.5659486 rawScore=0.4340513 label=similarity 2. ERR_GATEWAY_TIMEOUT score=0.6048740 rawScore=0.3951259 label=similarity 3. Error handling score=0.7735061 rawScore=0.2264938 label=similarity ``` 解释: - 排序一致。 - 兼容 `score` 与 SDK L2 distance 一致。 - `rawScore` 暴露 Spring AI similarity。 ### MySQL connection pool 两条路径都返回: ```text 1. MySQL connection pool config 2. wait_timeout timeout 3. idle-timeout ``` 说明迁移保留了核心基础设施排障检索能力。 ### HighCPUUsage payment-service 两条路径都返回 payment-service 高 CPU 相关排障文档,说明 AIOps 告警式 query 没有退化。 ### rag-l0-l1 VectorStore 只返回一个候选,但 Top1 与 SDK 一致。这说明抽象设计类 query 需要后续 query rewrite、补充索引或 threshold 调整。 ### database-filter 两条路径都返回 0,因为相关 MySQL 文档当前分类是 `infrastructure`,不是 `database`。这是 metadata taxonomy 问题,不是 VectorStore 回归。 ## 6. 分数兼容结论 对比验证了当前分数设计: ```text SDK: score = L2 distance rawScore = L2 distance scoreLabel = l2_distance VectorStore: score = Milvus metadata.distance rawScore = Spring AI similarity scoreLabel = similarity ``` 这样既保持 `lookup_knowledge` 原有归一化逻辑,又能暴露 VectorStore 语义。 ## 7. 验收结论 Spring AI VectorStore 读路径可以接受用于当前 MVP/面试: - 核心排障和 AIOps case 与 SDK top3 一致。 - 分数兼容性保留。 - VectorStore 语义通过 `rawScore` 和 `scoreLabel` 可观察。 - SDK fallback 仍保留运行安全。 后续检索质量工作不阻塞这次迁移,应作为独立优化继续推进。 ## 8. 下一步 - 增加自动 live comparison 脚本。 - 在 offline evaluator 中加入 topK overlap、top1 hit、MRR。 - 规范 metadata category,例如 `database` 与 `infrastructure`。 - 为抽象设计类 query 增加 query rewriting。 - 后续再评估是否迁移写入路径到 `VectorStore.add(...)`。