重要提示

您正在查看 NeMo 2.0 文档。此版本引入了对 API 和新库 NeMo Run 的重大更改。我们目前正在将 NeMo 1.0 中的所有功能移植到 2.0。有关先前版本或 2.0 中尚不可用的功能的文档,请参阅 NeMo 24.07 文档

评估已训练模型#

训练模型后,您可能需要运行评估以了解模型在未见过的任务上的表现。您可以使用 Eleuther AI 的 语言模型评估工具 来快速运行各种流行的基准测试,包括 MMLU、SuperGLUE、HellaSwag 和 WinoGrande。可以在此处找到支持任务的完整列表。

安装 LM 评估工具#

在 NeMo 容器内运行以下命令以安装 LM 评估工具

git clone --depth 1 https://github.com/EleutherAI/lm-evaluation-harness
cd lm-evaluation-harness
pip install -e .

运行评估#

有关使用 .nemo 模型运行评估的详细说明,请参阅 Eleuther AI 的文档。支持单 GPU 和多 GPU 评估。以下是使用 8 个 GPU 在 hellaswagsuper_gluewinogrande 任务上使用来自 NeMo-Aligner 的 .nemo 文件运行评估的示例。请注意,虽然建议这样做,但您无需在运行评估之前解压缩 .nemo 文件。

mkdir unzipped_checkpoint
tar -xvf /path/to/model.nemo -c unzipped_checkpoint

torchrun --nproc-per-node=8 --no-python lm_eval --model nemo_lm \
  --model_args path='unzipped_checkpoint',devices=8,tensor_model_parallel_size=8 \
  --tasks lambada_openai,super-glue-lm-eval-v1,winogrande \
  --batch_size 8