Skip to content

Commit ac007df

Browse files
authored
update docs (#3349)
1 parent 4aa48d3 commit ac007df

File tree

19 files changed

+135
-376
lines changed

19 files changed

+135
-376
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ CUDA_VISIBLE_DEVICES=0 swift export \
393393

394394
### Push Model
395395
```shell
396-
CUDA_VISIBLE_DEVICES=0 swift export \
396+
swift export \
397397
--model <model-path> \
398398
--push_to_hub true \
399399
--hub_model_id '<model-id>' \

README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ CUDA_VISIBLE_DEVICES=0 swift export \
381381

382382
### 推送模型
383383
```shell
384-
CUDA_VISIBLE_DEVICES=0 swift export \
384+
swift export \
385385
--model <model-path> \
386386
--push_to_hub true \
387387
--hub_model_id '<model-id>' \

docs/source/BestPractices/GRPO多模态训练.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# GRPO完整实验流程
1+
# 多模态GRPO完整实验流程
22
本文介绍如何使用SWIFT GRPO进行多模态模型和任务的训练。目标是对多个多模态任务进行训练,提升任务精度,任务定义和训练参数等参考了 [R1-V](https://github.com/Deep-Agent/R1-V.git)[open-r1-multimodal](https://github.com/EvolvingLMMs-Lab/open-r1-multimodal.git)
33

44

docs/source/Instruction/人类对齐.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ RM和DPO类算法如ORPO,CPO,SimPO,则需要 $(x,y_w,y_l)$ 格式的数据
1111
而KTO算法的数据比较特殊,只需要 $(x,y,\text{label})$ 格式的数据,其中 $x$ 表示模型输入,$y$ 表示模型输出,label表示回答是否符合人类偏好
1212
比如![kto_data](../../resources/kto_data.png)
1313

14+
使用自定义数据集对文本模型或者多模态大模型进行RLHF训练可以参考[自定义数据集文档](../Customization/自定义数据集.md#rlhf)
15+
1416
## GRPO
1517
[论文arvix](https://arxiv.org/abs/2402.03300)
1618

docs/source/Instruction/导出.md

Lines changed: 0 additions & 112 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# 导出与推送
2+
3+
4+
## Merge LoRA
5+
6+
- 查看[这里](https://github.com/modelscope/ms-swift/blob/main/examples/export/merge_lora.sh)
7+
8+
## 量化
9+
10+
SWFIT支持AWQ、GPTQ、BNB模型的量化导出。其中使用AWQ、GPTQ需使用校准数据集,量化性能较好但量化耗时较长;而BNB无需校准数据集,量化耗时较短。
11+
12+
| 量化技术 | 多模态 | 推理加速 | 继续训练 |
13+
| -------- | ------ | -------- | -------- |
14+
| GPTQ ||||
15+
| AWQ ||||
16+
| BNB ||||
17+
18+
19+
除SWIFT安装外,需要安装以下额外依赖:
20+
```shell
21+
# 使用awq量化:
22+
# autoawq和cuda版本有对应关系,请按照`https://github.com/casper-hansen/AutoAWQ`选择版本
23+
# 如果出现torch依赖冲突,请额外增加指令`--no-deps`
24+
pip install autoawq -U
25+
26+
# 使用gptq量化:
27+
# auto_gptq和cuda版本有对应关系,请按照`https://github.com/PanQiWei/AutoGPTQ#quick-installation`选择版本
28+
pip install auto_gptq optimum -U
29+
30+
# 使用bnb量化:
31+
pip install bitsandbytes -U
32+
```
33+
34+
我们提供了一系列脚本展现SWIFT的量化导出能力:
35+
- 支持[AWQ](https://github.com/modelscope/ms-swift/blob/main/examples/export/quantize/awq.sh)/[GPTQ](https://github.com/modelscope/ms-swift/blob/main/examples/export/quantize/gptq.sh)/[BNB](https://github.com/modelscope/ms-swift/blob/main/examples/export/quantize/bnb.sh)量化导出。
36+
- 多模态量化: 支持使用GPTQ和AWQ对多模态模型进行量化,其中AWQ支持的多模态模型有限。参考[这里](https://github.com/modelscope/ms-swift/tree/main/examples/export/quantize/mllm)
37+
- 更多系列模型的支持: 支持[Bert](https://github.com/modelscope/ms-swift/tree/main/examples/export/quantize/bert)[Reward Model](https://github.com/modelscope/ms-swift/tree/main/examples/export/quantize/reward_model)的量化导出。
38+
- 使用SWIFT量化导出的模型支持使用vllm/lmdeploy进行推理加速;也支持使用QLoRA继续进行SFT/RLHF。
39+
40+
41+
## 推送模型
42+
43+
SWIFT支持将训练/量化的模型重新推送到ModelScope/HuggingFace。默认推送到ModelScope,你可以指定`--use_hf true`推送到HuggingFace。
44+
```shell
45+
swift export \
46+
--model output/vx-xxx/checkpoint-xxx \
47+
--push_to_hub true \
48+
--hub_model_id '<model-id>' \
49+
--hub_token '<sdk-token>' \
50+
--use_hf false
51+
```
52+
53+
小贴士:
54+
- 你可以使用`--model <checkpoint-dir>`或者`--adapters <checkpoint-dir>`指定需要推送的checkpoint目录,这两种写法在推送模型场景没有差异。
55+
- 推送到ModelScope时,你需要确保你已经注册了魔搭账号,你的SDK token可以在[该页面](https://www.modelscope.cn/my/myaccesstoken)中获取。推送模型需确保sdk token的账号具有model_id对应组织的编辑权限。推送模型将自动创建对应model_id的模型仓库(如果该模型仓库不存在),你可以使用`--hub_private_repo true`来自动创建私有的模型仓库。

docs/source/Instruction/推送模型.md

Lines changed: 0 additions & 66 deletions
This file was deleted.

docs/source/Instruction/预训练与微调.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ result = sft_main(TrainArguments(
106106

107107
## Merge LoRA
108108

109-
- 查看[这里](https://github.com/modelscope/ms-swift/blob/main/examples/export/merge_lora.sh)
109+
- 查看[这里](https://github.com/modelscope/ms-swift/blob/main/examples/export/merge_lora.sh)
110110

111111
## 推理(微调后模型)
112112

docs/source/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ Swift DOCUMENTATION
2323
Instruction/推理和部署.md
2424
Instruction/采样.md
2525
Instruction/评测.md
26-
Instruction/导出.md
26+
Instruction/导出与推送.md
2727
Instruction/强化微调.md
2828
Instruction/GRPO.md
2929
Instruction/支持的模型和数据集.md
3030
Instruction/使用tuners.md
3131
Instruction/智能体的支持.md
32-
Instruction/推送模型.md
3332
Instruction/ReleaseNote3.0.md
3433
Instruction/常见问题整理.md
3534

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Export and Push
2+
3+
## Merge LoRA
4+
5+
- See [here](https://github.com/modelscope/ms-swift/blob/main/examples/export/merge_lora.sh).
6+
7+
## Quantization
8+
9+
SWIFT supports quantization exports for AWQ, GPTQ, and BNB models. AWQ and GPTQ require a calibration dataset, which yields better quantization performance but takes longer to quantize. On the other hand, BNB does not require a calibration dataset and is quicker to quantize.
10+
11+
| Quantization Technique | Multimodal | Inference Acceleration | Continued Training |
12+
| ---------------------- | ---------- | ---------------------- | ------------------ |
13+
| GPTQ ||||
14+
| AWQ ||||
15+
| BNB ||||
16+
17+
In addition to the SWIFT installation, the following additional dependencies need to be installed:
18+
19+
```shell
20+
# For AWQ quantization:
21+
# The versions of autoawq and CUDA are correlated; please choose the version according to `https://github.com/casper-hansen/AutoAWQ`.
22+
# If there are dependency conflicts with torch, please add the `--no-deps` option.
23+
pip install autoawq -U
24+
25+
# For GPTQ quantization:
26+
# The versions of auto_gptq and CUDA are correlated; please choose the version according to `https://github.com/PanQiWei/AutoGPTQ#quick-installation`.
27+
pip install auto_gptq optimum -U
28+
29+
# For BNB quantization:
30+
pip install bitsandbytes -U
31+
```
32+
33+
We provide a series of scripts to demonstrate SWIFT's quantization export capabilities:
34+
35+
- Supports [AWQ](https://github.com/modelscope/ms-swift/blob/main/examples/export/quantize/awq.sh)/[GPTQ](https://github.com/modelscope/ms-swift/blob/main/examples/export/quantize/gptq.sh)/[BNB](https://github.com/modelscope/ms-swift/blob/main/examples/export/quantize/bnb.sh) quantization exports.
36+
- Multimodal quantization: Supports quantizing multimodal models using GPTQ and AWQ, with limited multimodal models supported by AWQ. Refer to [here](https://github.com/modelscope/ms-swift/tree/main/examples/export/quantize/mllm).
37+
- Support for more model series: Supports quantization exports for [BERT](https://github.com/modelscope/ms-swift/tree/main/examples/export/quantize/bert) and [Reward Model](https://github.com/modelscope/ms-swift/tree/main/examples/export/quantize/reward_model).
38+
- Models exported with SWIFT's quantization support inference acceleration using vllm/lmdeploy; they also support further SFT/RLHF using QLoRA.
39+
40+
41+
## Push Model
42+
43+
SWIFT supports re-pushing trained/quantized models to ModelScope/Hugging Face. By default, it pushes to ModelScope, but you can specify `--use_hf true` to push to Hugging Face.
44+
45+
```shell
46+
swift export \
47+
--model output/vx-xxx/checkpoint-xxx \
48+
--push_to_hub true \
49+
--hub_model_id '<model-id>' \
50+
--hub_token '<sdk-token>' \
51+
--use_hf false
52+
```
53+
54+
Tips:
55+
56+
- You can use `--model <checkpoint-dir>` or `--adapters <checkpoint-dir>` to specify the checkpoint directory to be pushed. There is no difference between these two methods in the model pushing scenario.
57+
- When pushing to ModelScope, you need to make sure you have registered for a ModelScope account. Your SDK token can be obtained from [this page](https://www.modelscope.cn/my/myaccesstoken). Ensure that the account associated with the SDK token has edit permissions for the organization corresponding to the model_id. The model pushing process will automatically create a model repository corresponding to the model_id (if it does not already exist), and you can use `--hub_private_repo true` to automatically create a private model repository.

0 commit comments

Comments
 (0)