Skip to content

Commit 2e02bd4

Browse files
committed
Merge commit 'ca4d2f6ecef44df77289a02d3927b014a25bacac' into fix/packing
* commit 'ca4d2f6ecef44df77289a02d3927b014a25bacac': (29 commits) update wechat (modelscope#1071) Support glm4 (modelscope#1069) fix argument (modelscope#1066) ✏️ fix typo (modelscope#1064) Fix citest test_run.py (modelscope#1059) fix deepseek-vl template (modelscope#1057) fix vllm==0.4.3 (modelscope#1055) Fix mini-internvl-4b (modelscope#1054) fix mini-internvl-4b (modelscope#1053) support sharegpt dataset format (modelscope#1052) fix deepseek-vl (modelscope#1046) update arguments (modelscope#1044) update arguments (modelscope#1043) fix phi3-vision bug fix phi3-vision bug (modelscope#1039) bump version Support SimPO Algorithm (modelscope#1037) support multimodal deploy (modelscope#1029) support mini-internvl (modelscope#1032) fix bugs (modelscope#1038) ... # Conflicts: # swift/llm/sft.py
2 parents 1279a52 + ca4d2f6 commit 2e02bd4

Some content is hidden

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

75 files changed

+3732
-923
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ SWIFT has rich documentations for users, please check [here](https://github.com/
4747
SWIFT web-ui is available both on [Huggingface space](https://huggingface.co/spaces/tastelikefeet/swift) and [ModelScope studio](https://www.modelscope.cn/studios/iic/Scalable-lightWeight-Infrastructure-for-Fine-Tuning/summary), please feel free to try!
4848

4949
## 🎉 News
50+
- 🔥2024.06.05: Support for **glm4** series LLM and glm4v-9b-chat MLLM. You can refer to [glm4v best practice](docs/source/Multi-Modal/glm4v最佳实践.md).
51+
- 🔥2024.06.01: Supoprts **SimPO** training! See [document](https://github.com/modelscope/swift/blob/main/docs/source_en/LLM/SimPO.md) to start training!
52+
- 🔥2024.06.01: Support for deploying large multimodal models, please refer to the [Multimodal Deployment Documentation](docs/source_en/Multi-Modal/mutlimodal-deployment.md) for more information.
53+
- 2024.05.31: Supports Mini-Internvl model, Use model_type `mini-internvl-chat-2b-v1_5` and `mini-internvl-chat-4b-v1_5`to train.
5054
- 2024.05.24: Supports Phi3-vision model, Use model_type `phi3-vision-128k-instruct` to train.
5155
- 2024.05.22: Supports DeepSeek-V2-Lite series models, model_type are `deepseek-v2-lite` and `deepseek-v2-lite-chat`
5256
- 2024.05.22: Supports TeleChat-12B-v2 model with quantized version, model_type are `telechat-12b-v2` and `telechat-12b-v2-gptq-int4`
@@ -233,7 +237,7 @@ You can refer to the following scripts to customize your own training script.
233237
|------------------|-------------------------------------------------------------------------------|
234238
| Pretraining | Text Generation |
235239
| Fine-tuning | Single-turn/Multi-turn<br>Agent Training/Self-cognition<br>Multi-modal Vision/Multi-modal Speech|
236-
| Human Alignment | DPO<br>ORPO |
240+
| Human Alignment | DPO<br>ORPO<br>SimPO |
237241
| Text-to-Image | DreamBooth, etc. |
238242
| Text-to-Video | - |
239243

@@ -533,9 +537,10 @@ The complete list of supported models and datasets can be found at [Supported Mo
533537
| Llava | [Llava series models](https://github.com/haotian-liu/LLaVA) | English | 7B-34B | chat model |
534538
| Llava-Next | [Llava-Next series models](https://github.com/LLaVA-VL/LLaVA-NeXT) | Chinese<br>English | 8B-110B | chat model |
535539
| mPLUG-Owl | [mPLUG-Owl series models](https://github.com/X-PLUG/mPLUG-Owl) | English | 11B | chat model |
536-
| InternVL | [InternVL](https://github.com/OpenGVLab/InternVL) | Chinese<br>English | 25.5B<br>including quantized version | chat model |
540+
| InternVL | [InternVL](https://github.com/OpenGVLab/InternVL) | Chinese<br>English | 2B-25.5B<br>including quantized version | chat model |
537541
| Llava-llama3 | [xtuner](https://huggingface.co/xtuner/llava-llama-3-8b-v1_1-transformers) | English | 8B | chat model |
538-
| Phi3 | Microsoft | English | 4B | chat model |
542+
| Phi3-Vision | Microsoft | English | 4B | chat model |
543+
| PaliGemma | Google | English | 3B | chat model |
539544

540545
#### Diffusion Models
541546

@@ -612,8 +617,6 @@ make docs
612617
| [LLM Evaluation](docs/source_en/LLM/LLM-eval.md) |
613618
| [LLM Quantization](docs/source_en/LLM/LLM-quantization.md) |
614619
| [LLM Deployment](docs/source_en/LLM/VLLM-inference-acceleration-and-deployment.md) |
615-
| [DPO Human Alignment Training](docs/source_en/LLM/DPO.md) |
616-
| [ORPO Human Alignment Training](docs/source_en/LLM/ORPO.md) |
617620
| [AnimateDiff Training](docs/source_en/AIGC/AnimateDiff-train-infer.md) |
618621

619622
### Reference Documentation
@@ -634,6 +637,9 @@ make docs
634637
| [Qwen1.5 Best Practice](docs/source_en/LLM/Qwen1.5-best-practice.md) |
635638
| [Multi-Modal Model Training Best Practice](docs/source_en/Multi-Modal/index.md) |
636639
| [NPU Best Practice](docs/source_en/LLM/NPU-best-practice.md) |
640+
| [DPO Human Alignment Training](docs/source_en/LLM/DPO.md) |
641+
| [ORPO Human Alignment Training](docs/source_en/LLM/ORPO.md) |
642+
| [SimPO Human Alignment Training](docs/source_en/LLM/SimPO.md) |
637643

638644

639645
### Deep Learning Tutorials

README_CN.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ SWIFT具有丰富的文档体系,如有使用问题请请查看[这里](https:
4848
可以在[Huggingface space](https://huggingface.co/spaces/tastelikefeet/swift)[ModelScope创空间](https://www.modelscope.cn/studios/iic/Scalable-lightWeight-Infrastructure-for-Fine-Tuning/summary) 中体验SWIFT web-ui功能了。
4949

5050
## 🎉 新闻
51+
- 🔥2024.06.05: 支持glm4系列大模型和glm4v-9b-chat多模态大模型, 可以查看[glm4v最佳实践](docs/source/Multi-Modal/glm4v最佳实践.md).
52+
- 🔥2024.06.01: 支持**SimPO**训练,使用`swift simpo`来开始训练,最佳实践可以查看[这里](https://github.com/modelscope/swift/tree/main/docs/source/LLM/SimPO算法最佳实践.md)
53+
- 🔥2024.06.01: 支持多模态大模型部署, 可以查看[多模态部署文档](docs/source/Multi-Modal/MLLM部署文档.md).
54+
- 2024.05.31: 支持Mini-Internvl多模态模型, 使用model_type `mini-internvl-chat-2b-v1_5``mini-internvl-chat-4b-v1_5`来训练.
5155
- 2024.05.24: 支持Phi3多模态模型, 使用model_type `phi3-vision-128k-instruct`来训练.
5256
- 2024.05.22: 支持DeepSeek-V2-lite系列模型, model_type为 `deepseek-v2-lite``deekseek-v2-lite-chat`
5357
- 2024.05.22: 支持TeleChat-12b-v2模型和量化版本, model_type为 `telechat-12b-v2``telechat-12b-v2-gptq-int4`
@@ -59,7 +63,7 @@ SWIFT具有丰富的文档体系,如有使用问题请请查看[这里](https:
5963
- 2024.05.11: 支持使用[hqq](https://github.com/mobiusml/hqq)[eetq](https://github.com/NetEase-FuXi/EETQ)进行qlora训练和量化推理,可以查看[LLM量化文档](https://github.com/modelscope/swift/tree/main/docs/source/LLM/LLM量化文档.md)
6064
- 2024.05.10: 支持序列并行. 先安装`pip install .[seq_parallel]`, 之后在DDP环境中添加`--sequence_parallel_size n`即可使用!
6165
- 2024.05.08: 支持DeepSeek-V2-Chat模型, 训练参考[这个脚本](https://github.com/modelscope/swift/blob/main/examples/pytorch/llm/scripts/deepseek-v2-chat/lora_ddp_ds3/sft.sh)。支持InternVL-Chat-V1.5-Int8模型,最佳实践参考[这里](https://github.com/modelscope/swift/tree/main/docs/source/Multi-Modal/internvl最佳实践.md).
62-
- 🔥2024.05.07: 支持**ORPO**训练,使用`swift orpo`来开始使用, 最佳实践可以查看[这里](https://github.com/modelscope/swift/tree/main/docs/source/LLM/ORPO算法最佳实践.md)
66+
- 🔥2024.05.07: 支持**ORPO**训练,使用`swift orpo`来开始训练, 最佳实践可以查看[这里](https://github.com/modelscope/swift/tree/main/docs/source/LLM/ORPO算法最佳实践.md)
6367
- 2024.05.07: 支持来自xtuner的Llava-Llama3模型,model_type为`llava-llama-3-8b-v1_1`.
6468
- 2024.04.29: 支持InternVL-Chat-V1.5的推理与微调, 最佳实践可以查看[这里](https://github.com/modelscope/swift/tree/main/docs/source/Multi-Modal/internvl最佳实践.md).
6569
- 🔥2024.04.26: 支持**LISA****unsloth**训练!指定 `--lisa_activated_layers=2` 来开启LISA(显存使用降低至全参训练的30%),指定 `--tuner_backend unsloth` 来使用unsloth,用更少的显存(30%或更少)更快的速度(5x)训练一个超大模型!
@@ -233,7 +237,7 @@ swift web-ui
233237
| -------- |------------------------------------|
234238
| 预训练 | 文本生成 |
235239
| 微调 | 单轮/多轮<br>Agent训练/自我认知<br>多模态视觉/多模态语音 |
236-
| 人类对齐 | DPO<br>ORPO |
240+
| 人类对齐 | DPO<br>ORPO<br>SimPO |
237241
| 文生图 | DreamBooth等 |
238242
| 文生视频 | - |
239243

@@ -530,9 +534,10 @@ CUDA_VISIBLE_DEVICES=0 swift deploy \
530534
| Llava | [Llava系列模型](https://github.com/haotian-liu/LLaVA) | 英文 | 7B-34B | chat模型 |
531535
| Llava-Next | [Llava-Next系列模型](https://github.com/LLaVA-VL/LLaVA-NeXT) | 中文<br>英文 | 8B-110B | chat模型 |
532536
| mPLUG-Owl | [mPLUG-Owl系列模型](https://github.com/X-PLUG/mPLUG-Owl) | 英文 | 11B | chat模型 |
533-
| InternVL | [InternVL](https://github.com/OpenGVLab/InternVL) | 中文<br>英文 | 25.5B<br>包含量化版本 | chat模型 |
537+
| InternVL | [InternVL](https://github.com/OpenGVLab/InternVL) | 中文<br>英文 | 2B-25.5B<br>包含量化版本 | chat模型 |
534538
| Llava-llama3 | [xtuner](https://huggingface.co/xtuner/llava-llama-3-8b-v1_1-transformers) | 英文 | 8B | chat model |
535-
| Phi3 | Microsoft | 英文 | 4B | chat model |
539+
| Phi3-Vision | 微软 | 英文 | 4B | chat model |
540+
| PaliGemma | Google | 英文 | 3B | chat model |
536541

537542
#### 扩散模型
538543

@@ -610,7 +615,6 @@ make docs
610615
| [LLM评测](https://github.com/modelscope/swift/blob/main/docs/source/LLM/LLM%E8%AF%84%E6%B5%8B%E6%96%87%E6%A1%A3.md) |
611616
| [LLM量化](https://github.com/modelscope/swift/blob/main/docs/source/LLM/LLM%E9%87%8F%E5%8C%96%E6%96%87%E6%A1%A3.md) |
612617
| [LLM部署](https://github.com/modelscope/swift/blob/main/docs/source/LLM/VLLM%E6%8E%A8%E7%90%86%E5%8A%A0%E9%80%9F%E4%B8%8E%E9%83%A8%E7%BD%B2.md) |
613-
| [DPO人类对齐训练](https://github.com/modelscope/swift/blob/main/docs/source/LLM/DPO%E8%AE%AD%E7%BB%83%E6%96%87%E6%A1%A3.md) |
614618
| [AnimateDiff训练](https://github.com/modelscope/swift/blob/main/docs/source/AIGC/AnimateDiff%E5%BE%AE%E8%B0%83%E6%8E%A8%E7%90%86%E6%96%87%E6%A1%A3.md) |
615619

616620

@@ -632,6 +636,9 @@ make docs
632636
| [Qwen1.5最佳实践](https://github.com/modelscope/swift/blob/main/docs/source/LLM/Qwen1.5%E5%85%A8%E6%B5%81%E7%A8%8B%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5.md) |
633637
| [多模态模型训练最佳实践](https://github.com/modelscope/swift/blob/main/docs/source/Multi-Modal/index.md) |
634638
| [NPU推理与微调最佳实践](https://github.com/modelscope/swift/blob/main/docs/source/LLM/NPU%E6%8E%A8%E7%90%86%E4%B8%8E%E5%BE%AE%E8%B0%83%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5.md) |
639+
| [DPO人类对齐训练](https://github.com/modelscope/swift/blob/main/docs/source/LLM/DPO%E8%AE%AD%E7%BB%83%E6%96%87%E6%A1%A3.md) |
640+
| [ORPO人类对齐训练](https://github.com/modelscope/swift/blob/main/docs/source/LLM/ORPO%E7%AE%97%E6%B3%95%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5.md) |
641+
| [SimPO人类对齐训练](https://github.com/modelscope/swift/blob/main/docs/source/LLM/SimPO%E7%AE%97%E6%B3%95%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5.md) |
635642

636643

637644
### 深度学习教程

asset/wechat.png

-16 KB
Loading

docs/resources/simpo1.png

510 KB
Loading

docs/resources/simpo2.png

540 KB
Loading

docs/resources/simpo3.png

694 KB
Loading

docs/resources/simpo4.png

167 KB
Loading

docs/source/LLM/LLM微调文档.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ CUDA_VISIBLE_DEVICES=0 swift sft \
8383
--output_dir output \
8484

8585
# 使用自己的数据集
86+
# 自定义数据集格式查看: https://github.com/modelscope/swift/blob/main/docs/source/LLM/%E8%87%AA%E5%AE%9A%E4%B9%89%E4%B8%8E%E6%8B%93%E5%B1%95.md#%E8%87%AA%E5%AE%9A%E4%B9%89%E6%95%B0%E6%8D%AE%E9%9B%86
8687
CUDA_VISIBLE_DEVICES=0 swift sft \
8788
--model_id_or_path qwen/Qwen-7B-Chat \
8889
--dataset chatml.jsonl \

docs/source/LLM/LLM推理文档.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,26 +183,47 @@ model, tokenizer = get_model_tokenizer(model_type, model_kwargs={'device_map': '
183183

184184
template = get_template(template_type, tokenizer)
185185
seed_everything(42)
186+
186187
query = '浙江的省会在哪里?'
187188
gen = inference_stream(model, template, query)
188189
print(f'query: {query}')
189190
for response, history in gen:
190-
print(f'response: {response}')
191+
pass
192+
print(f'response: {response}')
193+
194+
# 方式1
191195
query = '这有什么好吃的?'
192-
gen = inference_stream(model, template, query, history)
196+
old_history = history
197+
gen = inference_stream(model, template, query, old_history)
193198
print(f'query: {query}')
194199
for response, history in gen:
195200
print(f'response: {response}')
196201
print(f'history: {history}')
197202

203+
# 方式2
204+
query = '这有什么好吃的?'
205+
gen = inference_stream(model, template, query, old_history)
206+
print_idx = 0
207+
print(f'query: {query}\nresponse: ', end='')
208+
for response, history in gen:
209+
delta = response[print_idx:]
210+
print(delta, end='', flush=True)
211+
print_idx = len(response)
212+
print(f'\nhistory: {history}')
213+
198214
"""Out[0]
199215
query: 浙江的省会在哪里?
200-
...
201216
response: 浙江省的省会是杭州。
202217
query: 这有什么好吃的?
218+
response: 杭
219+
response: 杭州
220+
response: 杭州市有
203221
...
204-
response: 杭州市有很多著名的美食,例如西湖醋鱼、龙井虾仁、糖醋排骨、毛血旺等。此外,还有杭州特色的点心,如桂花糕、荷花酥、艾窝窝等。
205-
history: [('浙江的省会在哪里?', '浙江省的省会是杭州。'), ('这有什么好吃的?', '杭州市有很多著名的美食,例如西湖醋鱼、龙井虾仁、糖醋排骨、毛血旺等。此外,还有杭州特色的点心,如桂花糕、荷花酥、艾窝窝等。')]
222+
response: 杭州市有很多著名的美食,例如西湖醋鱼、龙井虾仁、糖醋排骨、毛血旺等。此外,还有杭州特色的点心,如桂花酥饼、抹茶糕点等。
223+
history: [['浙江的省会在哪里?', '浙江省的省会是杭州。'], ['这有什么好吃的?', '杭州市有很多著名的美食,例如西湖醋鱼、龙井虾仁、糖醋排骨、毛血旺等。此外,还有杭州特色的点心,如桂花酥饼、抹茶糕点等。']]
224+
query: 这有什么好吃的?
225+
response: 杭州有许多美食,比如西湖醋鱼、龙井虾仁、酱鸭等。此外,还有许多小吃,如烧麦、春卷、油条等,都是浙江特色美食。
226+
history: [['浙江的省会在哪里?', '浙江省的省会是杭州。'], ['这有什么好吃的?', '杭州有许多美食,比如西湖醋鱼、龙井虾仁、酱鸭等。此外,还有许多小吃,如烧麦、春卷、油条等,都是浙江特色美食。']]
206227
"""
207228
```
208229

0 commit comments

Comments
 (0)