Skip to content

Commit e893ed8

Browse files
authored
add dataset (#65)
1 parent 9752725 commit e893ed8

File tree

36 files changed

+266
-123
lines changed

36 files changed

+266
-123
lines changed

examples/pytorch/llm/README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,40 @@ pip install .
6262
```
6363

6464
## Run SFT and Inference
65+
Performace: full(nice) > lora > qlora
66+
Training GPU memory: qlora(low,3090) > lora > full(2*A100)
6567
```bash
6668
# Clone the repository and enter the code directory.
6769
git clone https://github.com/modelscope/swift.git
6870
cd swift/examples/pytorch/llm
6971

70-
# sft lora and infer qwen-7b, Requires 27GB VRAM.
71-
# If you want to push weights into modelscope hub during training, you need to set '--push_to_hub true'
72+
# sft lora and infer qwen-7b-chat, Requires 27GB GPU memory.
73+
# You can save GPU memory by setting `--gradient_checkpointing true`, but this will slightly decrease the training speed.
74+
# If you want to push weights into modelscope hub during training, you need to set '--push_to_hub true'.
75+
# Recommended experimental environment: A100
7276
bash scripts/qwen_7b_chat/lora/sft.sh
7377
bash scripts/qwen_7b_chat/lora/infer.sh
7478

75-
# sft(lora+ddp) and infer qwen-7b, Requires 4*27GB VRAM.
79+
# sft(lora+ddp) and infer qwen-7b-chat, Requires 2*27GB GPU memory.
7680
bash scripts/qwen_7b_chat/lora_ddp/sft.sh
7781
bash scripts/qwen_7b_chat/lora_ddp/infer.sh
7882

79-
# sft(qlora) and infer qwen-7b, Requires 20GB VRAM.
83+
# sft(qlora) and infer qwen-7b-chat, Requires 13GB GPU memory.
8084
# If you want to use quantification, you need to `pip install bitsandbytes -U`
85+
# Recommended experimental environment: 3090
8186
bash scripts/qwen_7b_chat/qlora/sft.sh
8287
bash scripts/qwen_7b_chat/qlora/infer.sh
8388

84-
# sft(qlora+ddp) and infer qwen-7b, Requires 4*20GB VRAM.
89+
# sft(qlora+ddp) and infer qwen-7b-chat, Requires 2*13GB GPU memory.
8590
bash scripts/qwen_7b_chat/qlora_ddp/sft.sh
8691
bash scripts/qwen_7b_chat/qlora_ddp/infer.sh
8792

88-
# sft(full) and infer qwen-7b, Requires 95GB VRAM.
93+
# sft(full) and infer qwen-7b-chat, Requires 100GB GPU memory.
94+
# Recommended experimental environment: A100
8995
bash scripts/qwen_7b_chat/full/sft.sh
9096
bash scripts/qwen_7b_chat/full/infer.sh
9197

92-
# For more scripts, please see `scripts/` folder
98+
# For more scripts, please see `scripts/` folder.
9399
```
94100

95101
## Extend Datasets

examples/pytorch/llm/README_CN.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,34 +64,40 @@ pip install .
6464
```
6565

6666
## 微调和推理
67+
性能: full(优) > lora > qlora
68+
训练显存: qlora(低,3090) > lora > full(2*A100)
6769
```bash
6870
# clone仓库并进入代码目录
6971
git clone https://github.com/modelscope/swift.git
7072
cd swift/examples/pytorch/llm
7173

72-
# 微调(lora)+推理 qwen-7b, 需要27GB显存.
73-
# 如果你想在训练时, 将权重push到modelscope hub中, 你需要设置`--push_to_hub true`
74+
# 微调(lora)+推理 qwen-7b-chat, 需要27GB显存.
75+
# 你可以通过设置`--gradient_checkpointing true`来节约显存, 但这会略微降低训练速度.
76+
# 如果你想在训练时, 将权重push到modelscope hub中, 你需要设置`--push_to_hub true`.
77+
# 推荐的实验环境: A100
7478
bash scripts/qwen_7b_chat/lora/sft.sh
7579
bash scripts/qwen_7b_chat/lora/infer.sh
7680

77-
# 微调(lora+ddp)+推理 qwen-7b, 需要4卡*27GB显存.
81+
# 微调(lora+ddp)+推理 qwen-7b-chat, 需要2卡*27GB显存.
7882
bash scripts/qwen_7b_chat/lora_ddp/sft.sh
7983
bash scripts/qwen_7b_chat/lora_ddp/infer.sh
8084

81-
# 微调(qlora)+推理 qwen-7b, 需要20GB显存.
85+
# 微调(qlora)+推理 qwen-7b-chat, 需要13GB显存.
8286
# 如果你想要使用量化, 你需要`pip install bitsandbytes -U`
87+
# 推荐的实验环境: 3090
8388
bash scripts/qwen_7b_chat/qlora/sft.sh
8489
bash scripts/qwen_7b_chat/qlora/infer.sh
8590

86-
# 微调(qlora+ddp)+推理 qwen-7b, 需要4卡*20GB显存.
91+
# 微调(qlora+ddp)+推理 qwen-7b-chat, 需要2卡*13GB显存.
8792
bash scripts/qwen_7b_chat/qlora_ddp/sft.sh
8893
bash scripts/qwen_7b_chat/qlora_ddp/infer.sh
8994

90-
# 微调(full)+推理 qwen-7b, 需要95G显存.
95+
# 微调(full)+推理 qwen-7b-chat, 需要100G显存.
96+
# 推荐的实验环境: A100
9197
bash scripts/qwen_7b_chat/full/sft.sh
9298
bash scripts/qwen_7b_chat/full/infer.sh
9399

94-
# 更多的scripts脚本, 可以看`scripts`文件夹
100+
# 更多的scripts脚本, 可以看`scripts`文件夹.
95101
```
96102

97103
## 拓展数据集

examples/pytorch/llm/scripts/baichuan2_7b_chat/lora_ddp/sft.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ torchrun \
1414
--dataset alpaca-en,alpaca-zh \
1515
--dataset_sample 20000 \
1616
--num_train_epochs 1 \
17-
--max_length 1024 \
17+
--max_length 2048 \
1818
--lora_rank 8 \
1919
--lora_alpha 32 \
20-
--lora_dropout_p 0.05 \
20+
--lora_dropout_p 0. \
2121
--lora_target_modules W_pack o_proj \
2222
--gradient_checkpointing false \
2323
--batch_size 1 \

examples/pytorch/llm/scripts/chatglm2_6b/lora_ddp/sft.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ torchrun \
1313
--dataset alpaca-en,alpaca-zh \
1414
--dataset_sample -1 \
1515
--num_train_epochs 1 \
16-
--max_length 1024 \
16+
--max_length 2048 \
1717
--lora_rank 8 \
1818
--lora_alpha 32 \
19-
--lora_dropout_p 0.1 \
19+
--lora_dropout_p 0. \
2020
--gradient_checkpointing false \
2121
--batch_size 1 \
2222
--weight_decay 0. \

examples/pytorch/llm/scripts/internlm_7b_chat/lora_ddp/sft.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ torchrun \
1313
--dataset alpaca-en,alpaca-zh \
1414
--dataset_sample 20000 \
1515
--num_train_epochs 1 \
16-
--max_length 1024 \
16+
--max_length 2048 \
1717
--lora_rank 8 \
1818
--lora_alpha 32 \
19-
--lora_dropout_p 0.05 \
19+
--lora_dropout_p 0. \
2020
--lora_target_modules q_proj k_proj v_proj \
2121
--gradient_checkpointing false \
2222
--batch_size 1 \

examples/pytorch/llm/scripts/llama2_70b_chat/qlora/sft.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ python src/llm_sft.py \
77
--dataset alpaca-en \
88
--dataset_sample 20000 \
99
--num_train_epochs 1 \
10-
--max_length 1024 \
10+
--max_length 2048 \
1111
--quantization_bit 4 \
1212
--lora_rank 8 \
1313
--lora_alpha 32 \
14-
--lora_dropout_p 0.1 \
14+
--lora_dropout_p 0. \
1515
--batch_size 1 \
1616
--learning_rate 1e-4 \
1717
--gradient_accumulation_steps 16 \

examples/pytorch/llm/scripts/openbuddy-llama2-70b/qlora/sft.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ python src/llm_sft.py \
99
--dataset alpaca-en,alpaca-zh \
1010
--dataset_sample 20000 \
1111
--num_train_epochs 1 \
12-
--max_length 1024 \
12+
--max_length 2048 \
1313
--quantization_bit 4 \
1414
--bnb_4bit_comp_dtype bf16 \
1515
--lora_rank 8 \
1616
--lora_alpha 32 \
17-
--lora_dropout_p 0.1 \
17+
--lora_dropout_p 0. \
1818
--gradient_checkpointing false \
1919
--batch_size 1 \
2020
--weight_decay 0. \

examples/pytorch/llm/scripts/polylm_13b/qlora_ddp/sft.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ torchrun \
1212
--dataset alpaca-en,alpaca-zh \
1313
--dataset_sample -1 \
1414
--num_train_epochs 1 \
15-
--max_length 1024 \
15+
--max_length 2048 \
1616
--quantization_bit 4 \
1717
--lora_rank 8 \
1818
--lora_alpha 32 \
19-
--lora_dropout_p 0.1 \
19+
--lora_dropout_p 0. \
2020
--batch_size 1 \
2121
--learning_rate 1e-4 \
2222
--gradient_accumulation_steps $(expr 16 / $nproc_per_node) \

examples/pytorch/llm/scripts/qwen_7b/lora_ddp/infer.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ CUDA_VISIBLE_DEVICES=0 \
22
python src/llm_infer.py \
33
--model_type qwen-7b \
44
--sft_type lora \
5-
--template_type default \
5+
--template_type default-generation \
66
--dtype bf16 \
77
--ckpt_dir "runs/qwen-7b/vx_xxx/checkpoint-xxx" \
8-
--eval_human true \
8+
--eval_human false \
9+
--dataset dureader-robust-zh \
10+
--dataset_sample -1 \
11+
--max_length 2048 \
912
--use_flash_attn true \
1013
--max_new_tokens 1024 \
1114
--temperature 0.9 \

examples/pytorch/llm/scripts/qwen_7b/lora_ddp/sft.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ torchrun \
66
src/llm_sft.py \
77
--model_type qwen-7b \
88
--sft_type lora \
9-
--template_type default \
9+
--template_type default-generation \
1010
--dtype bf16 \
1111
--output_dir runs \
1212
--ddp_backend nccl \
13-
--dataset alpaca-en,alpaca-zh \
13+
--dataset dureader-robust-zh \
1414
--dataset_sample -1 \
1515
--num_train_epochs 1 \
16-
--max_length 1024 \
16+
--max_length 2048 \
1717
--lora_rank 8 \
1818
--lora_alpha 32 \
19-
--lora_dropout_p 0.05 \
19+
--lora_dropout_p 0. \
2020
--lora_target_modules c_attn c_proj \
2121
--gradient_checkpointing false \
2222
--batch_size 1 \

0 commit comments

Comments
 (0)