书生大模型课堂笔记 - 第七节课

155 阅读3分钟

相关课程资料:

课程:第七节课

日期:2024.04.23

主题:浦语大模型全链路开源体系

文档链接:课程文档

视频链接:课程视频

课堂重点

OpenCompass大模型测评

用于对训练好的大模型进行测评打分,检验模型能力的工具

大模型测评中的挑战

全面性、评测成本、数据污染、鲁棒性

image.png

司南大模型测评体系

模型评测标准

image.png

客观评测与主观测评

客观问答题、客观选择题以及开放式主观问答

image.png

提示词工程

明确性、概念无歧义、逐步引导、具体描述、迭代反馈

image.png

长文本评测 大海捞针式,对长文本内容的识别和处理能力

image.png

opencampass2.0能力升级

考察大模型各项能力

  • 基础能力如语言、知识、理解、数学、代码、推理等
  • 综合能力如考试、对话、创作、智能体、评价、长文本等

image.png

作业

基础作业

使用 OpenCompass 评测 internlm2-chat-1_8b 模型在 C-Eval 数据集上的性能

环境配置

studio-conda -o internlm-base -t opencompass
source activate opencompass
git clone -b 0.2.4 https://github.com/open-compass/opencompass
cd opencompass
pip install -e .

pip install -e .安装显示成功,但是无法执行命令,缺少包,使用命令检查 列出所有跟 InternLM 及 C-Eval 相关的配置,未成功

python tools/list_configs.py internlm ceval

image.png

继续执行,进行安装,安装成功

pip install -r requirements.txt

准备数据集

文档目录不一定是开发机器目录,自行调整

cp /share/temp/datasets/OpenCompassData-core-20231110.zip /opt/jupyterlab/opencompass
unzip OpenCompassData-core-20231110.zip

查看支持的数据集和模型

列出所有跟 InternLM 及 C-Eval 相关的配置

python tools/list_configs.py internlm ceval

image.png

启动评测

确保按照上述步骤正确安装 OpenCompass 并准备好数据集后,可以通过以下命令评测 InternLM2-Chat-1.8B 模型在 C-Eval 数据集上的性能。由于 OpenCompass 默认并行启动评估过程,我们可以在第一次运行时以 --debug 模式启动评估,并检查是否存在问题。在 --debug 模式下,任务将按顺序执行,并实时打印输出。

python run.py --datasets ceval_gen --hf-path /share/new_models/Shanghai_AI_Laboratory/internlm2-chat-1_8b --tokenizer-path /share/new_models/Shanghai_AI_Laboratory/internlm2-chat-1_8b --tokenizer-kwargs padding_side='left' truncation='left' trust_remote_code=True --model-kwargs trust_remote_code=True device_map='auto' --max-seq-len 1024 --max-out-len 16 --batch-size 2 --num-gpus 1 --debug

执行失败 无评测数据 image.png

解决方案

pip install protobuf

命令解析

python run.py
--datasets ceval_gen \
--hf-path /share/new_models/Shanghai_AI_Laboratory/internlm2-chat-1_8b \  # HuggingFace 模型路径
--tokenizer-path /share/new_models/Shanghai_AI_Laboratory/internlm2-chat-1_8b \  # HuggingFace tokenizer 路径(如果与模型路径相同,可以省略)
--tokenizer-kwargs padding_side='left' truncation='left' trust_remote_code=True \  # 构建 tokenizer 的参数
--model-kwargs device_map='auto' trust_remote_code=True \  # 构建模型的参数
--max-seq-len 1024 \  # 模型可以接受的最大序列长度
--max-out-len 16 \  # 生成的最大 token 数
--batch-size 2  \  # 批量大小
--num-gpus 1  # 运行模型所需的 GPU 数量
--debug

遇到错误mkl-service + Intel(R) MKL MKL_THREADING_LAYER=INTEL is incompatible with libgomp.so.1 ... 解决方案:

export MKL_SERVICE_FORCE_INTEL=1
#或
export MKL_THREADING_LAYER=GNU

再次执行评测命令

image.png

image.png