LLMs之SWIFT:SWIFT的简介、安装和使用方法、案例应用之详细攻略
目录
SWIFT的简介
新闻
🛠️ 安装
🚀 快速开始
Web-UI
训练
训练脚本
支持的训练过程
单卡训练
模型并行训练
数据并行训练
Deepspeed训练
多机多卡
阿里云-DLC多机训练
预训练
人类对齐
推理
评测
量化
部署
支持的模型
大语言模型
多模态大模型
扩散模型
支持的开源数据集
支持的技术
支持的硬件
环境变量
SWIFT的简介
SWIFT支持300+ LLM和80+ MLLM(多模态大模型)的训练(预训练、微调、对齐)、推理、评测和部署。开发者可以直接将我们的框架应用到自己的Research和生产环境中,实现模型训练评测到应用的完整链路。我们除支持了PEFT提供的轻量训练方案外,也提供了一个完整的Adapters库以支持最新的训练技术,如NEFTune、LoRA+、LLaMA-PRO等,这个适配器库可以脱离训练脚本直接使用在自己的自定流程中。
为方便不熟悉深度学习的用户使用,我们提供了一个Gradio的web-ui用于控制训练和推理,并提供了配套的深度学习课程和最佳实践供新手入门。 可以在Huggingface space 和 ModelScope创空间 中体验SWIFT web-ui功能了。
新闻
- 2024.09.07: 支持
Reflection-llama3-70b模型, 使用swift sft/infer --model_type reflection-llama_3_1-70b命令即可训练和推理. - 2024.09.06: 支持mplug-owl3的微调和推理, 最佳实践可以查看这里.
- 2024.09.05: 支持minicpm3-4b模型. 使用
swift infer --model_type minicpm3-4b进行体验. - 2024.09.05: 支持yi-coder系列模型. 使用
swift infer --model_type yi-coder-1_5b-chat进行体验. - 🔥2024.08.30: 支持qwen2-vl系列模型的推理与微调: qwen2-vl-2b-instruct, qwen2-vl-7b-instruct. 最佳实践可以查看这里.
- 🔥2024.08.26: 支持Liger, 该内核支持LLaMA、Qwen、Mistral等模型, 并大幅减少显存使用(10%~60%), 使用
--use_liger true开启训练. - 🔥2024.08.22: 支持ReFT, 该tuner可以以LoRA的1/15~1/65的参数量达到和LoRA匹配或更好的效果, 使用
--sft_type reft开始训练! - 🔥2024.08.21: 支持phi3_5-mini-instruct, phi3_5-moe-instruct, phi3_5-vision-instruct. 使用phi3_5-vision-instruct进行Latex OCR微调的最佳实践可以查看这里.
- 2024.08.21: 支持idefics3-8b-llama3, llava-onevision-qwen2-0_5b-ov, llava-onevision-qwen2-7b-ov, llava-onevision-qwen2-72b-ov.
- 🔥2024.08.20: 支持使用deepspeed-zero3对多模态大模型进行微调.
- 2024.08.20: 支持模型: longwriter-glm4-9b, longwriter-llama3_1-8b. 支持数据集: longwriter-6k.
- 🔥2024.08.12: 🎉 SWIFT论文已经发布到arXiv上,可以点击这个链接阅读.
- 🔥2024.08.12: 支持packing和flash-attention时不污染attention_mask, 使用
--packing开启。详情见PR. - 🔥2024.08.09: 支持qwen2-audio模型的推理与微调. 最佳实践可以查看这里.
- 🔥2024.08.08: 支持qwen2-math系列模型, 1.5B, 7B, 72B. 使用
swift infer --model_type qwen2-math-1_5b-instruct进行体验. - 🔥2024.08.07: 支持使用vllm对多模态大模型: llava系列, internvl2系列, phi3-vision, minicpm-v2.5进行推理加速和部署. 可以查看多模态&vLLM推理加速文档获取更多信息.
- 2024.08.06: 支持minicpm-v-v2_6-chat, 使用
swift infer --model_type minicpm-v-v2_6-chat进行推理体验, 最佳实践可以查看这里. - 2024.08.06: 支持internlm2.5的1.8b和20b系列. 使用
swift infer --model_type internlm2_5-1_8b-chat进行体验. - 🔥2024.08.05: 支持多模态数据集的评测!命令行完全一致,新增了许多多模态数据集.
- 🔥2024.08.02: 支持Fourier Ft训练. 使用方式为
--sft_type fourierft, 参数可以参考这里. - 🔥2024.07.29: 支持使用lmdeploy对LLM和VLM模型进行推理加速. 文档可以查看这里.
- 🔥2024.07.24: 人类偏好对齐算法支持视觉多模态大模型, 包括DPO/ORPO/SimPO/CPO, 训练参考文档. 支持数据集RLAIF-V.
- 🔥2024.07.24: 支持使用megatron对qwen2系列进行CPT和SFT. 可以查看megatron训练文档.
- 🔥2024.07.24: 支持llama3.1系列模型. 包含8b, 70b, 405b. 支持openbuddy-llama3_1-8b-chat.
More
🛠️ 安装
SWIFT在Python环境中运行。请确保您的Python版本高于3.8。
- 方法1:使用pip命令安装SWIFT:
# 全量能力 pip install 'ms-swift[all]' -U # 仅使用LLM pip install 'ms-swift[llm]' -U # 仅使用AIGC pip install 'ms-swift[aigc]' -U # 仅使用Adapters pip install ms-swift -U
- 方法2:通过源代码安装SWIFT(方便运行训练推理脚本),请运行以下命令:
git clone https://github.com/modelscope/swift.git cd swift pip install -e '.[llm]'
SWIFT依赖torch>=1.13,建议torch>=2.0.0。
- 方法3:在我们的Docker镜像中使用SWIFT
🚀 快速开始
本章节介绍基本使用,更丰富的使用方式请查看文档部分。
Web-UI
Web-UI是基于gradio界面技术的零门槛训练部署界面方案。Web-UI配置简单,且完美支持多卡训练和部署:
swift web-ui

训练
训练脚本
你可以参考以下脚本来自定义属于你的训练脚本.
- full: qwen1half-7b-chat (A100), qwen-7b-chat (2*A100)
- full+ddp+zero2: qwen-7b-chat (4*A100)
- full+ddp+zero3: qwen-14b-chat (4*A100)
- lora: chatglm3-6b (3090), baichuan2-13b-chat (2*3090), yi-34b-chat (A100), qwen-72b-chat (2*A100)
- lora+ddp: chatglm3-6b (2*3090)
- lora+ddp+zero3: qwen-14b-chat (4*3090), qwen-72b-chat (4*A100)
- qlora(gptq-int4): qwen-14b-chat-int4 (3090), qwen1half-72b-chat-int4 (A100)
- qlora(gptq-int8): qwen-14b-chat-int8 (3090)
- qlora(bnb-int4): qwen-14b-chat (3090), llama2-70b-chat (2 * 3090)
支持的训练过程
| 训练过程 | 训练方式 |
|---|---|
| 预训练 | 文本生成 |
| 微调 | 单轮/多轮 Agent训练/自我认知 多模态视觉/多模态语音 |
| 人类对齐 | DPO ORPO SimPO KTO CPO |
| 文生图 | DreamBooth等 |
| 文生视频 | - |
单卡训练
通过如下命令启动单卡微调:
LoRA:
# 实验环境: A100
# 显存需求: 20GB
# 运行时长: 3.1小时
CUDA_VISIBLE_DEVICES=0 \
swift sft \
--model_type qwen1half-7b-chat \
--dataset blossom-math-zh \
--num_train_epochs 5 \
--sft_type lora \
--output_dir output \
全参数:
# 实验环境: A100
# 显存需求: 80GB
# 运行时长: 2.5小时
CUDA_VISIBLE_DEVICES=0 \
swift sft \
--model_type qwen1half-7b-chat \
--dataset blossom-math-zh \
--num_train_epochs 5 \
--sft_type full \
--output_dir output \
--eval_steps 500 \
模型并行训练
# 实验环境: 2 * A100
# 显存需求: 10GB + 13GB
# 运行时长: 3.4小时
CUDA_VISIBLE_DEVICES=0,1 \
swift sft \
--model_type qwen1half-7b-chat \
--dataset blossom-math-zh \
--num_train_epochs 5 \
--sft_type lora \
--output_dir output \
数据并行训练
# 实验环境: 4 * A100
# 显存需求: 4 * 30GB
# 运行时长: 0.8小时
NPROC_PER_NODE=4 \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
swift sft \
--model_type qwen1half-7b-chat \
--dataset blossom-math-zh \
--num_train_epochs 5 \
--sft_type lora \
--output_dir output \
模型并行与数据并行结合:
# 实验环境: 4 * A100
# 显存需求: 2*14GB + 2*18GB
# 运行时长: 1.7小时
NPROC_PER_NODE=2 \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
swift sft \
--model_type qwen1half-7b-chat \
--dataset blossom-math-zh \
--num_train_epochs 5 \
--sft_type lora \
--output_dir output \
Deepspeed训练
Deepspeed支持对GPTQ和AWQ量化模型进行训练.
ZeRO2:
# 实验环境: 4 * A100
# 显存需求: 4 * 21GB
# 运行时长: 0.9小时
NPROC_PER_NODE=4 \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
swift sft \
--model_type qwen1half-7b-chat \
--dataset blossom-math-zh \
--num_train_epochs 5 \
--sft_type lora \
--output_dir output \
--deepspeed default-zero2 \
ZeRO3:
# 实验环境: 4 * A100
# 显存需求: 4 * 19GB
# 运行时长: 3.2小时
NPROC_PER_NODE=4 \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
swift sft \
--model_type qwen1half-7b-chat \
--dataset blossom-math-zh \
--num_train_epochs 5 \
--sft_type lora \
--output_dir output \
--deepspeed default-zero3 \
ZeRO3-Offload:
# 实验环境: 4 * A100
# 显存需求: 4 * 12GB
# 运行时长: 60小时
NPROC_PER_NODE=4 \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
swift sft \
--model_id_or_path AI-ModelScope/WizardLM-2-8x22B \
--dataset blossom-math-zh \
--num_train_epochs 5 \
--sft_type lora \
--output_dir output \
--deepspeed zero3-offload \
多机多卡
# 如果非共用磁盘请在各机器sh中额外指定`--save_on_each_node true`.
# node0
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
NNODES=2 \
NODE_RANK=0 \
MASTER_ADDR=127.0.0.1 \
NPROC_PER_NODE=8 \
swift sft \
--model_type qwen1half-32b-chat \
--sft_type full \
--dataset blossom-math-zh \
--output_dir output \
--deepspeed default-zero3 \
# node1
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
NNODES=2 \
NODE_RANK=1 \
MASTER_ADDR=xxx.xxx.xxx.xxx \
NPROC_PER_NODE=8 \
swift sft \
--model_type qwen1half-32b-chat \
--sft_type full \
--dataset blossom-math-zh \
--output_dir output \
--deepspeed default-zero3 \
阿里云-DLC多机训练
DLC环境变量中,WORLD_SIZE指代node数量,RANK指代node序号,这一点和torchrun定义不同,需要注意。
NNODES=$WORLD_SIZE \
NODE_RANK=$RANK \
swift sft \
--model_type qwen1half-32b-chat \
--sft_type full \
--dataset blossom-math-zh \
--output_dir output \
--deepspeed default-zero3
预训练
NPROC_PER_NODE=4 \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
swift pt \
--model_type qwen1half-7b \
--dataset chinese-c4#100000 \
--num_train_epochs 1 \
--sft_type full \
--deepspeed default-zero3 \
--output_dir output \
--lazy_tokenize true
人类对齐
# We support rlhf_type dpo/cpo/simpo/orpo/kto
CUDA_VISIBLE_DEVICES=0 \
swift rlhf \
--rlhf_type dpo \
--model_type qwen1half-7b-chat \
--dataset shareai-llama3-dpo-zh-en-emoji \
--num_train_epochs 5 \
--sft_type lora \
--output_dir output \
推理
原始模型:
CUDA_VISIBLE_DEVICES=0 swift infer --model_type qwen1half-7b-chat
# 使用VLLM加速
CUDA_VISIBLE_DEVICES=0 swift infer --model_type qwen1half-7b-chat \
--infer_backend vllm --max_model_len 8192
LoRA微调后:
CUDA_VISIBLE_DEVICES=0 swift infer --ckpt_dir xxx/checkpoint-xxx --load_dataset_config true
# 使用VLLM加速
CUDA_VISIBLE_DEVICES=0 swift infer \
--ckpt_dir xxx/checkpoint-xxx --load_dataset_config true \
--merge_lora true --infer_backend vllm --max_model_len 8192
评测
原始模型:
CUDA_VISIBLE_DEVICES=0 swift eval --model_type qwen1half-7b-chat \
--eval_dataset ARC_c --infer_backend vllm
LoRA微调后:
CUDA_VISIBLE_DEVICES=0 swift eval --ckpt_dir xxx/checkpoint-xxx \
--eval_dataset ARC_c --infer_backend vllm \
--merge_lora true \
量化
原始模型:
CUDA_VISIBLE_DEVICES=0 swift export --model_type qwen1half-7b-chat \
--quant_bits 4 --quant_method awq
LoRA微调后:
CUDA_VISIBLE_DEVICES=0 swift export \
--ckpt_dir xxx/checkpoint-xxx --load_dataset_config true \
--quant_method awq --quant_bits 4 \
--merge_lora true \
部署
客户端使用OpenAI API进行调用,具体可以查看LLM部署文档
原始模型:
CUDA_VISIBLE_DEVICES=0 swift deploy --model_type qwen1half-7b-chat
# 使用VLLM加速
CUDA_VISIBLE_DEVICES=0 swift deploy --model_type qwen1half-7b-chat \
--infer_backend vllm --max_model_len 8192
LoRA微调后:
CUDA_VISIBLE_DEVICES=0 swift deploy --ckpt_dir xxx/checkpoint-xxx
# 使用VLLM加速
CUDA_VISIBLE_DEVICES=0 swift deploy \
--ckpt_dir xxx/checkpoint-xxx --merge_lora true \
--infer_backend vllm --max_model_len 8192
支持的模型
完整的支持模型和数据集可以查看支持的模型和数据集列表.
大语言模型
| 模型类型 | 模型介绍 | 语言 | 模型大小 | 模型类型 |
|---|---|---|---|---|
| Qwen Qwen1.5 Qwen2 | 通义千问1.0和1.5系列模型 | 中文 英文 | 0.5B-110B 包含量化版本 | base模型 chat模型 MoE模型 代码模型 |
| ChatGLM2 ChatGLM3 Codegeex2 GLM4 Codegeex4 | 智谱ChatGLM系列模型 | 中文 英文 | 6B-9B | base模型 chat模型 代码模型 长文本模型 |
| Baichuan Baichuan2 | 百川1和百川2 | 中文 英文 | 7B-13B 包含量化版本 | base模型 chat模型 |
| Yuan2 | 浪潮源系列模型 | 中文 英文 | 2B-102B | instruct模型 |
| XVerse | 元象系列模型 | 中文 英文 | 7B-65B | base模型 chat模型 长文本模型 MoE模型 |
| LLaMA2 | LLaMA2系列模型 | 英文 | 7B-70B 包含量化版本 | base模型 chat模型 |
| LLaMA3 LLaMA3.1 | LLaMA3系列模型 | 英文 | 8B-70B 包含量化版本 | |
| Mistral Mixtral | Mistral系列模型 | 英文 | 7B-8x22B | base模型 instruct模型 MoE模型 |
| Yi Yi1.5 Yi-Coder | 01AI的YI系列模型 | 中文 英文 | 1.5B-34B 包含量化版本 | base模型 chat模型 长文本模型 |
| InternLM InternLM2 InternLM2-Math InternLM2.5 | 浦江实验室书生浦语系列模型 | 中文 英文 | 1.8B-20B | base模型 chat模型 数学模型 |
| DeepSeek DeepSeek-MoE DeepSeek-Coder DeepSeek-Math DeepSeek-V2 DeepSeek-Coder-V2 | 幻方系列模型 | 中文 英文 | 1.3B-236B | base模型 chat模型 MoE模型 代码模型 数学模型 |
| MAMBA | MAMBA时序卷积模型 | 英文 | 130M-2.8B | base模型 |
| Gemma Gemma2 | Google Gemma系列模型 | 英文 | 2B-27B | base模型 instruct模型 |
| MiniCPM MiniCPM3 | OpenBmB MiniCPM系列模型 | 中文 英文 | 2B-3B | chat模型 MoE模型 |
| OpenBuddy | OpenBuddy系列模型 | 中文 英文 | 7B-70B | base模型 chat模型 |
| Orion | 猎户星空系列模型 | 中文 英文 | 14B | base模型 chat模型 |
| BlueLM | VIVO蓝心大模型 | 中文 英文 | 7B | base模型 chat模型 |
| Ziya2 | 封神榜系列模型 | 中文 英文 | 13B | base模型 chat模型 |
| Skywork | 昆仑天工系列模型 | 中文 英文 | 13B | base模型 chat模型 |
| Zephyr | 基于Mistral的zephyr系列模型 | 英文 | 7B | chat模型 |
| PolyLM | 通义实验室自研的PolyLM系列模型 | 多语种 | 13B | base模型 |
| SeqGPT | 通义实验室自研的文本理解模型,用于信息抽取和文本分类 | 中文 | 560M | 语义理解模型 |
| SUS | 南方科技大学基于YI Fine-Tune的模型 | 中文 英文 | 34B | chat模型 |
| Tongyi-Finance | 通义金融系列模型 | 中文 英文 | 14B | base模型 chat模型 金融模型 |
| CodeFuse-CodeLLaMA CodeFuse-Codegeex2 CodeFuse-Qwen | 蚂蚁CodeFuse系列模型 | 中文 英文 | 6B-34B | chat模型 代码模型 |
| phi2/phi3 | 微软PHI2模型 | 英文 | 3B/4B | base模型 指令模型 代码模型 |
| Grok | X-ai | 英文 | 300B | base模型 |
| TeleChat | Tele-AI | 中文 英文 | 7B-12B | chat模型 |
| dbrx | databricks | 英文 | 132B | base模型 chat模型 |
| mengzi3 | Langboat | 中文 英文 | 13B | base模型 |
| c4ai-command-r | c4ai | 多语种 | 35B-104B | chat模型 |
| WizardLM2 | WizardLM2系列模型 | 多语种 | 7B-8x22B 包含量化版本 | chat模型 MoE模型 |
| Atom | Atom | 中文 | 7B | base模型 chat模型 |
| Chinese-LLaMA-Alpaca-2 | Chinese-LLaMA-Alpaca-2 | 中文 | 1.3B-13B | base模型 chat模型 长文本模型 |
| Chinese-LLaMA-Alpaca-3 | Chinese-LLaMA-Alpaca-3 | 中文 | 8B | base模型 chat模型 |
| ModelScope-Agent | ModelScope Agent系列 | 中文 | 7B-14B | agent模型 |
| Numina | AI-MO | 英文 | 7B | 数学模型 |
多模态大模型
| 模型类型 | 模型介绍 | 语言 | 模型大小 | 模型类型 |
|---|---|---|---|---|
| Qwen-VL Qwen2-VL | 通义千问视觉模型 | 中文 英文 | 7B 包含量化版本 | base模型 chat模型 |
| Qwen-Audio Qwen2-Audio | 通义千问语音模型 | 中文 英文 | 7B | base模型 chat模型 |
| YI-VL | 01AI的YI系列视觉模型 | 中文 英文 | 6B-34B | chat模型 |
| XComposer2 XComposer2.5 | 浦江实验室书生浦语视觉模型 | 中文 英文 | 7B | chat模型 |
| DeepSeek-VL | 幻方系列视觉模型 | 中文 英文 | 1.3B-7B | chat模型 |
| MiniCPM-V MiniCPM-V-2 MiniCPM-V-2.5 MiniCPM-V-2.6 | OpenBmB MiniCPM视觉模型 | 中文 英文 | 3B-9B | chat模型 |
| CogVLM CogAgent CogVLM2 CogVLM2-Video GLM4V | 智谱ChatGLM视觉问答和Agent模型 | 中文 英文 | 9B-19B | chat模型 |
| Llava-HF | Llava-HF系列模型 | 英文 | 0.5B-110B | chat模型 |
| Llava1.5 Llava1.6 | Llava系列模型 | 英文 | 7B-34B | chat模型 |
| Llava-Next Llava-Next-Video | Llava-Next系列模型 | 中文 英文 | 7B-110B | chat模型 |
| mPLUG-Owl2 mPLUG-Owl2.1 mPLUG-Owl3 | mPLUG-Owl系列模型 | 英文 | 11B | chat模型 |
| InternVL Mini-InternVL InternVL2 | InternVL | 中文 英文 | 1B-40B 包含量化版本 | chat模型 |
| Llava-llama3 | xtuner | 英文 | 8B | chat模型 |
| Phi3-Vision | 微软 | 英文 | 4B | chat模型 |
| PaliGemma | 英文 | 3B | chat模型 | |
| Florence | 微软 | 英文 | 0.23B-0.77B | chat模型 |
| Idefics3 | HuggingFaceM4 | 英文 | 8B | chat模型 |
扩散模型
| 模型类型 | 模型介绍 | 语言 | 模型类型 |
|---|---|---|---|
| AnimateDiff | AnimateDiff动画模型 | 英文 | 文生视频 |
| SD1.5/SD2.0/SDXL | StabilityAI系列扩散模型 | 英文 | 文生图 |
支持的开源数据集
| 数据集类型 | 训练任务 | 文档 |
|---|---|---|
| 通用 | 微调 | 🔥ruozhiba, 🔥ms-bench, 🔥alpaca-en(gpt4), 🔥alpaca-zh(gpt4), multi-alpaca, instinwild, cot-en, cot-zh, firefly-zh, instruct-en, gpt4all-en, sharegpt, tulu-v2-sft-mixture, wikipedia-zh, open-orca, sharegpt-gpt4, deepctrl-sft, coig-cqia. |
| Agent | 微调 | 🔥ms-agent, 🔥ms-agent-for-agentfabric, ms-agent-multirole, 🔥toolbench-for-alpha-umi, damo-agent-zh, damo-agent-zh-mini, agent-instruct-all-en. |
| 通用 | 人类对齐 | hh-rlhf, 🔥hh-rlhf-cn, stack-exchange-paired. |
| 代码 | 微调 | code-alpaca-en, 🔥leetcode-python-en, 🔥codefuse-python-en, 🔥codefuse-evol-instruction-zh. |
| 医疗 | 微调 | medical-en, medical-zh, 🔥disc-med-sft-zh. |
| 法律 | 微调 | lawyer-llama-zh, tigerbot-law-zh, 🔥disc-law-sft-zh. |
| 数学 | 微调 | 🔥blossom-math-zh, school-math-zh, open-platypus-en. |
| SQL | 微调 | text2sql-en, 🔥sql-create-context-en. |
| 文本生成 | 微调 | 🔥advertise-gen-zh, 🔥dureader-robust-zh. |
| 分类 | 微调 | cmnli-zh, 🔥jd-sentiment-zh, 🔥hc3-zh, 🔥hc3-en. |
| 量化辅助 | 量化 | pileval. |
| 其他 | 微调 | finance-en, poetry-zh, webnovel-zh, generated-chat-zh, cls-fudan-news-zh, ner-jave-zh. |
| 视觉 | 微调 | coco-en, 🔥coco-en-mini, coco-en-2, coco-en-2-mini, capcha-images. |
| 音频 | 微调 | aishell1-zh, 🔥aishell1-zh-mini. |
支持的技术
| 技术名称 |
|---|
| 🔥LoRA: LORA: LOW-RANK ADAPTATION OF LARGE LANGUAGE MODELS |
| 🔥LoRA+: LoRA+: Efficient Low Rank Adaptation of Large Models |
| 🔥LLaMA PRO: LLAMA PRO: Progressive LLaMA with Block Expansion |
| 🔥GaLore:GaLore: Memory-Efficient LLM Training by Gradient Low-Rank Projection |
| 🔥LISA: LISA: Layerwise Importance Sampling for Memory-Efficient Large Language Model Fine-Tuning |
| 🔥UnSloth: GitHub - unslothai/unsloth: Finetune Llama 3.1, Mistral, Phi & Gemma LLMs 2-5x faster with 80% less memory |
| 🔥SCEdit: SCEdit: Efficient and Controllable Image Diffusion Generation via Skip Connection Editing < arXiv \ |
| 🔥NEFTune: Noisy Embeddings Improve Instruction Finetuning |
| LongLoRA: Efficient Fine-tuning of Long-Context Large Language Models |
| Adapter: Parameter-Efficient Transfer Learning for NLP |
| Vision Prompt Tuning: Visual Prompt Tuning |
| Side: Side-Tuning: A Baseline for Network Adaptation via Additive Side Networks |
| Res-Tuning: Res-Tuning: A Flexible and Efficient Tuning Paradigm via Unbinding Tuner from Backbone < arXiv \ |
| PEFT提供的tuners, 如IA3, AdaLoRA等 |
支持的硬件
| 硬件环境 | 备注 |
|---|---|
| CPU | |
| RTX20系列/30系列/40系列等 | 30序列之后可使用BF16和FlashAttn |
| 计算卡系列 T4/V100等 | 不支持BF16和FlashAttn |
| 计算卡系列 A10/A100等 | 支持BF16和FlashAttn |
| 华为昇腾NPU |
环境变量
- DATASET_ENABLE_CACHE:在预处理数据集时启用缓存,您可以使用
1/True或0/False,默认值为False - WEBUI_SHARE:共享web-ui,可以使用
1/True或0/False,默认值为False - SWIFT_UI_LANG:web-ui语言,您可以使用
en或zh,默认值为zh - WEBUI_SERVER:web-ui可访问的IP
0.0.0.0表示所有路由,127.0.0.1仅用于本地网络。默认值为127.0.0.1 - WEBUI_PORT:web-ui端口
- USE_HF:使用huggingface endpoint或ModelScope endpoint下载模型和数据集。您可以使用
1/True或0/False,默认值为False - FORCE_REDOWNLOAD:强制重新下载数据集
其他变量如CUDA_VISIBLE_DEVICES也支持,但未在此列出。


















