Skip to content

Commit 82a5ae7

Browse files
authored
Support internlm xcomposer2 (#354)
1 parent e8ff04d commit 82a5ae7

File tree

17 files changed

+441
-58
lines changed

17 files changed

+441
-58
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ Users can check the [documentation of SWIFT](docs/source/GetStarted/快速使用
6262

6363

6464
## 🎉 News
65-
- 2024.1.30: Support ZeRO-3, just need to specify `--deepspeed_config_path default-zero3`.
65+
- 2024.1.30: Support [internlm-xcomposer2-7b-chat](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm/scripts/internlm_xcomposer2_7b_chat).
66+
- 2024.1.30: Support [ZeRO-3](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm/scripts/qwen_14b_chat/full_ddp_zero3/), just need to specify `--deepspeed_config_path default-zero3`.
6667
- 2024.1.29: Support internlm2-math series: internlm2-math-7b, internlm2-math-7b-chat, internlm2-math-20b, internlm2-math-20b-chat.
6768
- 🔥2024.1.26: Support [yi-vl-6b-chat](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm/scripts/yi_vl_6b_chat), yi-vl-34b-chat.
6869
- 2024.1.24: Support codefuse-codegeex2-6b-chat, codefuse-qwen-14b-chat.
@@ -198,6 +199,7 @@ app_ui_main(infer_args)
198199
- [qwen-audio](https://github.com/QwenLM/Qwen-Audio) series: qwen-audio, qwen-audio-chat.
199200
- [yi-vl](https://github.com/01-ai/Yi) series: yi-vl-6b-chat, yi-vl-34b-chat.
200201
- [cogagent](https://github.com/THUDM/CogVLM) series: cogagent-18b-chat, cogagent-18b-instruct.
202+
- [internlm-xcomposer2](https://github.com/InternLM/InternLM-XComposer) series: internlm-xcomposer2-7b-chat.
201203
- General:
202204
- [qwen](https://github.com/QwenLM/Qwen) series: qwen-1_8b, qwen-1_8b-chat, qwen-1_8b-chat-int4, qwen-1_8b-chat-int8, qwen-7b, qwen-7b-chat, qwen-7b-chat-int4, qwen-7b-chat-int8, qwen-14b, qwen-14b-chat, qwen-14b-chat-int4, qwen-14b-chat-int8, qwen-72b, qwen-72b-chat, qwen-72b-chat-int4, qwen-72b-chat-int8.
203205
- [chatglm](https://github.com/THUDM/ChatGLM-6B) series: chatglm2-6b, chatglm2-6b-32k, chatglm3-6b-base, chatglm3-6b, chatglm3-6b-32k.
@@ -246,7 +248,7 @@ app_ui_main(infer_args)
246248
- Custom Dataset
247249
- Supported Templates:
248250
- Text Generation: default-generation, default-generation-bos, chatglm-generation.
249-
- Chat: default, qwen, baichuan, chatglm2, chatglm3, llama, openbuddy, internlm, internlm2, yi, yuan, xverse, ziya, skywork, bluelm, zephyr, sus, deepseek, deepseek-coder, codefuse-codellama, codefuse, cogagent-chat, cogagent-instruct, yi-vl.
251+
- Chat: default, qwen, baichuan, chatglm2, chatglm3, llama, openbuddy, internlm, internlm2, yi, yuan, xverse, ziya, skywork, bluelm, zephyr, sus, deepseek, deepseek-coder, codefuse-codellama, codefuse, cogagent-chat, cogagent-instruct, yi-vl, internlm-xcomposer2.
250252

251253

252254
## 🔥SCEdit
@@ -464,7 +466,6 @@ You can contact and communicate with us by joining our WeChat Group:
464466
<img src="asset/wechat.png" width="250" style="display: inline-block;">
465467
</p>
466468

467-
468469
## Star History
469470

470471
[![Star History Chart](https://api.star-history.com/svg?repos=modelscope/swift&type=Date)](https://star-history.com/#modelscope/swift&Date)

README_CN.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ SWIFT(Scalable lightWeight Infrastructure for Fine-Tuning)是一个可扩展
6060
用户可以查看 [SWIFT官方文档](docs/source/GetStarted/快速使用.md) 来了解详细信息。
6161

6262
## 🎉 新闻
63-
- 2024.1.30: 支持ZeRO-3, 只需要指定`--deepspeed_config_path default-zero3`即可.
63+
- 2024.1.30: 支持[internlm-xcomposer2-7b-chat](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm/scripts/internlm_xcomposer2_7b_chat).
64+
- 2024.1.30: 支持[ZeRO-3](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm/scripts/qwen_14b_chat/full_ddp_zero3/), 只需要指定`--deepspeed_config_path default-zero3`即可.
6465
- 2024.1.29: 支持internlm2-math系列: internlm2-math-7b, internlm2-math-7b-chat, internlm2-math-20b, internlm2-math-20b-chat.
65-
- 2024.1.26: 支持[yi-vl-6b-chat](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm/scripts/yi_vl_6b_chat), yi-vl-34b-chat.
66+
- 🔥2024.1.26: 支持[yi-vl-6b-chat](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm/scripts/yi_vl_6b_chat), yi-vl-34b-chat.
6667
- 2024.1.24: 支持codefuse-codegeex2-6b-chat, codefuse-qwen-14b-chat.
6768
- 2024.1.23: 支持orion系列: orion-14b, [orion-14b-chat](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm/scripts/orion_14b_chat).
6869
- 2024.1.20: 支持[xverse-13b-256k](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm/scripts/xverse_13b_256k), xverse-65b-v2, xverse-65b-chat.
@@ -198,6 +199,7 @@ app_ui_main(infer_args)
198199
- [qwen-audio](https://github.com/QwenLM/Qwen-Audio) 系列: qwen-audio, qwen-audio-chat.
199200
- [yi-vl](https://github.com/01-ai/Yi) 系列: yi-vl-6b-chat, yi-vl-34b-chat.
200201
- [cogagent](https://github.com/THUDM/CogVLM) 系列: cogagent-18b-chat, cogagent-18b-instruct.
202+
- [internlm-xcomposer2](https://github.com/InternLM/InternLM-XComposer) 系列: internlm-xcomposer2-7b-chat.
201203
- 通用:
202204
- [qwen](https://github.com/QwenLM/Qwen) 系列: qwen-1_8b, qwen-1_8b-chat, qwen-1_8b-chat-int4, qwen-1_8b-chat-int8, qwen-7b, qwen-7b-chat, qwen-7b-chat-int4, qwen-7b-chat-int8, qwen-14b, qwen-14b-chat, qwen-14b-chat-int4, qwen-14b-chat-int8, qwen-72b, qwen-72b-chat, qwen-72b-chat-int4, qwen-72b-chat-int8.
203205
- [chatglm](https://github.com/THUDM/ChatGLM-6B) 系列: chatglm2-6b, chatglm2-6b-32k, chatglm3-6b-base, chatglm3-6b, chatglm3-6b-32k.
@@ -246,7 +248,7 @@ app_ui_main(infer_args)
246248
- 自定义数据集
247249
- 支持的对话模板:
248250
- 文本生成: default-generation, default-generation-bos, chatglm-generation.
249-
- 对话: default, qwen, baichuan, chatglm2, chatglm3, llama, openbuddy, internlm, internlm2, yi, yuan, xverse, ziya, skywork, bluelm, zephyr, sus, deepseek, deepseek-coder, codefuse-codellama, codefuse, cogagent-chat, cogagent-instruct, yi-vl.
251+
- 对话: default, qwen, baichuan, chatglm2, chatglm3, llama, openbuddy, internlm, internlm2, yi, yuan, xverse, ziya, skywork, bluelm, zephyr, sus, deepseek, deepseek-coder, codefuse-codellama, codefuse, cogagent-chat, cogagent-instruct, yi-vl, internlm-xcomposer2.
250252

251253

252254
## 🔥SCEdit

docs/source/LLM/支持的模型和数据集.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
|internlm2-math-7b-chat|[Shanghai_AI_Laboratory/internlm2-math-7b](https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm2-math-7b/summary)|wqkv|internlm2|&#x2714;|&#x2718;||
7373
|internlm2-math-20b|[Shanghai_AI_Laboratory/internlm2-math-base-20b](https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm2-math-base-20b/summary)|wqkv|default-generation-bos|&#x2714;|&#x2718;||
7474
|internlm2-math-20b-chat|[Shanghai_AI_Laboratory/internlm2-math-20b](https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm2-math-20b/summary)|wqkv|internlm2|&#x2714;|&#x2718;||
75+
|internlm-xcomposer2-7b-chat|[Shanghai_AI_Laboratory/internlm-xcomposer2-7b](https://modelscope.cn/models/Shanghai_AI_Laboratory/internlm-xcomposer2-7b/summary)|wqkv|internlm-xcomposer2|&#x2714;|&#x2718;||
7576
|deepseek-7b|[deepseek-ai/deepseek-llm-7b-base](https://modelscope.cn/models/deepseek-ai/deepseek-llm-7b-base/summary)|q_proj, k_proj, v_proj|default-generation-bos|&#x2714;|&#x2714;||
7677
|deepseek-7b-chat|[deepseek-ai/deepseek-llm-7b-chat](https://modelscope.cn/models/deepseek-ai/deepseek-llm-7b-chat/summary)|q_proj, k_proj, v_proj|deepseek|&#x2714;|&#x2714;||
7778
|deepseek-moe-16b|[deepseek-ai/deepseek-moe-16b-base](https://modelscope.cn/models/deepseek-ai/deepseek-moe-16b-base/summary)|q_proj, k_proj, v_proj|default-generation-bos|&#x2714;|&#x2718;||

docs/source/LLM/自定义与拓展.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,17 @@ AAAAA,BBBBB,CCCCC
9999
{"messages": [{"role": "user", "content": "AAAAA"}, {"role": "assistant", "content": "BBBBB"}, {"role": "user", "content": "CCCCC"}, {"role": "assistant", "content": "DDDDD"}]}
100100
```
101101

102-
**Qwen-VL 系列**
102+
**强化学习(DPO)**
103+
104+
```jsonl
105+
{"query": "11111", "response": "22222", "rejected_response": "33333"}
106+
{"query": "aaaaa", "response": "bbbbb", "rejected_response": "ccccc"}
107+
{"query": "AAAAA", "response": "BBBBB", "rejected_response": "CCCCC"}
108+
```
109+
110+
**Qwen-VL, Internlm-XComposer2 系列**
103111

104-
输入格式兼容: [qwen-vl github](https://github.com/QwenLM/Qwen-VL#data-preparation), 且同样支持csv, json, jsonl格式.
112+
输入格式兼容: [qwen-vl github](https://github.com/QwenLM/Qwen-VL#data-preparation), 且同样支持csv, json, jsonl格式. img_path支持本地路径和url两类.
105113

106114
```json
107115
[{"conversations": [{"from": "user", "value": "Picture 1:<img>img_path</img>\n11111"}, {"from": "assistant", "value": "22222"}]},
@@ -117,12 +125,12 @@ AAAAA,BBBBB,CCCCC
117125
{"conversations": [{"from": "user", "value": "AAAAA"}, {"from": "assistant", "value": "BBBBB"}, {"from": "user", "value": "CCCCC"}, {"from": "assistant", "value": "DDDDD"}]}
118126
```
119127

120-
**强化学习(DPO)**
128+
**Yi-VL 系列**
121129

122130
```jsonl
123-
{"query": "11111", "response": "22222", "rejected_response": "33333"}
124-
{"query": "aaaaa", "response": "bbbbb", "rejected_response": "ccccc"}
125-
{"query": "AAAAA", "response": "BBBBB", "rejected_response": "CCCCC"}
131+
{"query": "55555", "response": "66666", "images": ["image_path"]}
132+
{"query": "eeeee", "response": "fffff", "history": [], "images": ["image_path"]}
133+
{"query": "EEEEE", "response": "FFFFF", "history": [["AAAAA", "BBBBB"], ["CCCCC", "DDDDD"]], "images": ["image_path", "image_path2", "image_path3"]}
126134
```
127135

128136
**CogAgent 系列**
@@ -133,15 +141,6 @@ AAAAA,BBBBB,CCCCC
133141
{"query": "EEEEE", "response": "FFFFF", "history": [["AAAAA", "BBBBB"], ["CCCCC", "DDDDD"]], "images": ["image_path"]}
134142
```
135143

136-
**Yi-VL 系列**
137-
```jsonl
138-
{"query": "55555", "response": "66666", "images": ["image_path"]}
139-
{"query": "eeeee", "response": "fffff", "history": [], "images": ["image_path"]}
140-
{"query": "EEEEE", "response": "FFFFF", "history": [["AAAAA", "BBBBB"], ["CCCCC", "DDDDD"]], "images": ["image_path", "image_path2", "image_path3"]}
141-
```
142-
143-
image字段支持本地图片文件和http可访问的image url两类。
144-
145144
### 注册数据集的方式
146145

147146
以下是一个**注册数据集**的案例. 完整的py文件可以查看[custom.py](https://github.com/modelscope/swift/blob/main/examples/pytorch/llm/custom.py), sh脚本可以查看[custom](https://github.com/modelscope/swift/tree/main/examples/pytorch/llm/scripts/custom).
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Experimental environment: V100, A10, 3090
2+
CUDA_VISIBLE_DEVICES=0 \
3+
swift infer \
4+
--ckpt_dir "output/internlm-xcomposer2-7b-chat/vx_xxx/checkpoint-xxx" \
5+
--load_dataset_config true \
6+
--max_length 2048 \
7+
--use_flash_attn false \
8+
--max_new_tokens 2048 \
9+
--temperature 0.5 \
10+
--top_p 0.7 \
11+
--repetition_penalty 1. \
12+
--do_sample true \
13+
--merge_lora_and_save false \
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Experimental environment: V100, A10, 3090
2+
# 21GB GPU memory
3+
CUDA_VISIBLE_DEVICES=0 \
4+
swift sft \
5+
--model_type internlm-xcomposer2-7b-chat \
6+
--sft_type lora \
7+
--tuner_backend swift \
8+
--template_type AUTO \
9+
--dtype AUTO \
10+
--output_dir output \
11+
--dataset coco-mini-en \
12+
--train_dataset_sample -1 \
13+
--num_train_epochs 1 \
14+
--max_length 2048 \
15+
--check_dataset_strategy warning \
16+
--lora_rank 8 \
17+
--lora_alpha 32 \
18+
--lora_dropout_p 0.05 \
19+
--lora_target_modules DEFAULT \
20+
--gradient_checkpointing true \
21+
--batch_size 1 \
22+
--weight_decay 0.01 \
23+
--learning_rate 1e-4 \
24+
--gradient_accumulation_steps 16 \
25+
--max_grad_norm 0.5 \
26+
--warmup_ratio 0.03 \
27+
--eval_steps 100 \
28+
--save_steps 100 \
29+
--save_total_limit 2 \
30+
--logging_steps 10 \
31+
--use_flash_attn false \
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Experimental environment: A100
2+
CUDA_VISIBLE_DEVICES=0 \
3+
swift infer \
4+
--ckpt_dir "output/qwen-14b-chat/vx_xxx/checkpoint-xxx" \
5+
--load_dataset_config true \
6+
--max_length 2048 \
7+
--use_flash_attn true \
8+
--max_new_tokens 2048 \
9+
--temperature 0.1 \
10+
--top_p 0.7 \
11+
--repetition_penalty 1. \
12+
--do_sample true \
13+
--merge_lora_and_save false \
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Experimental environment: 8 * A100
2+
nproc_per_node=8
3+
NPROC_PER_NODE=$nproc_per_node \
4+
MASTER_PORT=29500 \
5+
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
6+
swift sft \
7+
--model_id_or_path qwen/Qwen-14B-Chat \
8+
--model_revision master \
9+
--sft_type full \
10+
--tuner_backend swift \
11+
--template_type AUTO \
12+
--dtype AUTO \
13+
--output_dir output \
14+
--ddp_backend nccl \
15+
--dataset blossom-math-zh \
16+
--train_dataset_sample -1 \
17+
--num_train_epochs 5 \
18+
--max_length 2048 \
19+
--check_dataset_strategy warning \
20+
--gradient_checkpointing true \
21+
--batch_size 1 \
22+
--weight_decay 0.01 \
23+
--learning_rate 1e-4 \
24+
--gradient_accumulation_steps $(expr 64 / $nproc_per_node) \
25+
--max_grad_norm 0.5 \
26+
--warmup_ratio 0.03 \
27+
--eval_steps 100 \
28+
--save_steps 100 \
29+
--save_total_limit 2 \
30+
--logging_steps 10 \
31+
--use_flash_attn true \
32+
--deepspeed_config_path 'default-zero3' \
33+
--save_only_model true \
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Experimental environment: A100
2+
CUDA_VISIBLE_DEVICES=0 \
3+
swift infer \
4+
--ckpt_dir "output/qwen-7b-chat/vx_xxx/checkpoint-xxx" \
5+
--load_dataset_config true \
6+
--max_length 2048 \
7+
--use_flash_attn true \
8+
--max_new_tokens 2048 \
9+
--temperature 0.1 \
10+
--top_p 0.7 \
11+
--repetition_penalty 1. \
12+
--do_sample true \
13+
--merge_lora_and_save false \
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Experimental environment: 8 * A100
2+
nproc_per_node=8
3+
NPROC_PER_NODE=$nproc_per_node \
4+
MASTER_PORT=29500 \
5+
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
6+
swift sft \
7+
--model_id_or_path qwen/Qwen-7B-Chat \
8+
--model_revision master \
9+
--sft_type full \
10+
--tuner_backend swift \
11+
--template_type AUTO \
12+
--dtype AUTO \
13+
--output_dir output \
14+
--ddp_backend nccl \
15+
--dataset blossom-math-zh \
16+
--train_dataset_sample -1 \
17+
--num_train_epochs 5 \
18+
--max_length 2048 \
19+
--check_dataset_strategy warning \
20+
--gradient_checkpointing true \
21+
--batch_size 1 \
22+
--weight_decay 0.01 \
23+
--learning_rate 1e-4 \
24+
--gradient_accumulation_steps $(expr 64 / $nproc_per_node) \
25+
--max_grad_norm 0.5 \
26+
--warmup_ratio 0.03 \
27+
--eval_steps 100 \
28+
--save_steps 100 \
29+
--save_total_limit 2 \
30+
--logging_steps 10 \
31+
--use_flash_attn true \
32+
--deepspeed_config_path 'default-zero3' \
33+
--save_only_model true \

0 commit comments

Comments
 (0)