Add committed zh judge-prompt cache + enable in Siemens scenarios + docs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
wangwei
2026-07-01 18:15:53 +08:00
co-authored by Copilot
parent 065b0e0f1a
commit 24a8688a34
14 changed files with 1670 additions and 3 deletions
+44 -1
View File
@@ -148,7 +148,50 @@ def run(question: str, **kwargs) -> dict:
这意味着后续你比较不同模型、不同 prompt、不同检索策略时,不需要再靠手工记参数。
## 7. PDF 题库构建
## 7. 中文评判 Prompt 适配
RAGAS 评判 prompt 默认为英文,对中文语料启用中文适配可提升判定一致性(架构设计 §10.5)。
### 配置方式
**场景 YAML**(离线/在线评估场景):
```yaml
judge_language: zh # 启用中文评判(默认 en
```
**Score API**`/api/score``/api/score/async``/api/score/session_async`):
```json
{ "judge_language": "zh", ... }
```
**全局默认**`.env`):
```env
RAGAS_JUDGE_LANGUAGE=zh
```
优先级:请求/场景显式值 > `RAGAS_JUDGE_LANGUAGE`(默认 `en`)。
### 支持的指标
| 指标 | 中文适配 |
|---|---|
| `faithfulness` | ✅ |
| `answer_relevancy` | ✅ |
| `context_recall` | ✅ |
| `context_precision` | ✅ |
| `factual_correctness` | ✅ |
| `noise_sensitivity` | ⚠️ 使用内置函数式 prompt,不支持 adapt,保持英文 |
| `semantic_similarity` | — 无 LLM 调用,不涉及 |
### 缓存机制
中文 prompt 以 JSON 缓存提交在 `configs/judge_prompts/zh/`,运行时零延迟加载。RAGAS 升级后若检测到 prompt 变化(`stale cache` 日志告警),请重新运行:
```bash
python -m scripts.build_judge_prompt_cache --language zh
```
仓库现在额外支持把 PDF 文档解析成可人工复核的在线题库草稿。最推荐的阅读顺序是: