Skip to content

Commit f925f42

Browse files
authored
Add internlm (#59)
1 parent a467046 commit f925f42

File tree

13 files changed

+119
-17
lines changed

13 files changed

+119
-17
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ 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, seqgpt-560m
35+
2. supported models:
36+
1. qwen series: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B)
37+
2. qwen-vl series: qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL)
38+
3. baichuan series: baichuan-7b, baichuan-13b, baichuan-13b-chat, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat
39+
4. chatglm2 series: chatglm2-6b, chatglm2-6b-32k
40+
5. llama series: llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat
41+
6. openbuddy-llama series: openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b
42+
7. internlm series: internlm-7b, internlm-7b-chat, internlm-7b-chat-8k
43+
8. other: polylm-13b, seqgpt-560m
3644
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, ...
3745
4. supported datasets:
3846
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

README_CN.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ 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, seqgpt-560m
33+
2. 支持的模型:
34+
1. qwen 系列: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B)
35+
2. qwen-vl 系列: qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL)
36+
3. baichuan 系列: baichuan-7b, baichuan-13b, baichuan-13b-chat, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat
37+
4. chatglm2 系列: chatglm2-6b, chatglm2-6b-32k
38+
5. llama 系列: llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat
39+
6. openbuddy-llama 系列: openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b
40+
7. internlm 系列: internlm-7b, internlm-7b-chat, internlm-7b-chat-8k
41+
8. other: polylm-13b, seqgpt-560m
3442
3. 支持的特性: 模型量化, DDP, 模型并行(device_map), gradient checkpointing, 梯度累加, 支持推送ModelScope Hub, 自定义数据集, 多模态和Agent SFT, 多轮对话, ...
3543
4. 支持的数据集:
3644
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

examples/pytorch/llm/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
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, seqgpt-560m
19+
2. supported models:
20+
1. qwen series: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B)
21+
2. qwen-vl series: qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL)
22+
3. baichuan series: baichuan-7b, baichuan-13b, baichuan-13b-chat, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat
23+
4. chatglm2 series: chatglm2-6b, chatglm2-6b-32k
24+
5. llama series: llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat
25+
6. openbuddy-llama series: openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b
26+
7. internlm series: internlm-7b, internlm-7b-chat, internlm-7b-chat-8k
27+
8. other: polylm-13b, seqgpt-560m
2028
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, ...
2129
4. supported datasets:
2230
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

examples/pytorch/llm/README_CN.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
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, seqgpt-560m
20+
2. 支持的模型:
21+
1. qwen 系列: qwen-7b, [qwen-7b-chat](https://github.com/QwenLM/Qwen-7B)
22+
2. qwen-vl 系列: qwen-vl, [qwen-vl-chat](https://github.com/QwenLM/Qwen-VL)
23+
3. baichuan 系列: baichuan-7b, baichuan-13b, baichuan-13b-chat, baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat
24+
4. chatglm2 系列: chatglm2-6b, chatglm2-6b-32k
25+
5. llama 系列: llama2-7b, llama2-7b-chat, llama2-13b, llama2-13b-chat, llama2-70b, llama2-70b-chat
26+
6. openbuddy-llama 系列: openbuddy-llama2-13b, openbuddy-llama-65b, openbuddy-llama2-70b
27+
7. internlm 系列: internlm-7b, internlm-7b-chat, internlm-7b-chat-8k
28+
8. other: polylm-13b, seqgpt-560m
2129
3. 支持的特性: 模型量化, DDP, 模型并行(device_map), gradient checkpointing, 梯度累加, 支持推送ModelScope Hub, 自定义数据集, 多模态和Agent SFT, 多轮对话, ...
2230
4. 支持的数据集:
2331
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
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CUDA_VISIBLE_DEVICES=0 \
2+
python src/llm_infer.py \
3+
--model_type internlm-7b-chat \
4+
--sft_type lora \
5+
--template_type internlm \
6+
--dtype bf16 \
7+
--ckpt_dir "runs/internlm-7b-chat/vx_xxx/checkpoint-xxx" \
8+
--eval_human true \
9+
--max_new_tokens 1024 \
10+
--temperature 0.9 \
11+
--top_k 50 \
12+
--top_p 0.9 \
13+
--do_sample true \
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
nproc_per_node=2
2+
CUDA_VISIBLE_DEVICES=0,1 \
3+
torchrun \
4+
--nproc_per_node=$nproc_per_node \
5+
--master_port 29500 \
6+
src/llm_sft.py \
7+
--model_type internlm-7b-chat \
8+
--sft_type lora \
9+
--template_type internlm \
10+
--dtype bf16 \
11+
--output_dir runs \
12+
--ddp_backend nccl \
13+
--dataset alpaca-en,alpaca-zh \
14+
--dataset_sample 20000 \
15+
--num_train_epochs 1 \
16+
--max_length 1024 \
17+
--lora_rank 8 \
18+
--lora_alpha 32 \
19+
--lora_dropout_p 0.05 \
20+
--lora_target_modules q_proj k_proj v_proj \
21+
--gradient_checkpointing false \
22+
--batch_size 1 \
23+
--weight_decay 0. \
24+
--learning_rate 1e-4 \
25+
--gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
26+
--max_grad_norm 0.5 \
27+
--warmup_ratio 0.03 \
28+
--eval_steps 100 \
29+
--save_steps 100 \
30+
--save_total_limit 2 \
31+
--logging_steps 10 \
32+
--push_to_hub false \
33+
--hub_model_id internlm-7b-lora \
34+
--hub_private_repo true \
35+
--hub_token 'your-sdk-token' \

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ python src/llm_infer.py \
66
--dtype bf16 \
77
--ckpt_dir "runs/qwen-7b/vx_xxx/checkpoint-xxx" \
88
--eval_human true \
9+
--use_flash_attn true \
910
--max_new_tokens 1024 \
1011
--temperature 0.9 \
1112
--top_k 50 \

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ torchrun \
2929
--save_steps 100 \
3030
--save_total_limit 2 \
3131
--logging_steps 10 \
32-
--use_flash_attn false \
32+
--use_flash_attn true \
3333
--push_to_hub false \
3434
--hub_model_id qwen-7b-lora \
3535
--hub_private_repo true \

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ python src/llm_infer.py \
88
--eval_human false \
99
--dataset coco-en \
1010
--dataset_sample 20000 \
11+
--use_flash_attn true \
1112
--max_new_tokens 1024 \
1213
--temperature 0.9 \
1314
--top_k 50 \

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ torchrun \
2929
--save_steps 100 \
3030
--save_total_limit 2 \
3131
--logging_steps 10 \
32-
--use_flash_attn false \
32+
--use_flash_attn true \
3333
--push_to_hub false \
3434
--hub_model_id qwen-vl-lora \
3535
--hub_private_repo true \

0 commit comments

Comments
 (0)