feat: 添加 RAG 评估模块,支持召回率和相关性评估
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Failing after 6m13s

This commit is contained in:
2026-04-26 15:39:05 +08:00
parent 6404ea8c42
commit 92863e86dc
4 changed files with 864 additions and 0 deletions

View File

@@ -664,6 +664,31 @@ def reciprocal_rank_fusion(doc_lists: List[List[Document]], k: int = 60) -> List
- 兼容 OpenAI Rerank API 格式
- 超时保护60 秒超时,失败时降级为原始排序
---
### 1.5 RAG 评估方法 ⭐
如何评估 RAG 系统的召回率和相关性?
**核心指标:**
- **Recall@k**:前 k 个结果中包含多少比例的相关文档
- **Precision@k**:前 k 个结果中有多少比例是相关文档
- **F1@k**:召回率和精确率的调和平均数
- **MRR**:平均倒数排名
- **相关性评分**0-5 分的相关性评估
**详细指南:**
参见 [backend/docs/RAG_EVALUATION_GUIDE.md](backend/docs/RAG_EVALUATION_GUIDE.md)
**快速使用:**
```bash
# 运行评估脚本
cd backend
python scripts/evaluate_rag.py
```
---
### 2. LangGraph 工作流算法
#### 2.1 React (Reasoning → Acting → Observing) 模式 ⭐