Skip to content

Commit a467046

Browse files
authored
Add bloom (#55)
1 parent a875f16 commit a467046

File tree

49 files changed

+266
-209
lines changed

Some content is hidden

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

49 files changed

+266
-209
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ Key features:
3232
[code link](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm)
3333

3434
1. supported SFT methods: [lora](https://arxiv.org/abs/2106.09685), [qlora](https://arxiv.org/abs/2305.14314), full(full parameter fine-tuning)
35-
2. supported models: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B), qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL), baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b, polylm-13b, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat
35+
2. supported models: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B), qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL), baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b, polylm-13b, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat, seqgpt-560m
3636
3. supported features: quantization, ddp, model parallelism(device map), gradient checkpointing, gradient accumulation, pushing to modelscope hub, custom datasets, multimodal and agent SFT, mutli-round chat, ...
3737
4. supported datasets:
38-
1. NLP: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh, firefly-all-zh, poetry-zh, instruct-en, gpt4all-en
38+
1. NLP: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh, firefly-all-zh, poetry-zh, instruct-en, gpt4all-en, cmnli-zh
3939
2. agent: [damo-agent-zh](https://modelscope.cn/datasets/damo/MSAgent-Bench/summary), damo-agent-mini-zh
4040
3. multi-modal: coco-en
41-
5. supported templates: chatml(qwen), baichuan, chatglm2, llama, openbuddy-llama, default
41+
5. supported templates: chatml(qwen), baichuan, chatglm2, llama, openbuddy-llama, default, default-generation
4242

4343
# Installation
4444

README_CN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ SWIFT(Scalable lightWeight Infrastructure for Fine-Tuning)是一个可扩展
3030
[code link](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm)
3131

3232
1. 支持的SFT方法: [lora](https://arxiv.org/abs/2106.09685), [qlora](https://arxiv.org/abs/2305.14314), 全参数微调
33-
2. 支持的模型: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B), qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL), baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b, polylm-13b, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat
33+
2. 支持的模型: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B), qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL), baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b, polylm-13b, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat, seqgpt-560m
3434
3. 支持的特性: 模型量化, DDP, 模型并行(device_map), gradient checkpointing, 梯度累加, 支持推送ModelScope Hub, 自定义数据集, 多模态和Agent SFT, 多轮对话, ...
3535
4. 支持的数据集:
36-
1. NLP: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh, firefly-all-zh, poetry-zh, instruct-en, gpt4all-en
36+
1. NLP: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh, firefly-all-zh, poetry-zh, instruct-en, gpt4all-en, cmnli-zh
3737
2. agent: [damo-agent-zh](https://modelscope.cn/datasets/damo/MSAgent-Bench/summary), damo-agent-mini-zh
38-
3. multi-modal: coco-en
39-
5. 支持的对话模板: chatml(qwen), baichuan, chatglm2, llama, openbuddy-llama, default
38+
3. 多模态: coco-en
39+
5. 支持的对话模板: chatml(qwen), baichuan, chatglm2, llama, openbuddy-llama, default, default-generation
4040

4141
# 安装
4242

examples/pytorch/llm/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
## Features
1818
1. supported SFT methods: [lora](https://arxiv.org/abs/2106.09685), [qlora](https://arxiv.org/abs/2305.14314), full(full parameter fine-tuning)
19-
2. supported models: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B), qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL), baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b, polylm-13b, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat
19+
2. supported models: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B), qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL), baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b, polylm-13b, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat, seqgpt-560m
2020
3. supported features: quantization, ddp, model parallelism(device map), gradient checkpointing, gradient accumulation, pushing to modelscope hub, custom datasets, multimodal and agent SFT, mutli-round chat, ...
2121
4. supported datasets:
22-
1. NLP: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh, firefly-all-zh, poetry-zh, instruct-en, gpt4all-en
22+
1. NLP: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh, firefly-all-zh, poetry-zh, instruct-en, gpt4all-en, cmnli-zh
2323
2. agent: [damo-agent-zh](https://modelscope.cn/datasets/damo/MSAgent-Bench/summary), damo-agent-mini-zh
2424
3. multi-modal: coco-en
25-
5. supported templates: chatml(qwen), baichuan, chatglm2, llama, openbuddy-llama, default
25+
5. supported templates: chatml(qwen), baichuan, chatglm2, llama, openbuddy-llama, default, default-generation
2626

2727
## Prepare the Environment
2828
Experimental environment: A10, 3090, A100, ... (V100 does not support bf16, quantization)
@@ -59,21 +59,21 @@ pip install .
5959
git clone https://github.com/modelscope/swift.git
6060
cd swift/examples/pytorch/llm
6161

62-
# sft lora and infer qwen-7b, Requires 22GB VRAM.
62+
# sft lora and infer qwen-7b, Requires 27GB VRAM.
6363
# If you want to push weights into modelscope hub during training, you need to set '--push_to_hub true'
6464
bash scripts/qwen_7b_chat/lora/sft.sh
6565
bash scripts/qwen_7b_chat/lora/infer.sh
6666

67-
# sft(lora+ddp) and infer qwen-7b, Requires 4*22GB VRAM.
67+
# sft(lora+ddp) and infer qwen-7b, Requires 4*27GB VRAM.
6868
bash scripts/qwen_7b_chat/lora_ddp/sft.sh
6969
bash scripts/qwen_7b_chat/lora_ddp/infer.sh
7070

71-
# sft(qlora) and infer qwen-7b, Requires 16GB VRAM.
71+
# sft(qlora) and infer qwen-7b, Requires 20GB VRAM.
7272
# If you want to use quantification, you need to `pip install bitsandbytes -U`
7373
bash scripts/qwen_7b_chat/qlora/sft.sh
7474
bash scripts/qwen_7b_chat/qlora/infer.sh
7575

76-
# sft(qlora+ddp) and infer qwen-7b, Requires 4*16GB VRAM.
76+
# sft(qlora+ddp) and infer qwen-7b, Requires 4*20GB VRAM.
7777
bash scripts/qwen_7b_chat/qlora_ddp/sft.sh
7878
bash scripts/qwen_7b_chat/qlora_ddp/infer.sh
7979

examples/pytorch/llm/README_CN.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
## 特性
1919
1. 支持的SFT方法: [lora](https://arxiv.org/abs/2106.09685), [qlora](https://arxiv.org/abs/2305.14314), 全参数微调
20-
2. 支持的模型: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B), qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL), baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b, polylm-13b, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat
20+
2. 支持的模型: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B), qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL), baichuan-7b, baichuan-13b, baichuan-13b-chat, chatglm2-6b, chatglm2-6b-32k, llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat, openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b, polylm-13b, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat, seqgpt-560m
2121
3. 支持的特性: 模型量化, DDP, 模型并行(device_map), gradient checkpointing, 梯度累加, 支持推送ModelScope Hub, 自定义数据集, 多模态和Agent SFT, 多轮对话, ...
2222
4. 支持的数据集:
23-
1. NLP: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh, firefly-all-zh, poetry-zh, instruct-en, gpt4all-en
23+
1. NLP: alpaca-en(gpt4), alpaca-zh(gpt4), finance-en, multi-alpaca-all, code-en, instinwild-en, instinwild-zh, cot-en, cot-zh, firefly-all-zh, poetry-zh, instruct-en, gpt4all-en, cmnli-zh
2424
2. agent: [damo-agent-zh](https://modelscope.cn/datasets/damo/MSAgent-Bench/summary), damo-agent-mini-zh
25-
3. multi-modal: coco-en
26-
5. 支持的对话模板: chatml(qwen), baichuan, chatglm2, llama, openbuddy-llama, default
25+
3. 多模态: coco-en
26+
5. 支持的对话模板: chatml(qwen), baichuan, chatglm2, llama, openbuddy-llama, default, default-generation
2727

2828
## 准备实验环境
2929
实验环境: A10, 3090, A100均可. (V100不支持bf16, 量化)
@@ -61,21 +61,21 @@ pip install .
6161
git clone https://github.com/modelscope/swift.git
6262
cd swift/examples/pytorch/llm
6363

64-
# 微调(lora)+推理 qwen-7b, 需要22GB显存.
64+
# 微调(lora)+推理 qwen-7b, 需要27GB显存.
6565
# 如果你想在训练时, 将权重push到modelscope hub中, 你需要设置`--push_to_hub true`
6666
bash scripts/qwen_7b_chat/lora/sft.sh
6767
bash scripts/qwen_7b_chat/lora/infer.sh
6868

69-
# 微调(lora+ddp)+推理 qwen-7b, 需要4卡*22GB显存.
69+
# 微调(lora+ddp)+推理 qwen-7b, 需要4卡*27GB显存.
7070
bash scripts/qwen_7b_chat/lora_ddp/sft.sh
7171
bash scripts/qwen_7b_chat/lora_ddp/infer.sh
7272

73-
# 微调(qlora)+推理 qwen-7b, 需要16GB显存.
73+
# 微调(qlora)+推理 qwen-7b, 需要20GB显存.
7474
# 如果你想要使用量化, 你需要`pip install bitsandbytes -U`
7575
bash scripts/qwen_7b_chat/qlora/sft.sh
7676
bash scripts/qwen_7b_chat/qlora/infer.sh
7777

78-
# 微调(qlora+ddp)+推理 qwen-7b, 需要4卡*16GB显存.
78+
# 微调(qlora+ddp)+推理 qwen-7b, 需要4卡*20GB显存.
7979
bash scripts/qwen_7b_chat/qlora_ddp/sft.sh
8080
bash scripts/qwen_7b_chat/qlora_ddp/infer.sh
8181

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# 16G
21
CUDA_VISIBLE_DEVICES=0 \
32
python src/llm_infer.py \
43
--model_type baichuan2-7b-chat \

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# 4 * 22GB VRAM
2-
nproc_per_node=4
3-
CUDA_VISIBLE_DEVICES=0,1,2,3 \
1+
# Experimental environment: 2 * A100
2+
nproc_per_node=2
3+
CUDA_VISIBLE_DEVICES=0,1 \
44
torchrun \
55
--nproc_per_node=$nproc_per_node \
66
--master_port 29500 \
@@ -19,15 +19,15 @@ torchrun \
1919
--lora_alpha 32 \
2020
--lora_dropout_p 0.05 \
2121
--lora_target_modules W_pack o_proj \
22-
--gradient_checkpointing true \
22+
--gradient_checkpointing false \
2323
--batch_size 1 \
2424
--weight_decay 0. \
2525
--learning_rate 1e-4 \
2626
--gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
2727
--max_grad_norm 0.5 \
2828
--warmup_ratio 0.03 \
29-
--eval_steps 50 \
30-
--save_steps 50 \
29+
--eval_steps 100 \
30+
--save_steps 100 \
3131
--save_total_limit 2 \
3232
--logging_steps 10 \
3333
--push_to_hub false \

examples/pytorch/llm/scripts/chatglm_6b/lora_ddp/infer.sh renamed to examples/pytorch/llm/scripts/chatglm2_6b/lora_ddp/infer.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# 14G
21
CUDA_VISIBLE_DEVICES=0 \
32
python src/llm_infer.py \
43
--model_type chatglm2-6b \
54
--sft_type lora \
5+
--template_type chatglm2 \
6+
--dtype bf16 \
67
--ckpt_dir "runs/chatglm2-6b/vx_xxx/checkpoint-xxx" \
78
--eval_human true \
89
--max_new_tokens 1024 \
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
1-
# 4 * 15G
2-
# ddp_backend gloo: support windows
3-
nproc_per_node=4
4-
CUDA_VISIBLE_DEVICES=0,1,2,3 \
1+
nproc_per_node=2
2+
CUDA_VISIBLE_DEVICES=0,1 \
53
torchrun \
64
--nproc_per_node=$nproc_per_node \
75
--master_port 29500 \
86
src/llm_sft.py \
97
--model_type chatglm2-6b \
108
--sft_type lora \
9+
--template_type chatglm2 \
10+
--dtype bf16 \
1111
--output_dir runs \
12-
--ddp_backend gloo \
12+
--ddp_backend nccl \
1313
--dataset alpaca-en,alpaca-zh \
1414
--dataset_sample -1 \
1515
--num_train_epochs 1 \
1616
--max_length 1024 \
1717
--lora_rank 8 \
1818
--lora_alpha 32 \
1919
--lora_dropout_p 0.1 \
20+
--gradient_checkpointing false \
2021
--batch_size 1 \
22+
--weight_decay 0. \
2123
--learning_rate 1e-4 \
2224
--gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
23-
--eval_steps 50 \
24-
--save_steps 50 \
25+
--max_grad_norm 0.5 \
26+
--warmup_ratio 0.03 \
27+
--eval_steps 100 \
28+
--save_steps 100 \
2529
--save_total_limit 2 \
2630
--logging_steps 10 \
31+
--push_to_hub false \
32+
--hub_model_id chatglm2-6b-lora \
33+
--hub_private_repo true \
34+
--hub_token 'your-sdk-token' \

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# 40G
21
CUDA_VISIBLE_DEVICES=0,1 \
32
python src/llm_infer.py \
43
--model_type llama2-7b-chat \

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# 44G
2-
# llama2 is not good at Chinese
1+
# Experimental environment: 2 * 3090
32
CUDA_VISIBLE_DEVICES=0,1 \
43
python src/llm_sft.py \
54
--model_type llama2-70b-chat \
@@ -16,7 +15,7 @@ python src/llm_sft.py \
1615
--batch_size 1 \
1716
--learning_rate 1e-4 \
1817
--gradient_accumulation_steps 16 \
19-
--eval_steps 50 \
20-
--save_steps 50 \
18+
--eval_steps 100 \
19+
--save_steps 100 \
2120
--save_total_limit 2 \
2221
--logging_steps 10 \

0 commit comments

Comments
 (0)