名称: nemo-evaluator-sdk 描述: 使用多后端执行在100+个基准测试和18+个测试框架(如MMLU、HumanEval、GSM8K、安全、VLM)上评估大型语言模型(LLM)。适用于需要在本地Docker、Slurm HPC或云平台上进行可扩展评估的场景。NVIDIA的企业级平台,采用容器优先架构,实现可复现的基准测试。 版本: 1.0.0 作者: Orchestra Research 许可证: MIT 标签: [评估, NeMo, NVIDIA, 基准测试, MMLU, HumanEval, 多后端, Slurm, Docker, 可复现, 企业级] 依赖项: [nemo-evaluator-launcher>=0.1.25, docker]
NeMo 评估器 SDK - 企业级 LLM 基准测试
快速开始
NeMo 评估器 SDK 使用容器化、可复现的评估和多后端执行(本地Docker、Slurm HPC、Lepton云)在100+个基准测试和18+个测试框架上评估LLM。
安装:
pip install nemo-evaluator-launcher
设置API密钥并运行评估:
export NGC_API_KEY=nvapi-your-key-here
# 创建最小配置
cat > config.yaml << 'EOF'
defaults:
- execution: local
- deployment: none
- _self_
execution:
output_dir: ./results
target:
api_endpoint:
model_id: meta/llama-3.1-8b-instruct
url: https://integrate.api.nvidia.com/v1/chat/completions
api_key_name: NGC_API_KEY
evaluation:
tasks:
- name: ifeval
EOF
# 运行评估
nemo-evaluator-launcher run --config-dir . --config-name config
查看可用任务:
nemo-evaluator-launcher ls tasks
常见工作流
工作流1:在标准基准上评估模型
在任何OpenAI兼容的端点上运行核心学术基准(MMLU、GSM8K、IFEval)。
清单:
标准评估:
- [ ] 步骤1:配置API端点
- [ ] 步骤2:选择基准
- [ ] 步骤3:运行评估
- [ ] 步骤4:检查结果
步骤1:配置API端点
# config.yaml
defaults:
- execution: local
- deployment: none
- _self_
execution:
output_dir: ./results
target:
api_endpoint:
model_id: meta/llama-3.1-8b-instruct
url: https://integrate.api.nvidia.com/v1/chat/completions
api_key_name: NGC_API_KEY
对于自托管端点(vLLM、TRT-LLM):
target:
api_endpoint:
model_id: my-model
url: http://localhost:8000/v1/chat/completions
api_key_name: "" # 本地无需密钥
步骤2:选择基准
将任务添加到配置中:
evaluation:
tasks:
- name: ifeval # 指令跟随
- name: gpqa_diamond # 研究生级QA
env_vars:
HF_TOKEN: HF_TOKEN # 某些任务需要HF令牌
- name: gsm8k_cot_instruct # 数学推理
- name: humaneval # 代码生成
步骤3:运行评估
# 使用配置文件运行
nemo-evaluator-launcher run \
--config-dir . \
--config-name config
# 覆盖输出目录
nemo-evaluator-launcher run \
--config-dir . \
--config-name config \
-o execution.output_dir=./my_results
# 限制样本以进行快速测试
nemo-evaluator-launcher run \
--config-dir . \
--config-name config \
-o +evaluation.nemo_evaluator_config.config.params.limit_samples=10
步骤4:检查结果
# 检查作业状态
nemo-evaluator-launcher status <invocation_id>
# 列出所有运行
nemo-evaluator-launcher ls runs
# 查看结果
cat results/<invocation_id>/<task>/artifacts/results.yml
工作流2:在Slurm HPC集群上运行评估
在HPC基础设施上执行大规模评估。
清单:
Slurm评估:
- [ ] 步骤1:配置Slurm设置
- [ ] 步骤2:设置模型部署
- [ ] 步骤3:启动评估
- [ ] 步骤4:监控作业状态
步骤1:配置Slurm设置
# slurm_config.yaml
defaults:
- execution: slurm
- deployment: vllm
- _self_
execution:
hostname: cluster.example.com
account: my_slurm_account
partition: gpu
output_dir: /shared/results
walltime: "04:00:00"
nodes: 1
gpus_per_node: 8
步骤2:设置模型部署
deployment:
checkpoint_path: /shared/models/llama-3.1-8b
tensor_parallel_size: 2
data_parallel_size: 4
max_model_len: 4096
target:
api_endpoint:
model_id: llama-3.1-8b
# URL由部署自动生成
步骤3:启动评估
nemo-evaluator-launcher run \
--config-dir . \
--config-name slurm_config
步骤4:监控作业状态
# 检查状态(查询sacct)
nemo-evaluator-launcher status <invocation_id>
# 查看详细信息
nemo-evaluator-launcher info <invocation_id>
# 如果需要,终止作业
nemo-evaluator-launcher kill <invocation_id>
工作流3:比较多个模型
在相同任务上对多个模型进行基准测试以进行比较。
清单:
模型比较:
- [ ] 步骤1:创建基础配置
- [ ] 步骤2:使用覆盖运行评估
- [ ] 步骤3:导出和比较结果
步骤1:创建基础配置
# base_eval.yaml
defaults:
- execution: local
- deployment: none
- _self_
execution:
output_dir: ./comparison_results
evaluation:
nemo_evaluator_config:
config:
params:
temperature: 0.01
parallelism: 4
tasks:
- name: mmlu_pro
- name: gsm8k_cot_instruct
- name: ifeval
步骤2:使用模型覆盖运行评估
# 评估Llama 3.1 8B
nemo-evaluator-launcher run \
--config-dir . \
--config-name base_eval \
-o target.api_endpoint.model_id=meta/llama-3.1-8b-instruct \
-o target.api_endpoint.url=https://integrate.api.nvidia.com/v1/chat/completions
# 评估Mistral 7B
nemo-evaluator-launcher run \
--config-dir . \
--config-name base_eval \
-o target.api_endpoint.model_id=mistralai/mistral-7b-instruct-v0.3 \
-o target.api_endpoint.url=https://integrate.api.nvidia.com/v1/chat/completions
步骤3:导出和比较
# 导出到MLflow
nemo-evaluator-launcher export <invocation_id_1> --dest mlflow
nemo-evaluator-launcher export <invocation_id_2> --dest mlflow
# 导出到本地JSON
nemo-evaluator-launcher export <invocation_id> --dest local --format json
# 导出到Weights & Biases
nemo-evaluator-launcher export <invocation_id> --dest wandb
工作流4:安全和视觉语言评估
在安全基准和VLM任务上评估模型。
清单:
安全/VLM评估:
- [ ] 步骤1:配置安全任务
- [ ] 步骤2:设置VLM任务(如适用)
- [ ] 步骤3:运行评估
步骤1:配置安全任务
evaluation:
tasks:
- name: aegis # 安全测试框架
- name: wildguard # 安全分类
- name: garak # 安全探测
步骤2:配置VLM任务
# 对于视觉语言模型
target:
api_endpoint:
type: vlm # 视觉语言端点
model_id: nvidia/llama-3.2-90b-vision-instruct
url: https://integrate.api.nvidia.com/v1/chat/completions
evaluation:
tasks:
- name: ocrbench # OCR评估
- name: chartqa # 图表理解
- name: mmmu # 多模态理解
何时使用与替代方案
使用NeMo评估器当:
- 需要100+个基准测试和18+个测试框架在一个平台中
- 在Slurm HPC集群或云上运行评估
- 需要可复现的容器化评估
- 评估OpenAI兼容的API(如vLLM、TRT-LLM、NIMs)
- 需要企业级评估并支持结果导出(如MLflow、W&B)
使用替代方案当:
- lm-evaluation-harness:更简单设置以进行快速本地评估
- bigcode-evaluation-harness:专注于代码基准测试
- HELM:斯坦福的更广泛评估(公平性、效率)
- 自定义脚本:高度专业化的领域评估
支持的测试框架和任务
| 测试框架 | 任务数量 | 类别 |
|---|---|---|
lm-evaluation-harness |
60+ | MMLU、GSM8K、HellaSwag、ARC |
simple-evals |
20+ | GPQA、MATH、AIME |
bigcode-evaluation-harness |
25+ | HumanEval、MBPP、MultiPL-E |
safety-harness |
3 | Aegis、WildGuard |
garak |
1 | 安全探测 |
vlmevalkit |
6+ | OCRBench、ChartQA、MMMU |
bfcl |
6 | 函数调用v2/v3 |
mtbench |
2 | 多轮对话 |
livecodebench |
10+ | 实时编码评估 |
helm |
15 | 医疗领域 |
nemo-skills |
8 | 数学、科学、代理式任务 |
常见问题
问题:容器拉取失败
确保NGC凭据已配置:
docker login nvcr.io -u '$oauthtoken' -p $NGC_API_KEY
问题:任务需要环境变量
某些任务需要HF_TOKEN或JUDGE_API_KEY:
evaluation:
tasks:
- name: gpqa_diamond
env_vars:
HF_TOKEN: HF_TOKEN # 映射环境变量名到环境变量
问题:评估超时
增加并行度或减少样本:
-o +evaluation.nemo_evaluator_config.config.params.parallelism=8
-o +evaluation.nemo_evaluator_config.config.params.limit_samples=100
问题:Slurm作业未启动
检查Slurm账户和分区:
execution:
account: correct_account
partition: gpu
qos: normal # 可能需要特定QOS
问题:结果与预期不同
验证配置与报告设置匹配:
evaluation:
nemo_evaluator_config:
config:
params:
temperature: 0.0 # 确定性
num_fewshot: 5 # 检查论文中的fewshot计数
CLI参考
| 命令 | 描述 |
|---|---|
run |
使用配置执行评估 |
status <id> |
检查作业状态 |
info <id> |
查看详细作业信息 |
ls tasks |
列出可用基准 |
ls runs |
列出所有调用 |
export <id> |
导出结果(mlflow/wandb/local) |
kill <id> |
终止运行中的作业 |
配置覆盖示例
# 覆盖模型端点
-o target.api_endpoint.model_id=my-model
-o target.api_endpoint.url=http://localhost:8000/v1/chat/completions
# 添加评估参数
-o +evaluation.nemo_evaluator_config.config.params.temperature=0.5
-o +evaluation.nemo_evaluator_config.config.params.parallelism=8
-o +evaluation.nemo_evaluator_config.config.params.limit_samples=50
# 更改执行设置
-o execution.output_dir=/custom/path
-o execution.mode=parallel
# 动态设置任务
-o 'evaluation.tasks=[{name: ifeval}, {name: gsm8k}]'
Python API使用
用于不使用CLI的程序化评估:
from nemo_evaluator.core.evaluate import evaluate
from nemo_evaluator.api.api_dataclasses import (
EvaluationConfig,
EvaluationTarget,
ApiEndpoint,
EndpointType,
ConfigParams
)
# 配置评估
eval_config = EvaluationConfig(
type="mmlu_pro",
output_dir="./results",
params=ConfigParams(
limit_samples=10,
temperature=0.0,
max_new_tokens=1024,
parallelism=4
)
)
# 配置目标端点
target_config = EvaluationTarget(
api_endpoint=ApiEndpoint(
model_id="meta/llama-3.1-8b-instruct",
url="https://integrate.api.nvidia.com/v1/chat/completions",
type=EndpointType.CHAT,
api_key="nvapi-your-key-here"
)
)
# 运行评估
result = evaluate(eval_cfg=eval_config, target_cfg=target_config)
高级主题
多后端执行:参见references/execution-backends.md 配置深入探讨:参见references/configuration.md 适配器和拦截器系统:参见references/adapter-system.md 自定义基准集成:参见references/custom-benchmarks.md
要求
- Python:3.10-3.13
- Docker:本地执行所需
- NGC API密钥:用于拉取容器和使用NVIDIA Build
- HF_TOKEN:某些基准所需(如GPQA、MMLU)
资源
- GitHub:https://github.com/NVIDIA-NeMo/Evaluator
- NGC容器:nvcr.io/nvidia/eval-factory/
- NVIDIA Build:https://build.nvidia.com(免费托管模型)
- 文档:https://github.com/NVIDIA-NeMo/Evaluator/tree/main/docs