yuccaaa commited on
Commit
0e64043
·
verified ·
1 Parent(s): c4b3fac

Upload ms-swift/docs/source/Instruction/导出与推送.md with huggingface_hub

Browse files
ms-swift/docs/source/Instruction/导出与推送.md ADDED
@@ -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`来自动创建私有的模型仓库。