README.md 5.35 KB
Newer Older
jerrrrry's avatar
jerrrrry committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# <div align="center"><strong>opencompass</strong></div>
## 简介
OpenCompass主要由三个核心模块构成:CompassKit、CompassHub和CompassRank。CompassRank不仅囊括了开源基准测试项目,还包含了私有基准测试。CompassHub推出了一个基准测试资源导航平台,可以在多样化的基准测试库中进行搜索与利用。CompassKit 是一系列专为大型语言模型和大型视觉-语言模型打造的强大评估工具合集,它所提供的全面评测工具集能够有效地对这些复杂模型的功能性能进行精准测量和科学评估。


## 安装
opencompass支持
+ Python 3.8.
+ Python 3.9.
+ Python 3.10.

### 使用源码编译方式安装

#### 编译环境准备
提供2种环境准备方式:

1. 基于光源pytorch2.3.0基础镜像环境:镜像下载地址:[https://sourcefind.cn/#/image/dcu/pytorch](https://sourcefind.cn/#/image/dcu/pytorch),根据pytorch2.3.0、python、dtk及系统下载对应的镜像版本。

2. 基于现有python环境:安装pytorch2.3.0,pytorch whl包下载目录:[https://cancon.hpccube.com:65024/4/main/pytorch/DAS1.3](https://cancon.hpccube.com:65024/4/main/pytorch/DAS1.3),根据python、dtk版本,下载对应pytorch2.3.0的whl包。安装命令如下:
```shell
pip install torch* (下载的torch的whl包)
pip install setuptools wheel
```

#### 源码编译安装
```shell
git clone -b 0.3.7 http://developer.hpccube.com/codes/OpenDAS/opencompass.git 
```

- 提供2种源码编译方式(进入opencompass目录):
```
基础依赖安装:
pip install -r requirements.txt
pip install -r requirements/api.txt
pip install -r requirements/extra.txt

1. 编译whl包并安装
python setup.py bdist_wheel 
cd dist
pip install opencompass*

2. 源码编译安装(推荐)
pip install -e .
```

安装humaneval(可选)
```shell
git clone https://github.com/open-compass/human-eval.git
cd human-eval
pip install -e .
```


#### 注意事项
+ 若使用 pip install 下载安装过慢,可添加源:-i https://pypi.tuna.tsinghua.edu.cn/simple/


## 使用
### 数据集准备
```
wget https://github.com/open-compass/opencompass/releases/download/0.2.2.rc1/OpenCompassData-core-20240207.zip
unzip OpenCompassData-core-20240207.zip (解压后为data目录)
```

### 使用说明
列出所有配置:
```shell
python tools/list_configs.py
```

列出和llama模型以及mmlu数据集有关的配置:
```shell
python tools/list_configs.py llama mmlu
```

根据需要的框架进行安装,然后运行:
#### 离线评测

1、使用vllm推理验证

环境及使用参考:[https://developer.hpccube.com/codes/OpenDAS/vllm](https://developer.hpccube.com/codes/OpenDAS/vllm)
```shell
python run.py examples/vllm/eval_llama2_vllm.py
```
其它模型使用参考`examples/vllm/eval_xxx_vllm.py`,若使用多卡,修改`tensor_parallel_size``num_gpus`为卡的数量

2、使用lmdeploy推理验证

环境及使用参考:[https://developer.hpccube.com/codes/OpenDAS/lmdeploy](https://developer.hpccube.com/codes/OpenDAS/lmdeploy)
```shell
#安装gpufusion 相关工具
#https://forum.hpccube.com/thread/483 进入网页下载gpufusion工具
#解压至dtk-24.04
unzip gpufusion.zip -d /opt/dtk-24.04/
#激活相关环境变量
source /opt/dtk-24.04/env.sh
source /opt/dtk-24.04/cuda/env.sh
#进入opencompass进行评测
cd opencompass 
#fp16精度评测方法
python run.py examples/lmdeploy/eval_llama2_lmdeploy.py
#awq int4 评测方法
#首先需要转换awqInt4模型  
#model_name:模型名字如 llama2 qwen-7b 
#awq_modelpath:awq 模型路径,例如:/dataset/llm-models/qwen/qwen-chat-7b-AWQ-4bit
#awq_lmdeploymodel_path:生成的lmdeploy格式 awq模型路径
lmdeploy convert ${model_name} ${awq_modelpath} --model-format awq --group-size 128 --dst-path ${awq_lmdeploymodel_path}
#将eval_llama2_lmdeploy.py中的Llama-2-7b-hf 替换为转换好的awq_lmdeploymodel_path
python run.py examples/lmdeploy/eval_llama2_lmdeploy.py
```
其它模型使用参考`examples/lmdeploy/eval_xxx_lmdeploy.py`

3、使用tgi推理验证

环境及使用参考:[https://developer.hpccube.com/codes/OpenDAS/text-generation-inference](https://developer.hpccube.com/codes/OpenDAS/text-generation-inference)
```shell
python run.py examples/tgi/eval_llama2_tgi.py
```
其它模型使用参考`examples/tgi/eval_xxx_tgi.py`

4、使用torch推理验证
```shell
python run.py --datasets xxx --hf-type chat --hf-path $model_path
```

参数说明:
(1)数据集配置参数
`work_dir`为保存路径,`from .datasets.ARC_c.ARC_c_gen_1e0de5 import ARC_c_datasets`为使用的数据集,可以在`configs/datasets`路径下查找并配置,vllm目前不支持ppl-based评测。
(2)模型配置参数
`abbr`为生成数据集指标得分的列名,`path`为模型路径。

#### API评测
1、使用vllm推理验证
启动服务:
'''shell
python -m  vllm.entrypoints.openai.api_server --model $model_path --trust-remote-code  --enforce-eager --host 0.0.0.0 --port 8000 -tp 1  --dtype float16 --max-model-len 32768 
'''
运行:
```shell
export OPENAI_API_KEY="ENV"
python run.py examples/vllm/eval_xxx_openai_vllm.py
```

## 验证
- python -c "import opencompass; print(opencompass.\_\_version__)",版本号与官方版本同步,查询该软件的版本号,例如0.4.1;

## Known Issue
-

## 参考资料
- [README_ORIGIN](README_ORIGIN.md)
- [https://github.com/open-compass/opencompass](https://github.com/open-compass/opencompass.git)