OpenCompass 评测 InternLM-1.8B 实践
【自有环境】
可以基于原先的llamaindex环境
重要:opencompass必须放在/root下面
1 环境准备
conda create -n opencompass python=3.10
conda activate opencompass
conda install pytorch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 pytorch-cuda=12.1 -c pytorch -c nvidia -y
# 注意:一定要先 cd /root
cd /root
git clone -b 0.2.4 https://github.com/open-compass/opencompass
cd opencompass
pip install -e .
yum update
yum install cmake
pip install -r requirements.txt
pip install protobuf
2 数据准备
# 下载/share/temp/datasets/OpenCompassData-core-20231110.zip
# 上传到自己的服务器 /root/opencompass/
cd /root/opencompass/
unzip OpenCompassData-core-20231110.zip
3 评测
3.1 使用命令行配置参数法进行评测
vim configs/models/hf_internlm/hf_internlm2_chat_1_8b.py
# 修改path、 tokenizer_path路径
#环境变量配置
export MKL_SERVICE_FORCE_INTEL=1
#或
export MKL_THREADING_LAYER=GNU
CUDA_VISIBLE_DEVICES=1,2,3,4,5 python run.py
--datasets ceval_gen \ # 数据集准备
--models hf_internlm2_chat_1_8b \ # 模型准备
--debug
3.2 使用配置文件修改参数法进行评测
cd /root/opencompass/configs
touch eval_tutorial_demo.py
# vi eval_tutorial_demo.py
from mmengine.config import read_base
with read_base():
from .datasets.ceval.ceval_gen import ceval_datasets
from .models.hf_internlm.hf_internlm2_chat_1_8b import models as hf_internlm2_chat_1_8b_models
datasets = ceval_datasets
models = hf_internlm2_chat_1_8b_models
cd /root/opencompass
CUDA_VISIBLE_DEVICES=1,2,3,4,5 python run.py configs/eval_tutorial_demo.py --debug
# 和3.1的结果是一致的
3.3 api模型评测(进阶必做)
这些都要花钱,我们尝试之前lmdeploy部署的api:
from mmengine.config import read_base
from opencompass.models import OpenAI
from opencompass.partitioners import NaivePartitioner
from opencompass.runners import LocalRunner
from opencompass.tasks import OpenICLInferTask
with read_base():
# choose a list of datasets
from .datasets.collections.chat_medium import datasets
# and output the results in a choosen format
from .summarizers.medium import summarizer
api_meta_template = dict(
round=[
dict(role='HUMAN', api_role='HUMAN'),
dict(role='BOT', api_role='BOT', generate=True),
],
)
models = [
dict(abbr='internlm2-chat-1.8b-hf',
type=OpenAI, path='internlm/internlm2-chat-1_8b',
base_url="http://192.168.26.212:23333/v1",
key='internlm2', # The key will be obtained from $OPENAI_API_KEY, but you can write down your key here as well
meta_template=api_meta_template,
query_per_second=1,
max_out_len=2048, max_seq_len=4096, batch_size=8),
]
infer = dict(
partitioner=dict(type=NaivePartitioner),
runner=dict(
type=LocalRunner,
max_num_workers=8,
task=dict(type=OpenICLInferTask)),
)
# 不支持url或者base_url
``![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/dfd3a1247ba943d9b277eef310a11618.png#pic_center)