Skip to content

Commit 498f709

Browse files
lugimzzzzjjlivein
andauthored
[LLM] change llm content (#8627)
* change llm * fix * fix * fix ci * fix * fix * fix --------- Co-authored-by: zhangjunjun04 <[email protected]>
1 parent 34fcced commit 498f709

File tree

208 files changed

+945
-3828
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+945
-3828
lines changed

docs/llm/peft.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,4 @@ key function
277277
该函数会遍历整个权重参数列表,对于每个权重参数weight,统计所有进行梯度更新的参数,最后将信息打印出来。
278278
```
279279

280-
更详细的使用可以参考[finetuning 脚本](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/llm/causallm/finetune_generation.py)版本, 以及对应的启动脚本编写方式(写在 [README.md](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/llm/causallm/README.md)文件中)。
280+
更详细的使用可以参考[finetuning 脚本](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/llm/run_finetune.py)版本, 以及对应的启动脚本编写方式(写在 [README.md](https://github.com/PaddlePaddle/PaddleNLP/blob/develop/llm/causallm/README.md)文件中)。

llm/.gitignore

Lines changed: 0 additions & 12 deletions
This file was deleted.

llm/Alignment/RM/models

Lines changed: 0 additions & 1 deletion
This file was deleted.

llm/README.md

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919

2020
## 🛠️ 支持模型列表 🛠️
2121

22-
| Model | Pretrain | SFT | LoRA | Prefix Tuning | Quantization | Weight convert |
23-
| --- | --- | --- | --- | --- | --- | --- |
24-
| [LLaMA/LLaMA2](./llama) |||||||
25-
| [Baichuan/Baichuan2](./llama) | ||||||
26-
| [ChatGLM-6B](./chatglm) | |||| | |
27-
| [ChatGLM2/ChatGLM3](./chatglm2) | ||| | ||
28-
| [Qwen](./qwen) | ✅ | ✅ | ✅ | ✅ | 🚧 | ✅ |j
29-
| [Bloom](./bloom) || ||| ||
30-
| [GPT-3](./gpt-3) | || 🚧 | 🚧 | 🚧 ||
31-
| [OPT](./opt) | 🚧 ||| 🚧 | 🚧 ||
32-
| [GLM](./glm) | ||| 🚧 | 🚧 ||
22+
| Model | Pretrain | SFT | LoRA | Prefix Tuning | DPO | Quantization | Weight convert |
23+
| --- | --- | --- | --- | --- | --- | --- | --- |
24+
| [LLaMA](./llama) |||| | |||
25+
| [Qwen](./qwen) ||||| | 🚧 ||
26+
| [Mixtral](./mixtral) | |||| 🚧 |🚧 | 🚧 |
27+
| [Baichuan/Baichuan2](./llama) | |||| || |
28+
| [ChatGLM-6B](./chatglm) | |||| 🚧 | ||
29+
| [ChatGLM2/ChatGLM3](./chatglm2) | | || | 🚧 | ||
30+
| [Bloom](./bloom) | ||| |🚧 | ||
31+
| [GPT-3](./gpt-3) | || 🚧 | 🚧 |🚧 | 🚧 ||
32+
| [OPT](./opt) | 🚧 ||| 🚧 | 🚧 |🚧 ||
3333

3434
* ✅: Supported
3535
* 🚧: In Progress
@@ -39,7 +39,7 @@
3939
## 🚀 快速开始 🚀
4040

4141
### 1. 预训练
42-
PaddleNLP将飞桨4D并行策略加入到Trainer API中, 用户只需修改Trainer配置即可使用不同的分布式策略。目前工具链提供[LLaMA/LLaMA2](./llama)[GPT-3](./gpt-3)[Qwen](./qwen)[Baichuan/Baichuan2](./llama) 等模型预训练功能,更多模型支持持续更新中。
42+
PaddleNLP将飞桨4D并行策略加入到Trainer API中, 用户只需修改Trainer配置即可使用不同的分布式策略。目前工具链提供[LLaMA/LLaMA2](./llama)[GPT-3](./gpt-3)[Qwen](./qwen)[Baichuan/Baichuan2](./llama)[Mixtral](./mixtral) 等模型预训练功能,更多模型支持持续更新中。
4343

4444
<div align="center">
4545
<img width="500" alt="llm" src="https://github.com/PaddlePaddle/PaddleNLP/assets/37530985/a2f0261d-7f76-4faf-ae01-cc9d37d5fcc0">
@@ -54,7 +54,7 @@ PaddleNLP将飞桨4D并行策略加入到Trainer API中, 用户只需修改Tra
5454
我们在此处提供了更详细的[预训练数据制作]()[分布式策略支持情况]( https://paddlenlp.readthedocs.io/zh/latest/llm/pretraining/index.html#model-capability)[性能测试报告文档](https://paddlenlp.readthedocs.io/zh/latest/llm/pretraining/index.html#model-performance),参见: https://paddlenlp.readthedocs.io/zh/latest/llm/pretraining/index.html. 大模型权重列表参见[此处](https://paddlenlp.readthedocs.io/zh/latest/llm/pretraining/index.html#model-weight)
5555

5656

57-
此项目支持了LLaMA、GPT-3、BaiChuan、Qwen 等大模型的预训练。用户切换配置config文件,即可一键运行。
57+
此项目支持了LLaMA、GPT-3、BaiChuan、Qwen、Mixtral 等大模型的预训练。用户切换配置config文件,即可一键运行。
5858

5959
数据详细制作流程可参考[此处](https://paddlenlp.readthedocs.io/zh/latest/llm/pretraining/dataset.html) : https://paddlenlp.readthedocs.io/zh/latest/llm/pretraining/dataset.html
6060

@@ -79,30 +79,26 @@ mv llama_openwebtext_100k.idx ./data
7979

8080
```shell
8181
# 编译自定义算子,可选
82-
cd ../model_zoo/gpt-3/external_ops/ && python3 setup.py install && cd -
82+
cd ..legacy/model_zoo/gpt-3/external_ops/ && python3 setup.py install && cd -
8383

84-
# llama 模型预训练
85-
python -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" run_pretrain.py ./llama/pretrain-llama2_7b-tp2sd4_stage2.json
86-
87-
# Qwen 模型预训练
88-
python -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" run_pretrain.py ./qwen/pretrain_argument_stage2.json
84+
# 模型预训练参考
85+
python -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" run_pretrain.py ./config/llama/pretrain_argument.json
8986
```
9087

9188
注意:
9289
1. 建议使用paddle develop版本训练,需要安装`pip install tool_helpers visualdl==2.5.3`等相关缺失whl包
9390
2. `use_flash_attention` 需要在A100机器开启,建议使用cuda11.8环境。
94-
3. `use_fused_rms_norm` 需要安装[此目录](https://github.com/PaddlePaddle/PaddleNLP/tree/develop/model_zoo/gpt-3/external_ops)下的自定义OP, `python setup.py install`。如果安装后仍然找不到算子,需要额外设置PYTHONPATH
91+
3. `use_fused_rms_norm` 需要安装自定义算子。如果安装后仍然找不到算子,需要额外设置PYTHONPATH
9592
4. `continue_training` 表示从现有的预训练模型加载训练。7b模型初始loss大概为2.xx, 随机初始化模型loss从11.x左右下降。
96-
5. 当前脚本为sharding版本,需要4D并行训练(数据、sharding、张量、流水线并行)的用户,请参考 `run_trainer_tp4pp2.sh`脚本。
97-
6. 多机训练时,若各机器使用的训练数据文件位置相同(例如挂载共享硬盘情况),请指定`--share_folder true`使全局0号卡制作缓存数据。否则默认各台机器的0号卡独立制作缓存数据,
98-
7. 若数据集文件夹中存在默认缓存文件夹`index-cache/`,则额外指定的`--data_cache`不生效,训练时优先加载默认缓存文件夹中的内容。
93+
5. 多机训练时,若各机器使用的训练数据文件位置相同(例如挂载共享硬盘情况),请指定`--share_folder true`使全局0号卡制作缓存数据。否则默认各台机器的0号卡独立制作缓存数据,
94+
6. 若数据集文件夹中存在默认缓存文件夹`index-cache/`,则额外指定的`--data_cache`不生效,训练时优先加载默认缓存文件夹中的内容。
9995

10096

10197

10298
### 2. 精调
10399
PaddleNLP支持多个主流大模型的SFT、LoRA、Prefix Tuning等精调策略,提供统一、高效精调方案:
104100
- **统一训练入口**。飞桨大模型套件精调方案可适配业界主流大模型,用户只需修改配置文件,即能在单卡或多卡(支持4D并行分布式策略)进行多种大模型精调。
105-
- **高效数据和分布式策略**。Zero Padding零填充优化策略有效减少了pad token的占比,提高模型训练效率高达100%。独创PEFT结合低比特和分布式并行策略,大幅降低大模型精调硬件门槛,支持单卡(A100 80G)百亿模型微调、单机(A100 80G * 8)千亿模型微调。
101+
- **高效数据和分布式策略**。Zero Padding零填充优化策略结合FlashMask策略有效提升模型训练效率。独创PEFT结合低比特和分布式并行策略,大幅降低大模型精调硬件门槛,支持单卡(A100 80G)百亿模型微调、单机(A100 80G * 8)千亿模型微调。
106102
- **支持多轮对话**。支持统一对话模板,支持多轮对话高效训练,详参[多轮对话文档](./docs/chat_template.md)
107103

108104

@@ -137,26 +133,26 @@ tar -zxvf AdvertiseGen.tar.gz
137133

138134
**全参精调:SFT**
139135
```bash
140-
# 四卡llama SFT启动命令参考
141-
python -u -m paddle.distributed.launch --gpus "0,1,2,3" finetune_generation.py ./llama/sft_argument.json
136+
# SFT启动命令参考
137+
python -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" run_finetune.py ./config/llama/sft_argument.json
142138
```
143139

144140
**LoRA**
145141
```bash
146-
# 单卡llama LoRA启动命令参考
147-
python finetune_generation.py ./llama/lora_argument.json
142+
# LoRA启动命令参考
143+
python run_finetune.py ./config/llama/lora_argument.json
148144
```
149145

150146
**Prefix Tuning**
151147
```bash
152-
# 单卡llama Prefix Tuning启动命令参考
153-
python finetune_generation.py ./llama/pt_argument.json
148+
# Prefix Tuning启动命令参考
149+
python run_finetune.py ./config/llama/pt_argument.json
154150
```
155151

156152
更多大模型精调分布式使用文档、训练细节和效果请参见[大模型精调教程](./docs/finetune.md)
157153

158154
### 3. 对齐
159-
我们支持DPO等偏好对齐策略。
155+
我们支持DPO等偏好对齐策略。DPO策略采用zero_padding策略,结合FlashMask策略,有效提升模型训练效率。
160156

161157
**数据准备**
162158

@@ -189,10 +185,10 @@ wget https://bj.bcebos.com/paddlenlp/datasets/examples/ultrafeedback_binarized.t
189185
tar -zxvf ultrafeedback_binarized.tar.gz
190186
```
191187

192-
**全参精调:SFT**
188+
**全参DPO**
193189
```bash
194-
# 四卡llama SFT启动命令参考
195-
python -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" dpo_train.py ./llama/dpo_argument.json
190+
# DPO启动命令参考
191+
python -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" ./dpo/run_dpo.py ./config/llama/dpo_argument.json
196192
```
197193

198194
### 4. 量化
@@ -215,10 +211,10 @@ python -u -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" dpo_train.py ./
215211

216212
```
217213
# PTQ 量化启动命令参考
218-
python finetune_generation.py ./llama/ptq_argument.json
214+
python run_finetune.py ./config/llama/ptq_argument.json
219215
220216
# GPTQ 量化启动命令参考
221-
python finetune_generation.py ./llama/ptq_argument.json
217+
python run_finetune.py ./config/llama/ptq_argument.json
222218
```
223219

224220
更多技术细节和模型量化使用详见[量化文档](./docs/quantization.md)
@@ -231,13 +227,13 @@ PaddleNLP除了提供常用模型推理外,还提供了高性能推理,内
231227

232228
```shell
233229
# 动态图模型推理命令参考
234-
python predictor.py --model_name_or_path meta-llama/Llama-2-7b-chat --data_file ./data/dev.json --dtype float16
230+
python ./predict/predictor.py --model_name_or_path meta-llama/Llama-2-7b-chat --data_file ./data/dev.json --dtype float16
235231

236232
# 静态图模型推理命令参考
237233
# step1 : 静态图导出
238-
python export_model.py --model_name_or_path meta-llama/Llama-2-7b-chat --output_path ./inference --dtype float16
234+
python ./predict/export_model.py --model_name_or_path meta-llama/Llama-2-7b-chat --output_path ./inference --dtype float16
239235
# step2: 静态图推理
240-
python predictor.py --model_name_or_path ./inference --data_file ./data/dev.json --dtype float16 --mode static
236+
python ./predict/predictor.py --model_name_or_path ./inference --data_file ./data/dev.json --dtype float16 --mode static
241237
```
242238

243239
- **InferenceModel 高性能推理**:PaddleNLP 还提供了高性能推理模型加快并行推理的速度,同时支持FP16、Prefix Tuning、WINT8、A8W8多种推理方式。
@@ -253,13 +249,13 @@ python predictor.py --model_name_or_path ./inference --data_file ./data/dev.json
253249

254250
```shell
255251
# 高性能动态图模型推理命令参考
256-
python predictor.py --model_name_or_path meta-llama/Llama-2-7b-chat --inference_model --dtype float16
252+
python ./predict/predictor.py --model_name_or_path meta-llama/Llama-2-7b-chat --inference_model --dtype float16
257253

258254
# 高性能静态图模型推理命令参考
259255
# step1 : 静态图导出
260-
python export_model.py --model_name_or_path meta-llama/Llama-2-7b-chat --inference_model --output_path ./inference --dtype float16
256+
python ./predict/export_model.py --model_name_or_path meta-llama/Llama-2-7b-chat --inference_model --output_path ./inference --dtype float16
261257
# step2: 静态图推理
262-
python predictor.py --model_name_or_path ./inference --inference_model --dtype "float16" --mode "static"
258+
python ./predict/predictor.py --model_name_or_path ./inference --inference_model --dtype "float16" --mode "static"
263259
```
264260

265261
更多常用模型推理和高性能模型使用方法详见[大模型推理文档](./docs/inference.md)
@@ -277,7 +273,7 @@ python predictor.py --model_name_or_path ./inference --inference_model --dtype "
277273
我们提供了一套基于动态图推理的简单易用UI服务化部署脚本,用户可以快速部署服务化推理。
278274

279275
```
280-
python -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" flask_server.py \
276+
python -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" ./predict/flask_server.py \
281277
--model_name_or_path meta-llama/Llama-2-7b-chat \
282278
--port 8010 \
283279
--flask_port 8011 \
@@ -287,7 +283,7 @@ python -m paddle.distributed.launch --gpus "0,1,2,3,4,5,6,7" flask_server.py \
287283
- `flask_port`: Flask服务端口号,默认8010。
288284
- 其他参数请参见[推理文档](./docs/inference.md)中推理参数配置。
289285

290-
此外,如果想通过API脚本的方式跑推理,可参考:`./request_flask_server.py` 文件。
286+
此外,如果想通过API脚本的方式跑推理,可参考:`./predict/request_flask_server.py` 文件。
291287

292288
</div></details>
293289

0 commit comments

Comments
 (0)