260 lines
7.2 KiB
Markdown
260 lines
7.2 KiB
Markdown
# EvalScope API 测试指南
|
||
|
||
本目录提供一键运行 API 模型评测的脚本。
|
||
|
||
## 1. 准备 API key
|
||
|
||
为了不把 key 写进代码,推荐用环境变量:
|
||
|
||
```bash
|
||
export EVAL_API_KEY="sk-xxxx"
|
||
```
|
||
|
||
如果使用智谱 / Vectron / 自定义 OpenAI-compatible 服务,按需改 `EVAL_API_URL`:
|
||
|
||
```bash
|
||
export EVAL_API_URL="https://api.vectron.meta-stone.com/v1"
|
||
export EVAL_MODEL="DeepSeek/DeepSeek-V4-Flash"
|
||
```
|
||
|
||
## 2. 快速开始
|
||
|
||
### 2.1 测指定 datasets(最常用)
|
||
|
||
```bash
|
||
cd /data1/sora/evalscope
|
||
|
||
export EVAL_API_KEY="sk-xxxx"
|
||
export EVAL_DATASETS="gsm8k,aime24,arc"
|
||
|
||
bash bash/case/GLM52_API_TEST1.sh
|
||
```
|
||
|
||
想换 benchmark,改 `EVAL_DATASETS` 即可。常用数据集:
|
||
|
||
```text
|
||
gsm8k, aime24, aime25, aime26, hmmt26, imo_answerbench, competition_math
|
||
bbh, drop
|
||
bigcodebench, humaneval, live_code_bench
|
||
gpqa_diamond, mmlu_pro, simple_qa, mmlu, cmmlu, arc, hellaswag, trivia_qa, winogrande
|
||
longbench_v2, openai_mrcr
|
||
tau2_bench, general_fc, bfcl_v3
|
||
```
|
||
|
||
### 2.2 使用内置模式
|
||
|
||
```bash
|
||
bash bash/case/GLM52_API_TEST1.sh --mode quick # 快速冒烟:gsm8k,aime24,arc limit=20
|
||
bash bash/case/GLM52_API_TEST1.sh --mode lite # lite 套件
|
||
bash bash/case/GLM52_API_TEST1.sh --mode mid # 中等套件
|
||
bash bash/case/GLM52_API_TEST1.sh --mode full # 全量(不含 tau2_bench,因为耗时)
|
||
bash bash/case/GLM52_API_TEST1.sh --mode official # 与 DP4-Flash 官方发布对齐
|
||
```
|
||
|
||
### 2.3 测 GLM5.2
|
||
|
||
```bash
|
||
export EVAL_API_KEY="sk-xxxx"
|
||
export EVAL_API_URL="https://api.example.com/v1" # 替换为 GLM5.2 的实际 endpoint
|
||
export EVAL_MODEL="glm-5.2"
|
||
export EVAL_DATASETS="gsm8k,aime24,arc"
|
||
export EVAL_FOLDER_NAME="GLM52-API-Test"
|
||
|
||
bash bash/case/GLM52_API_TEST1.sh
|
||
```
|
||
|
||
### 2.4 控制 thinking budget
|
||
|
||
如果模型 API 支持 `thinking.budget_tokens`,可以传入 `--thinking-budget-tokens`:
|
||
|
||
```bash
|
||
# 尝试用 budget_tokens=0 关闭 thinking
|
||
bash bash/case/GLM52_API_TEST1.sh \
|
||
--thinking \
|
||
--thinking-budget-tokens 0 \
|
||
--datasets aime24 \
|
||
--folder-name no-thinking-test
|
||
```
|
||
|
||
等价于在请求体里加入:
|
||
|
||
```json
|
||
"extra_body": {
|
||
"thinking": {"type": "enabled", "budget_tokens": 0}
|
||
}
|
||
```
|
||
|
||
## 3. 常用命令行参数
|
||
|
||
| 参数 | 说明 |
|
||
|---|---|
|
||
| `--api-key` | API key(也可用 `EVAL_API_KEY`) |
|
||
| `--api-url` | OpenAI-compatible API 地址 |
|
||
| `--model` | 模型名,如 `glm-5.2`、`DeepSeek/DeepSeek-V4-Flash` |
|
||
| `--datasets` | 逗号分隔的 benchmark 列表 |
|
||
| `--mode` | `quick / lite / mid / full / official / custom` |
|
||
| `--folder-name` | 输出目录名,默认 `API-Test` |
|
||
| `--config` | 评测配置 YAML,默认 `config/dpv4-int8_nothinking.yaml` |
|
||
| `--batch-size` | 并发数,默认 4 |
|
||
| `--limit` | 每个 benchmark 最多测多少条,`none` 表示全量 |
|
||
| `--thinking` | 启用 thinking 模式 |
|
||
| `--no-thinking` | 关闭 thinking 模式 |
|
||
| `--thinking-budget-tokens` | 控制 thinking budget,例如 `0` 尝试关闭 thinking |
|
||
|
||
## 4. 查看进度
|
||
|
||
评测日志在 `logs/` 目录,最新日志:
|
||
|
||
```bash
|
||
ls -t logs/live_code_bench_thinking_*.log | head -1
|
||
```
|
||
|
||
实时看进度:
|
||
|
||
```bash
|
||
tail -f $(ls -t logs/live_code_bench_thinking_*.log | head -1)
|
||
```
|
||
|
||
## 5. 结果与成本
|
||
|
||
### 5.1 结果位置
|
||
|
||
```text
|
||
output/<FOLDER_NAME>/<benchmark>/seed_42/reports/<benchmark>.json
|
||
```
|
||
|
||
### 5.2 计算成本
|
||
|
||
运行完成后,用成本脚本按 token 量算钱:
|
||
|
||
```bash
|
||
# GLM5.2:输入 8 元/M,输出 28 元/M,折扣 0.65
|
||
bash bash/case/calc_glm52_cost.sh
|
||
|
||
# 输出到 results/P800_benchmark_cost_GLM52.csv
|
||
```
|
||
|
||
如果是其他模型,直接调工具:
|
||
|
||
```bash
|
||
python3 tools/calculate_cost.py \
|
||
--input "P800模型能力评测结果 - DS4-Flash-INT8-NO-Thinking-2.0-FULL.csv" \
|
||
--input-price 2 \
|
||
--output-price 8 \
|
||
--discount 1.0 \
|
||
--model-name MyModel \
|
||
--output results/cost_mymodel.csv
|
||
```
|
||
|
||
### 5.3 把成本写回 Excel
|
||
|
||
```bash
|
||
python3 tools/fill_excel_cost.py \
|
||
--input "/data1/sora/P800模型能力评测结果_统一格式_filled.xlsx" \
|
||
--output "/data1/sora/P800模型能力评测结果_统一格式_with_cost.xlsx" \
|
||
--input-price 8 \
|
||
--output-price 28 \
|
||
--discount 0.65 \
|
||
--model-name GLM-5.2
|
||
```
|
||
|
||
## 6. 价格预测 → 选 dataset → 跑测试
|
||
|
||
推荐按下面三步走:先人工算好价格、选定 benchmark,再执行测试。
|
||
|
||
### 步骤 1:价格预测(人工决策)
|
||
|
||
`tools/predict_costs.py` 根据 `bash/case/model_pricing.yaml` 里的模型单价和折扣,对每个 benchmark 生成所有模型的成本矩阵。
|
||
|
||
```bash
|
||
# 生成全部模型 / 全部 benchmark 的成本矩阵
|
||
python3 tools/predict_costs.py
|
||
|
||
# 指定预算上限,输出预算内可测的 benchmark
|
||
python3 tools/predict_costs.py --budget 100
|
||
```
|
||
|
||
输出文件:
|
||
- `results/P800_benchmark_cost_all_models.csv/.xlsx`:完整成本矩阵
|
||
- `results/P800_benchmark_cost_all_models_budget_100.csv/.xlsx`:预算内可测列表
|
||
|
||
终端会打印各模型跑完全部 benchmark 的总成本,例如:
|
||
|
||
```text
|
||
=== 各模型总成本(元)===
|
||
GLM-5.2: 2014.44
|
||
GLM-5.1-lt32k: 1546.39
|
||
GLM-5-lt32k: 1054.64
|
||
Kimi-K2.5: 1174.06
|
||
MiniMax-M2.7: 707.77
|
||
DeepSeek-V3.2: 793.02
|
||
DeepSeek-V4-Pro: 1476.61
|
||
DeepSeek-V4-Flash: 360.03
|
||
```
|
||
|
||
> 注意:`model_pricing.yaml` 里的价格为公开参考价或占位价,实际测试前请按合同价修改。
|
||
|
||
### 步骤 2:按预算选 datasets(人工决策)
|
||
|
||
打开生成的预算筛选表,根据总预算和想覆盖的能力维度勾选 benchmark。例如预算 100 元时:
|
||
|
||
```text
|
||
预算 100.00 元内可测的 benchmark
|
||
DeepSeek-V4-Flash: 27 个 -> bigcodebench, humaneval, live_code_bench, aime24, ...
|
||
GLM-5.2: 22 个 -> bigcodebench, humaneval, live_code_bench, aime24, ...
|
||
```
|
||
|
||
把选好的 benchmark 列表写到 `EVAL_DATASETS`:
|
||
|
||
```bash
|
||
export EVAL_DATASETS="gpqa_diamond,winogrande,general_fc"
|
||
```
|
||
|
||
### 步骤 3:跑测试
|
||
|
||
设置 API key、模型、输出目录后启动:
|
||
|
||
```bash
|
||
export EVAL_API_KEY="sk-xxxx"
|
||
export EVAL_API_URL="https://api.example.com/v1"
|
||
export EVAL_MODEL="glm-5.2"
|
||
export EVAL_DATASETS="gpqa_diamond,winogrande,general_fc"
|
||
export EVAL_FOLDER_NAME="GLM52-budget-100"
|
||
|
||
bash bash/case/GLM52_API_TEST1.sh
|
||
```
|
||
|
||
也可以用内置 mode 快速跑一套:
|
||
|
||
```bash
|
||
bash bash/case/GLM52_API_TEST1.sh --mode quick
|
||
```
|
||
|
||
### 6.1 与历史价格对比
|
||
|
||
飞书 wiki 里的历史价格需要手动导出为 CSV 并放到 `data/historical_prices.csv`,随后可写对比脚本。目前预测表已生成,可直接用于人工对比。
|
||
|
||
## 7. 常见问题
|
||
|
||
### 7.1 simple_qa 分数为 0
|
||
|
||
通常是 judge API 被限流(HTTP 429)。SimpleQA 需要调用外部 judge 模型打分。解决方案:
|
||
|
||
- 换成本地模型当 judge:
|
||
```bash
|
||
bash bash/case/GLM52_API_TEST1.sh \
|
||
--datasets simple_qa \
|
||
--judge-model /data1/models/DeepSeek-V4-Flash-INT8 \
|
||
--judge-api-url http://localhost:30000/v1 \
|
||
--judge-api-key EMPTY
|
||
```
|
||
- 或降低 `--batch-size` / `--parallel-runs` 减少 judge 并发。
|
||
|
||
### 7.2 评测非常慢
|
||
|
||
代码类 benchmark(`live_code_bench`、`bigcodebench`、`humaneval`)需要实际执行生成的代码并跑测试用例,耗时比纯文本生成高很多。可以先 `--limit 10` 测小样本。
|
||
|
||
### 7.3 只想重跑失败/漏掉的 benchmark
|
||
|
||
直接指定 datasets 即可,EvalScope 会自动跳过已完成的(通过 `use_cache` 恢复)。
|