README.md 6.06 KB
Newer Older
zhuwenwen's avatar
zhuwenwen committed
1
2
3
# <div align="center"><strong>opencompass</strong></div>
## 简介
OpenCompass主要由三个核心模块构成:CompassKit、CompassHub和CompassRank。CompassRank不仅囊括了开源基准测试项目,还包含了私有基准测试。CompassHub推出了一个基准测试资源导航平台,可以在多样化的基准测试库中进行搜索与利用。CompassKit 是一系列专为大型语言模型和大型视觉-语言模型打造的强大评估工具合集,它所提供的全面评测工具集能够有效地对这些复杂模型的功能性能进行精准测量和科学评估。
Tong Gao's avatar
Tong Gao committed
4

Tong Gao's avatar
Tong Gao committed
5

zhuwenwen's avatar
zhuwenwen committed
6
7
8
9
10
## 安装
opencompass支持
+ Python 3.8.
+ Python 3.9.
+ Python 3.10.
Tong Gao's avatar
Tong Gao committed
11

zhuwenwen's avatar
zhuwenwen committed
12
### 使用源码编译方式安装
Tong Gao's avatar
Tong Gao committed
13

zhuwenwen's avatar
zhuwenwen committed
14
15
#### 编译环境准备
提供2种环境准备方式:
Tong Gao's avatar
Tong Gao committed
16

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

zhuwenwen's avatar
zhuwenwen committed
19
20
21
22
2. 基于现有python环境:安装pytorch2.1.0,pytorch whl包下载目录:[https://cancon.hpccube.com:65024/4/main/pytorch/DAS1.0](https://cancon.hpccube.com:65024/4/main/pytorch/DAS1.0),根据python、dtk版本,下载对应pytorch2.1.0的whl包。安装命令如下:
```shell
pip install torch* (下载的torch的whl包)
pip install setuptools wheel
23
24
```

zhuwenwen's avatar
zhuwenwen committed
25
26
27
28
#### 源码编译安装
```shell
git clone -b 0.2.5.rc1 http://developer.hpccube.com/codes/OpenDAS/opencompass.git 
```
29

zhuwenwen's avatar
zhuwenwen committed
30
- 提供2种源码编译方式(进入opencompass目录):
31
```
zhuwenwen's avatar
zhuwenwen committed
32
33
34
基础依赖安装:
pip install -r requirements.txt
pip install sentence_transformers==2.2.2 --no-deps
35

zhuwenwen's avatar
zhuwenwen committed
36
37
38
39
1. 编译whl包并安装
python setup.py bdist_wheel 
cd dist
pip install opencompass*
40

zhuwenwen's avatar
zhuwenwen committed
41
2. 源码编译安装
zhuwenwen's avatar
zhuwenwen committed
42
pip install -e .
Leymore's avatar
Leymore committed
43
44
45
```


zhuwenwen's avatar
zhuwenwen committed
46
47
#### 注意事项
+ 若使用 pip install 下载安装过慢,可添加源:-i https://pypi.tuna.tsinghua.edu.cn/simple/
Leymore's avatar
Leymore committed
48
49


zhuwenwen's avatar
zhuwenwen committed
50
51
52
53
54
## 使用
### 数据集准备
```
wget https://github.com/open-compass/opencompass/releases/download/0.2.2.rc1/OpenCompassData-core-20240207.zip
unzip OpenCompassData-core-20240207.zip (解压后为data目录)
Leymore's avatar
Leymore committed
55
56
```

zhuwenwen's avatar
zhuwenwen committed
57
58
59
### 使用说明
列出所有配置:
```shell
Leymore's avatar
Leymore committed
60
61
62
python tools/list_configs.py
```

zhuwenwen's avatar
zhuwenwen committed
63
64
65
列出和llama模型以及mmlu数据集有关的配置:
```shell
python tools/list_configs.py llama mmlu
Leymore's avatar
Leymore committed
66
67
```

zhuwenwen's avatar
zhuwenwen committed
68
根据需要的框架进行安装,然后运行:
zhuwenwen's avatar
zhuwenwen committed
69

huangwb's avatar
huangwb committed
70
#### 1、使用vllm推理验证
zhuwenwen's avatar
zhuwenwen committed
71

zhuwenwen's avatar
zhuwenwen committed
72
环境及使用参考:[https://developer.hpccube.com/codes/OpenDAS/vllm](https://developer.hpccube.com/codes/OpenDAS/vllm)
zhuwenwen's avatar
zhuwenwen committed
73
```shell
zhuwenwen's avatar
zhuwenwen committed
74
python run.py configs/vllm/eval_llama2_vllm.py
zhuwenwen's avatar
zhuwenwen committed
75
```
zhuwenwen's avatar
zhuwenwen committed
76
其它模型使用参考`configs/vllm/eval_xxx_vllm.py`
Tong Gao's avatar
Tong Gao committed
77

huangwb's avatar
huangwb committed
78
#### 2、使用lmdeploy推理验证
zhuwenwen's avatar
zhuwenwen committed
79

zhuwenwen's avatar
zhuwenwen committed
80
环境及使用参考:[https://developer.hpccube.com/codes/OpenDAS/lmdeploy](https://developer.hpccube.com/codes/OpenDAS/lmdeploy)
zhuwenwen's avatar
zhuwenwen committed
81
```shell
gaoqiong's avatar
gaoqiong committed
82
83
84
85
86
87
#安装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
gaoqiong's avatar
gaoqiong committed
88
source /opt/dtk-24.04/cuda/env.sh
gaoqiong's avatar
gaoqiong committed
89
90
91
#进入opencompass进行评测
cd opencompass 
#fp16精度评测方法
zhuwenwen's avatar
zhuwenwen committed
92
python run.py configs/lmdeploy/eval_llama2_lmdeploy.py
gaoqiong's avatar
gaoqiong committed
93
94
95
96
97
98
99
#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
zhuwenwen's avatar
zhuwenwen committed
100
python run.py configs/lmdeploy/eval_llama2_lmdeploy.py
zhuwenwen's avatar
zhuwenwen committed
101
```
zhuwenwen's avatar
zhuwenwen committed
102
其它模型使用参考`configs/lmdeploy/eval_xxx_lmdeploy.py`
Tong Gao's avatar
Tong Gao committed
103

huangwb's avatar
huangwb committed
104
#### 3、使用tgi推理验证
zhuwenwen's avatar
zhuwenwen committed
105

huangwb's avatar
huangwb committed
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
run所有的opencompass测试都需要先开启TGI的服务,TGI服务的环境及使用参考:[https://developer.hpccube.com/codes/OpenDAS/text-generation-inference](https://developer.hpccube.com/codes/OpenDAS/text-generation-inference)

**评测base模型**
启动服务example:
```shell
HIP_VISIBLE_DEVICES=3 text-generation-launcher --dtype=float16 --model-id /data/models/Llama-2-7b-chat-hf --port 3001
```
运行评测example:
```shell
python run.py configs/tgi/eval_llama2_tgi.py --debug
```
**评测chat模型**
评测chat模型需要在模型路径里的`tokenizer_config.json`配置文件中提供`chat_template`,不同模型的`chat_template`可以参考[https://github.com/chujiezheng/chat_templates/tree/main/chat_templates](https://github.com/chujiezheng/chat_templates/tree/main/chat_templates)
具体操作的时候可以从模型路径下copy一份`tokenizer_config.json`到其他目录下,比如copy后的文件为`tokenizer_config_llama2_7b_chat.json`,在该文件里添加`chat_template`,然后在起服务的时候指定`--tokenizer-config-path`参数为修改后的文件。以llama为列,修改后的config例子见[tokenizer_config_llama2_7b_chat.json](./configs/tgi/tokenizer_config_llama2_7b_chat.json)

启动服务example:
```shell
HIP_VISIBLE_DEVICES=3 text-generation-launcher --dtype=float16 --model-id /data/models/Llama-2-7b-chat-hf --port 3001 --tokenizer-config-path /path/to/tokenizer_config_llama2_7b_chat.json
```
注意:和base模型比多了`--tokenizer-config-path`参数。
运行评测example:
zhuwenwen's avatar
zhuwenwen committed
127
```shell
huangwb's avatar
huangwb committed
128
python run.py configs/tgi/eval_llama2_7b_chat_tgi.py.py --debug
zhuwenwen's avatar
zhuwenwen committed
129
```
zhuwenwen's avatar
zhuwenwen committed
130
其它模型使用参考`configs/tgi/eval_xxx_tgi.py`
Leymore's avatar
Leymore committed
131

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

zhuwenwen's avatar
zhuwenwen committed
139
140
## 验证
- python -c "import opencompass; print(opencompass.\_\_version__)",版本号与官方版本同步,查询该软件的版本号,例如0.2.4;
Songyang Zhang's avatar
Songyang Zhang committed
141

zhuwenwen's avatar
zhuwenwen committed
142
143
## Known Issue
-
Songyang Zhang's avatar
Songyang Zhang committed
144

zhuwenwen's avatar
zhuwenwen committed
145
146
## 参考资料
- [README_ORIGIN](README_ORIGIN.md)
gaoqiong's avatar
gaoqiong committed
147
- [https://github.com/open-compass/opencompass](https://github.com/open-compass/opencompass.git)