Skip to content

Commit e5bad03

Browse files
committed
Merge branch 'main' into release/2.4
2 parents 0297c67 + 38b32da commit e5bad03

File tree

121 files changed

+1801
-1271
lines changed

Some content is hidden

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

121 files changed

+1801
-1271
lines changed

README.md

Lines changed: 21 additions & 17 deletions
Large diffs are not rendered by default.

README_CN.md

Lines changed: 21 additions & 17 deletions
Large diffs are not rendered by default.

asset/wechat.png

-47.4 KB
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
# 推送模型
3+
4+
使用SWIFT时,用户可以选择将训练好的模型推送到魔搭社区上。
5+
6+
要使用推送模型能力,首先要确认你已经注册了魔搭官方账号,并且在[页面](https://www.modelscope.cn/my/myaccesstoken)上取得了对应的sdk token。
7+
8+
## 训练时推送模型
9+
10+
在训练时推送模型,需要在命令行上添加以下参数:
11+
```shell
12+
--push_to_hub true \
13+
--hub_model_id my-group/my-model \
14+
--hub_token <token-from-modelscope-page>
15+
```
16+
17+
上述参数添加好后,训练后的checkpoint和训练参数就会被推送到魔搭社区上,方便以后使用。值得注意的是,魔搭社区允许您上传私有模型,需要模型是私有时,添加以下参数:
18+
19+
```shell
20+
--hub_private_repo true
21+
```
22+
23+
这样该模型就只有有该组织权限的人才能看到。
24+
25+
## 导出时推送模型
26+
27+
导出时推送模型的参数和训练时的参数是相同的:
28+
```shell
29+
CUDA_VISIBLE_DEVICES=0 swift export \
30+
--ckpt_dir output/qwen1half-4b-chat/vx-xxx/checkpoint-xxx \
31+
--push_to_hub true \
32+
--hub_model_id qwen1half-4b-chat-lora \
33+
--hub_token '<your-sdk-token>'
34+
```
35+
36+
这样可以将LoRA合并或量化后的模型直接推送到魔搭上。

docs/source/GetStarted/界面训练推理.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ web-ui可以通过环境变量或者参数控制UI行为。环境变量如下:
2020
>
2121
> USE_INFERENCE=1/0 默认0. 控制gradio的推理页面是直接加载模型推理或者部署(USE_INFERENCE=0)
2222
23-
如果使用参数,请参考[命令行参数](../LLM/命令行参数.md#web-ui-参数)
23+
如果使用参数,请参考[命令行参数](../Instruction/命令行参数.md#web-ui-参数)
File renamed without changes.

docs/source/LLM/LLM微调文档.md renamed to docs/source/Instruction/LLM微调文档.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pip install -e '.[llm]'
2424
pip install deepspeed -U
2525

2626
# 如果你想要使用基于auto_gptq的qlora训练. (推荐, 效果优于bnb)
27-
# 支持auto_gptq的模型: `https://github.com/modelscope/swift/blob/main/docs/source/LLM/支持的模型和数据集.md#模型`
27+
# 支持auto_gptq的模型: `https://github.com/modelscope/swift/blob/main/docs/source/Instruction/支持的模型和数据集.md#模型`
2828
# auto_gptq和cuda版本有对应关系,请按照`https://github.com/PanQiWei/AutoGPTQ#quick-installation`选择版本
2929
pip install auto_gptq -U
3030

@@ -37,7 +37,7 @@ pip install -r requirements/llm.txt -U
3737
```
3838

3939
## 微调
40-
如果你要使用界面的方式进行微调与推理, 可以查看[界面训练与推理文档](../GetStarted/%E7%95%8C%E9%9D%A2%E8%AE%AD%E7%BB%83%E6%8E%A8%E7%90%86.md).
40+
如果你要使用界面的方式进行微调与推理, 可以查看[界面训练与推理文档](../GetStarted/界面训练推理.md).
4141

4242
### 使用python
4343
```python
@@ -83,7 +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
86+
# 自定义数据集格式查看: https://github.com/modelscope/swift/blob/main/docs/source/Instruction/%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
8787
CUDA_VISIBLE_DEVICES=0 swift sft \
8888
--model_id_or_path qwen/Qwen-7B-Chat \
8989
--dataset chatml.jsonl \
@@ -139,7 +139,7 @@ cd examples/pytorch/llm
139139
- 如果你想要使用基于**auto_gptq**的量化, 你需要先安装对应cuda版本的[auto_gptq](https://github.com/PanQiWei/AutoGPTQ): `pip install auto_gptq -U`.
140140
> 使用auto_gptq的模型可以查看[LLM支持的模型](支持的模型和数据集.md#模型). 建议使用auto_gptq, 而不是bnb.
141141
- 如果你想要使用deepspeed, 你需要`pip install deepspeed -U`. 使用deepspeed可以**节约显存**, 但可能会略微降低训练速度.
142-
- 如果你的训练涉及到**知识编辑**的内容, 例如: [自我认知微调](自我认知微调最佳实践.md), 你需要在MLP上也加上LoRA, 否则可能会效果不佳. 你可以简单传入参数`--lora_target_modules ALL`来对所有的linear(qkvo, mlp)加上lora, **这通常是效果最好的**.
142+
- 如果你的训练涉及到**知识编辑**的内容, 例如: [自我认知微调](../LLM/自我认知微调最佳实践.md), 你需要在MLP上也加上LoRA, 否则可能会效果不佳. 你可以简单传入参数`--lora_target_modules ALL`来对所有的linear(qkvo, mlp)加上lora, **这通常是效果最好的**.
143143
- 如果你使用的是**V100**等较老的GPU, 你需要设置`--dtype AUTO`或者`--dtype fp16`, 因为其不支持bf16.
144144
- 如果你的机器是A100等高性能显卡, 且模型支持flash-attn, 推荐你安装[**flash-attn**](https://github.com/Dao-AILab/flash-attention), 这将会加快训练和推理的速度以及显存占用(A10, 3090, V100等显卡不支持flash-attn进行训练). 支持flash-attn的模型可以查看[LLM支持的模型](支持的模型和数据集.md#模型)
145145
- 如果你要进行**二次预训练**, **多轮对话**, 你可以参考[自定义与拓展](自定义与拓展.md#注册数据集的方式)
@@ -168,10 +168,10 @@ cd examples/pytorch/llm
168168

169169

170170
## DPO
171-
如果你要使用DPO进行人类对齐, 你可以查看[DPO训练文档](DPO训练文档.md).
171+
如果你要使用DPO进行人类对齐, 你可以查看[DPO训练文档](../LLM/DPO训练文档.md).
172172

173173
## ORPO
174-
如果你要使用ORPO进行人类对齐, 你可以查看[ORPO最佳实践](ORPO算法最佳实践.md).
174+
如果你要使用ORPO进行人类对齐, 你可以查看[ORPO最佳实践](../LLM/ORPO算法最佳实践.md).
175175

176176
## Merge LoRA
177177
提示: **暂时**不支持bnb和auto_gptq量化模型的merge lora, 这会产生较大的精度损失.
@@ -186,7 +186,7 @@ CUDA_VISIBLE_DEVICES=0 swift export \
186186
对微调后模型进行量化可以查看[LLM量化与导出文档](LLM量化与导出文档.md#微调后模型)
187187

188188
## 推理
189-
如果你要使用VLLM进行推理加速, 可以查看[VLLM推理加速与部署](VLLM推理加速与部署.md#微调后的模型)
189+
如果你要使用VLLM进行推理加速, 可以查看[VLLM推理加速与部署](../LLM/VLLM推理加速与部署.md#微调后的模型)
190190

191191
### 原始模型
192192
**单样本推理**可以查看[LLM推理文档](LLM推理文档.md#推理)
@@ -279,7 +279,7 @@ CUDA_VISIBLE_DEVICES=0 swift infer --ckpt_dir 'xxx/vx-xxx/checkpoint-xxx-merged'
279279
```
280280

281281
## Web-UI
282-
如果你要使用VLLM进行部署并提供**API**接口, 可以查看[VLLM推理加速与部署](VLLM推理加速与部署.md#部署)
282+
如果你要使用VLLM进行部署并提供**API**接口, 可以查看[VLLM推理加速与部署](../LLM/VLLM推理加速与部署.md#部署)
283283

284284
### 原始模型
285285
使用原始模型的web-ui可以查看[LLM推理文档](LLM推理文档.md#Web-UI)

docs/source/LLM/LLM推理文档.md renamed to docs/source/Instruction/LLM推理文档.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# LLM推理文档
2-
如果你要使用vllm进行推理加速, 可以查看[VLLM推理加速与部署](VLLM推理加速与部署.md#推理加速)
2+
如果你要使用vllm进行推理加速, 可以查看[VLLM推理加速与部署](../LLM/VLLM推理加速与部署.md#推理加速)
33

44
## 目录
55
- [环境准备](#环境准备)
@@ -15,7 +15,7 @@ pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
1515
pip install 'ms-swift[llm]' -U
1616

1717
# 如果你想要使用基于auto_gptq的模型进行推理.
18-
# 使用auto_gptq的模型: `https://github.com/modelscope/swift/blob/main/docs/source/LLM/支持的模型和数据集.md#模型`
18+
# 使用auto_gptq的模型: `https://github.com/modelscope/swift/blob/main/docs/source/Instruction/支持的模型和数据集.md#模型`
1919
# auto_gptq和cuda版本有对应关系,请按照`https://github.com/PanQiWei/AutoGPTQ#quick-installation`选择版本
2020
pip install auto_gptq -U
2121

docs/source/LLM/LLM评测文档.md renamed to docs/source/Instruction/LLM评测文档.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ pip install -e '.[eval]'
6969
```shell
7070
# 原始模型 (单卡A100大约需要半小时)
7171
CUDA_VISIBLE_DEVCIES=0 swift eval --model_type qwen2-7b-instruct \
72-
--eval_dataset ARC_e --infer_backend vllm
72+
--eval_dataset ARC_c --infer_backend vllm
7373

7474
# LoRA微调后
7575
CUDA_VISIBLE_DEVICES=0 swift eval --ckpt_dir qwen2-7b-instruct/vx-xxx/checkpoint-xxx \
76-
--eval_dataset ARC_e --infer_backend vllm \
76+
--eval_dataset ARC_c --infer_backend vllm \
7777
--merge_lora true \
7878
```
7979

80-
评测的参数列表可以参考[这里](./命令行参数.md#eval参数)
80+
评测的参数列表可以参考[这里](命令行参数.md#eval参数)
8181

8282
请注意:评测结果会存储在{--eval_output_dir}/{--name}/{时间戳}下, 如果用户没有改变存储配置,则默认路径在:
8383
```text
@@ -93,7 +93,7 @@ CUDA_VISIBLE_DEVICES=0 swift deploy --model_type qwen2-7b-instruct
9393

9494
# 使用API进行评测
9595
# 如果是非swift部署, 则需要额外传入`--eval_is_chat_model true --model_type qwen2-7b-instruct`
96-
swift eval --eval_url http://127.0.0.1:8000/v1 --eval_dataset ARC_e
96+
swift eval --eval_url http://127.0.0.1:8000/v1 --eval_dataset ARC_c
9797

9898
# LoRA微调后的模型同理
9999
```
File renamed without changes.

0 commit comments

Comments
 (0)