【InternLM】书生·浦语大模型全链路开源体系实战营 第7课作业

缘起...即灭 2024-04-22 10:55:20

教程链接:https://github.com/InternLM/Tutorial/tree/camp2/opencompass

视频链接:https://www.bilibili.com/video/BV1Pm41127jU/?spm_id_from=333.788&vd_source=6393f1908894aa1c3e9b412a02def58b

目录

大模型的评测

环境配置

安装

数据准备

启动评测 (10% A100 8GB 资源)


大模型的评测

环境配置

创建开发机和 conda 环境

在创建开发机界面选择镜像为 Cuda11.7-conda,并选择 GPU 为10% A100。 

安装

面向GPU的环境安装

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 .安装未成功,请运行:

pip install -r requirements.txt

有部分第三方功能,如代码能力基准测试 Humaneval 以及 Llama格式的模型评测,可能需要额外步骤才能正常运行,如需评测,详细步骤请参考安装指南。

 

数据准备

解压评测数据集到 data/ 处

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

将会在opencompass下看到data文件夹

查看支持的数据集和模型

列出所有跟 internlm 及 ceval 相关的配置

python tools/list_configs.py internlm ceval

将会看到

 

启动评测 (10% A100 8GB 资源)

确保按照上述步骤正确安装 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

命令解析

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

运行时,提示需要导入的模块不存在,

 使用pip install * 命令依次安装下去,直到absl模块无法正常安装:

经大佬指点,应该是pip install -e .安装未成功

 运行以下命令:

pip install -r requirements.txt

如果一切正常,您应该看到屏幕上显示 “Starting inference process”:

[2024-03-18 12:39:54,972] [opencompass.openicl.icl_inferencer.icl_gen_inferencer] [INFO] Starting inference process...

 评测完成后,将会看到:

 

...全文
162 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

533

社区成员

发帖
与我相关
我的任务
社区描述
构建国际领先的计算机视觉开源算法平台
社区管理员
  • OpenMMLab
  • jason_0615
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧