1 Star 0 Fork 0

RexHuang936 / swift

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

SWIFT (Scalable lightWeight Infrastructure for Fine-Tuning)



魔搭社区官网
中文&nbsp | &nbspEnglish&nbsp

📖 目录

📝 简介

SWIFT支持近200种LLM和MLLM(多模态大模型)的训练、推理、评测和部署。开发者可以直接将我们的框架应用到自己的Research和生产环境中,实现模型训练评测到应用的完整链路。我们除支持了PEFT提供的轻量训练方案外,也提供了一个完整的Adapters库以支持最新的训练技术,如NEFTune、LoRA+、LLaMA-PRO等,这个适配器库可以脱离训练脚本直接使用在自己的自定流程中。

为方便不熟悉深度学习的用户使用,我们提供了一个Gradio的web-ui用于控制训练和推理,并提供了配套的深度学习课程和最佳实践供新手入门。

此外,我们也在拓展其他模态的能力,目前我们支持了AnimateDiff的全参数训练和LoRA训练。

🎉 新闻

  • 🔥2024.04.26: 支持LISAunsloth训练!指定 --lisa_activated_layers=2 来开启LISA(显存使用降低至全参训练的30%),指定 --tuner_backend unsloth 来使用unsloth,用更少的显存(30%或更少)更快的速度(5x)训练一个超大模型!
  • 🔥2024.04.26: 支持Qwen1.5-110B和Qwen1.5-110B-Chat模型的推理与微调, 使用这个脚本来开始训练!
  • 2024.04.24: 支持Phi3系列模型的推理与微调. 包括: phi3-4b-4k-instruct, phi3-4b-128k-instruct.
  • 2024.04.22: 支持chinese-llama-alpaca-2系列模型的推理与微调和部署等. 包括:chinese-llama-2-1.3b, chinese-llama-2-7b, chinese-llama-2-13b, chinese-alpaca-2-1.3b, chinese-alpaca-2-7b和chinese-alpaca-2-13b以及对应的16k和64k长文本模型.
  • 2024.04.22: 支持Llama3 GPTQ-Int4, GPTQ-Int8, AWQ系列模型的推理与微调. 支持chatglm3-6b-128k, Openbuddy-llama3的推理与微调.
  • 2024.04.20: 支持Atom系列模型的推理, 微调和部署等. 包括: Atom-7B and Atom-7B-Chat. 使用这个脚本来开始训练!
  • 2024.04.19: 支持NPU的单卡、DDP、ZeRO2和ZeRO3的训练与推理, 可以查看NPU推理与微调最佳实践.
  • 2024.04.19: 支持Llama3系列模型的推理, 微调和部署等. 包括: Llama-3-8B, Llama-3-8B-Instruct, Llama-3-70B, Llama-3-70B-Instruct. 使用这个脚本开始训练叭!
  • 2024.04.18: 支持模型: wizardlm2-7b-awq, wizardlm2-8x22b, yi-6b-chat-awq, yi-6b-chat-int8, yi-34b-chat-awq, yi-34b-chat-int8. 支持--deepspeed zero3-offload, 提供了默认zero3-offload配置文件来使用zero3+cpu offload.
  • 2024.04.18: 支持使用环境变量USE_HF兼容HuggingFace生态, 切换成使用HF中的模型和数据集, 可以查看HuggingFace生态兼容文档.
  • 2024.04.17: 支持OpenAI样式的接口评测, 可以查看评测参数接口文档来查看使用方法.
  • 🔥2024.04.17: 支持 CodeQwen1.5-7B系列: CodeQwen1.5-7B, CodeQwen1.5-7B-Chat, CodeQwen1.5-7B-Chat-AWQ, 使用这个脚本来开始训练!
  • 2024.04.16: 支持llava-v1.6-34b的推理与微调, 最佳实践可以查看这里.
  • 2024.04.13: 支持Mixtral-8x22B-v0.1模型的推理与微调, 使用这个脚本来开始训练!
  • 2024.04.13: 支持新推出的MiniCPM系列: MiniCPM-V-2.0、MiniCPM-2B-128k、MiniCPM-MoE-8x2B和MiniCPM-1B。使用这个脚本来开始训练!
  • 🔥2024.04.11: 支持一键式模型评测能力! 首批数据集包含MMLU、CEval、ARC等,也支持用户自定义数据集,具体可以这个文档。同时, 我们支持了一个比较trick的方法来做多个消融实验的管理,查看这个文档来使用。
  • 🔥2024.04.11: 支持c4ai-command-r系列: c4ai-command-r-plus, c4ai-command-r-v01。使用这个脚本来开始训练!
  • 2024.04.10: 使用swift微调qwen-7b-chat模型增强模型function call能力,并结合Modelscope-Agent使用,最佳实践可以查看这里
  • 🔥2024.04.09: 支持弱智吧系列数据集. 在支持的模型和数据集文档中搜索ruozhiba来找到数据集并开始训练!
  • 2024.04.08: 支持XVERSE-MoE-A4.2B模型的推理与微调, 使用这个脚本来开始训练!
  • 2024.04.04: 支持使用QLoRA+FSDP来使用两张24G显卡训练70B模型, 使用这个脚本开始训练.
  • 🔥2024.04.03: 支持Qwen1.5-32B系列: Qwen1.5-32B, Qwen1.5-32B-Chat, Qwen1.5-32B-Chat-GPTQ-Int4。使用这个脚本来开始训练!
  • 🔥2024.04.02: 支持Mengzi3-13B-Base模型的推理与微调, 使用这个脚本来开始训练!
  • 🔥2024.04.01: 支持dbrx系列, dbrx-base和dbrx-instruct, 使用这个脚本来开始训练!.
  • 🔥2024.03.29: 支持Qwen1.5-MoE系列: Qwen1.5-MoE-A2.7B, Qwen1.5-MoE-A2.7B-Chat, Qwen1.5-MoE-A2.7B-Chat-GPTQ-Int4.
  • 🔥2024.03.29: 支持Grok-1 300B MoE模型的推理与微调, 最佳实践可以查看这里.
  • 🔥2024.03.25: 支持TeleChat-7b和TeleChat-12b模型的训练和推理, 使用这个脚本来开始训练!.
  • 🔥2024.03.20: 支持llava系列的推理与微调, 最佳实践可以查看这里.
更多
  • 🔥2024.03.12: 支持deepseek-vl系列推理和微调, 最佳实践可以查看这里.
  • 🔥2024.03.11: 支持GaLore, 用于在全参数训练中有效减小显存占用至原来的1/2.
  • 🔥2024.03.10: Qwen1.5-7B-Chat与Qwen1.5-72B-Chat从微调到部署全流程最佳实践.
  • 🔥2024.03.09: 支持MAMBA模型的训练和推理, 使用这个脚本来开始训练!.
  • 2024.03.09: 支持AQLM量化模型的训练和推理, 使用这个脚本开始训练!
  • 2024.03.06: 支持AWQ量化模型的训练和推理, 使用这个Qwen1.5-AWQ模型脚本开始训练, 并支持yi-9b的训练和推理.
  • 🔥2024.02.29: 支持LLaMA PRO, 使用这个脚本即可开始训练.
  • 🔥2024.02.29: 支持LoRA+, 使用这个脚本即可开始训练.
  • 2024.02.25: 支持swift export, 对模型进行AWQ/GPTQ量化导出, 以及推送ModelScope Hub. 具体可以查看文档: LLM量化文档.
  • 2024.02.22: 支持gemma系列: gemma-2b, gemma-2b-instruct, gemma-7b, gemma-7b-instruct.
  • 2024.02.16: 支持deepseek-math系列: deepseek-math-7b, deepseek-math-7b-instruct, deepseek-math-7b-chat.
  • 🔥2024.02.05: 支持Qwen1.5系列模型, 支持的所有Qwen1.5系列模型请查看模型列表. 提供了qwen1half-7b-chat, qwen1half-7b-chat-int8微调的脚本.
  • 2024.02.05: 支持扩散模型如SDXL, SD, ControlNet的训练, 同时也支持DreamBooth的训练, 详情可以查看对应的训练脚本.
  • 2024.02.01: 支持minicpm系列: minicpm-2b-sft-chat, minicpm-2b-chat.
  • 🔥2024.02.01: 支持数据集打混来减少 灾难性遗忘问题. 使用--train_dataset_mix_ratio 2.0开启训练!同时我们也开源了通用知识数据集 ms-bench.
  • 🔥2024.02.01: 支持Agent训练!Agent训练算法源自这篇论文. 我们也增加了ms-agent这个优质的agent数据集. 使用这个脚本开启Agent训练!
  • 🔥2024.02.01: 支持在DPO训练中增加SFT loss来减少KL散度loss造成的生成重复问题.
  • 2024.02.01: 支持在训练中使用AdaLoRA和IA3两个adapter.
  • 2024.02.01: 支持在AnimateDiff训练中使用--merge_lora参数.
  • 2024.01.30: 支持internlm-xcomposer2-7b-chat.
  • 🔥2024.01.30: 支持ZeRO-3, 只需要指定--deepspeed default-zero3即可.
  • 2024.01.29: 支持internlm2-math系列: internlm2-math-7b, internlm2-math-7b-chat, internlm2-math-20b, internlm2-math-20b-chat.
  • 🔥2024.01.26: 支持yi-vl-6b-chat, yi-vl-34b-chat.
  • 2024.01.24: 支持codefuse-codegeex2-6b-chat, codefuse-qwen-14b-chat.
  • 2024.01.23: 支持orion系列: orion-14b, orion-14b-chat.
  • 2024.01.20: 支持xverse-13b-256k, xverse-65b-v2, xverse-65b-chat.
  • 🔥2024.01.17: 支持internlm2系列: internlm2-7b-base, internlm2-7b, internlm2-7b-sft-chat, internlm2-7b-chat, internlm2-20b-base, internlm2-20b, internlm2-20b-sft-chat, internlm2-20b-chat.
  • 2024.01.15: 支持yuan系列: yuan2-2b-instruct, yuan2-2b-janus-instruct, yuan2-51b-instruct, yuan2-102b-instruct.
  • 🔥2024.01.12: 支持deepseek-moe系列: deepseek-moe-16b, deepseek-moe-16b-chat.
  • 🔥2024.01.04: 支持VLLM部署, 兼容OpenAI API样式, 具体可以查看VLLM推理加速与部署.
  • 2024.01.04: 更新Benchmark, 方便查看不同模型训练的速度和所需显存.
  • 🔥 2023.12.29: 支持web-ui进行sft训练和推理,安装ms-swift后使用swift web-ui开启
  • 🔥 2023.12.29: 支持 DPO RLHF(Reinforcement Learning from Human Feedback) 和三个用于此任务的数据集: AI-ModelScope/stack-exchange-paired 以及 AI-ModelScope/hh-rlhf 以及 AI-ModelScope/hh_rlhf_cn. 查看文档开启训练!
  • 🔥 2023.12.28: 支持SCEdit! 该tuner可显著降低U-Net中的显存占用,并支持低显存可控图像生成(取代ControlNet),阅读下面的章节来了解详细信息
  • 2023.12.23: 支持codegeex2-6b.
  • 2023.12.19: 支持phi2-3b.
  • 2023.12.18: 支持VLLM进行推理加速.
  • 2023.12.15: 支持deepseek, deepseek-coder系列: deepseek-7b, deepseek-7b-chat, deepseek-67b, deepseek-67b-chat, openbuddy-deepseek-67b-chat, deepseek-coder-1_3b, deepseek-coder-1_3b-instruct, deepseek-coder-6_7b, deepseek-coder-6_7b-instruct, deepseek-coder-33b, deepseek-coder-33b-instruct.
  • 2023.12.13: 支持mistral-7b-instruct-v2, mixtral-moe-7b, mixtral-moe-7b-instruct.
  • 2023.12.09: 支持freeze_parameters参数, 作为lora和全参数训练的折中方案. 对应的sh可以查看full_freeze_ddp. 支持disable_tqdm, lazy_tokenize, preprocess_num_proc参数, 具体可以查看命令行参数.
  • 2023.12.08: 支持sus-34b-chat, 支持yi-6b-200k, yi-34b-200k.
  • 2023.12.07: 支持Multi-Node DDP训练.
  • 2023.12.05: 支持模型: zephyr-7b-beta-chat, openbuddy-zephyr-7b-chat. 支持数据集: hc3-zh, hc3-en.
  • 🔥 2023.12.02: 自我认知微调最佳实践, 10分钟对大模型进行自我认知微调, 创建专属于自己的大模型.
  • 🔥 2023.11.30: 支持qwen-1_8b, qwen-72b, qwen-audio系列模型的训练的推理. 对应的sh脚本可以查看qwen_1_8b_chat, qwen_72b_chat, qwen_audio_chat
  • 🔥 2023.11.29: 支持AnimateDiff的训练和推理
  • 🔥 2023.11.24: 支持yi-34b-chat, codefuse-codellama-34b-chat模型. 对应的sh脚本可以查看yi_34b_chat, codefuse_codellama_34b_chat.
  • 🔥 2023.11.18: 支持tongyi-finance-14b系列模型: tongyi-finance-14b, tongyi-finance-14b-chat, tongyi-finance-14b-chat-int4. 对应的sh脚本可以查看tongyi_finance_14b_chat_int4.
  • 2023.11.16: 支持更多模型的flash attn支持: qwen系列, qwen-vl系列, llama系列, openbuddy系列, mistral系列, yi系列, ziya系列. 请使用use_flash_attn参数.
  • 🔥 2023.11.11: 支持NEFTune, 使用Swift.prepare_model(model, NEFTuneConfig())即可开启.
  • 🔥 2023.11.11: 支持命令行训练推理和Web-UI推理, 详情可以查看下方的使用Swift CLI运行章节.
  • 🔥 2023.11.11: 支持模型训练后的部署链路(vllm/chatglm.cpp/xinference),详情可以查看官方文档.
  • 🔥 2023.11.10: 支持bluelm系列模型: bluelm-7b, bluelm-7b-chat, bluelm-7b-32k, bluelm-7b-chat-32k. 对应的sh脚本可以查看bluelm_7b_chat.
  • 🔥 2023.11.08: 支持xverse-65b模型的训练和推理流程,脚本在xverse_65b.
  • 🔥 2023.11.07: 支持yi-6b, yi-34b模型的训练和推理流程,脚本在yi_6b, yi_34b.
  • 🔥 2023.10.30: 支持 QA-LoRALongLoRA两种新的tuners.
  • 🔥 2023.10.30: 支持使用ROME(Rank One Model Editing)来编辑模型,在无需训练的情况下即可给模型灌注新知识!
  • 2023.10.30: 支持skywork-13b系列模型: skywork-13b, skywork-13b-chat. 对应的sh脚本可以查看skywork_13b.
  • 🔥 2023.10.27: 支持chatglm3系列模型: chatglm3-6b-base, chatglm3-6b, chatglm3-6b-32k. 对应的sh脚本可以查看chatglm3_6b.
  • 🔥 2023.10.17: 支持int4, int8模型的SFT: qwen-7b-chat-int4, qwen-14b-chat-int4, qwen-vl-chat-int4, baichuan2-7b-chat-int4, baichuan2-13b-chat-int4, qwen-7b-chat-int8, qwen-14b-chat-int8.
  • 2023.10.15: 支持ziya2-13b系列模型: ziya2-13b, ziya2-13b-chat.
  • 2023.10.12: 支持mistral-7b系列模型: openbuddy-mistral-7b-chat, mistral-7b, mistral-7b-instruct.
  • 🔥 2023.10.07: 支持DeepSpeed ZeRO-2, 使得lora(不仅仅是qlora)可以在双卡A10上运行DDP.
  • 2023.10.04: 支持更多数学, 法律, SQL, 代码领域的数据集: blossom-math-zh, school-math-zh, text2sql-en, sql-create-context-en, lawyer-llama-zh, tigerbot-law-zh, leetcode-python-en.
  • 🔥 2023.09.25: 支持qwen-14b系列: qwen-14b, qwen-14b-chat.
  • 2023.09.18: 支持internlm-20b系列: internlm-20b, internlm-20b-chat.
  • 2023.09.12: 支持MP+DDP对全参数训练进行加速.
  • 2023.09.05: 支持openbuddy-llama2-70b-chat.
  • 2023.09.03: 支持baichuan2系列: baichuan2-7b, baichuan2-7b-chat, baichuan2-13b, baichuan2-13b-chat.

🛠️ 安装

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
# China-Hangzhou image
docker pull registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda12.1.0-py310-torch2.1.2-tf2.14.0-1.13.1
# US-west image
docker pull registry.us-west-1.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda12.1.0-py310-torch2.1.2-tf2.14.0-1.13.1

🚀 快速开始

本章节介绍基本使用,更丰富的使用方式请查看文档部分

Web-UI

swift web-ui

训练

训练脚本

你可以参考以下脚本来自定义属于你的训练脚本.

支持的训练过程

训练过程 训练方式
预训练 文本生成
微调 单轮/多轮
Agent训练/自我认知
多模态视觉/多模态语音
人类对齐 DPO
文生图 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 \

多机多卡

# 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_id_or_path 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_id_or_path qwen1half-32b-chat \
    --sft_type full \
    --dataset blossom-math-zh \
    --output_dir output \
    --deepspeed default-zero3 \

推理

原始模型:

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 mmlu ceval

导出

原始模型:

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 \

部署

原始模型:

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
通义千问1.0和1.5系列模型 中文
英文
0.5B-110B
包含量化版本
base模型
chat模型
MoE模型
代码模型
ChatGLM2
ChatGLM3
Codegeex2
智谱ChatGLM系列模型 中文
英文
6B 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系列模型 英文 8B-70B
包含量化版本
base模型
chat模型
Mistral
Mixtral
Mistral系列模型 英文 7B-8x22B base模型
instruct模型
MoE模型
YI 01AI的YI系列模型 中文
英文
6B-34B
包含量化版本
base模型
chat模型
长文本模型
InternLM
InternLM2
InternLM2-Math
浦江实验室书生浦语系列模型 中文
英文
1.8B-20B base模型
chat模型
数学模型
DeepSeek
DeepSeek-MoE
DeepSeek-Coder
DeepSeek-Math
幻方系列模型 中文
英文
1.3B-67B base模型
chat模型
MoE模型
代码模型
数学模型
MAMBA MAMBA时序卷积模型 英文 130M-2.8B base模型
Gemma Google Gemma系列模型 英文 2B-7B base模型
instruct模型
MiniCPM OpenBmB MiniCPM系列模型 中文
英文
2B-3B chat模型
MoE模型
OpenBuddy OpenBuddy系列模型 中文
英文
7B-67B 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模型
长文本模型
ModelScope-Agent ModelScope Agent系列 中文 7B-14B agent模型

多模态大模型

模型类型 模型介绍 语言 模型大小 模型类型
Qwen-VL 通义千问视觉模型 中文
英文
7B
包含量化版本
base模型
chat模型
Qwen-Audio 通义千问语音模型 中文
英文
7B base模型
chat模型
YI-VL 01AI的YI系列视觉模型 中文
英文
6B-34B chat模型
XComposer2 浦江实验室书生浦语视觉模型 中文
英文
7B chat模型
DeepSeek-VL 幻方系列视觉模型 中文
英文
1.3B-7B chat模型
MiniCPM-V OpenBmB MiniCPM视觉模型 中文
英文
3B chat模型
CogVLM
CogAgent
智谱ChatGLM视觉问答和Agent模型 英文 17B-18B chat模型
Llava Llava系列模型 英文 7B-34B chat模型
mPLUG-Owl mPLUG-Owl系列模型 英文 11B chat模型

扩散模型

模型类型 模型介绍 语言 模型类型
AnimateDiff AnimateDiff动画模型 英文 文生视频
SD1.5/SD2.0/SDXL StabilityAI系列扩散模型 英文 文生图

支持的开源数据集

数据集类型 训练任务 文档
通用 微调 🔥ruozhiba, 🔥ms-bench, 🔥ms-bench-mini, 🔥alpaca-en(gpt4), 🔥alpaca-zh(gpt4), multi-alpaca-all, instinwild-en, instinwild-zh, cot-en, cot-zh, firefly-all-zh, instruct-en, gpt4all-en, sharegpt-en, sharegpt-zh, tulu-v2-sft-mixture, wikipedia-zh, open-orca, open-orca-gpt4, sharegpt-gpt4, 🔥sharegpt-gpt4-mini.
Agent 微调 🔥ms-agent, ms-agent-for-agentfabric-default, ms-agent-for-agentfabric-addition, damo-mini-agent-zh, damo-agent-zh, agent-instruct-all-en.
通用 人类对齐 🔥hh-rlhf-cn, stack-exchange-paired, hh-rlhf-harmless-base, hh-rlhf-helpful-base, hh-rlhf-helpful-online, hh-rlhf-helpful-rejection-sampled, hh-rlhf-red-team-attempts, hh-rlhf-cn-harmless-base-cn, hh-rlhf-cn-helpful-base-cn, hh-rlhf-cn-harmless-base-en, hh-rlhf-cn-helpful-base-en.
代码 微调 code-alpaca-en, 🔥leetcode-python-en, 🔥codefuse-python-en, 🔥codefuse-evol-instruction-zh.
医疗 微调 medical-en, medical-zh, medical-mini-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, 🔥cmnli-mini-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-mini-en, coco-mini-en-2, capcha-images.
音频 微调 aishell1-zh, 🔥aishell1-mini-zh.

支持的技术

技术名称
🔥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
🔥SCEdit: SCEdit: Efficient and Controllable Image Diffusion Generation via Skip Connection Editing < arXiv | Project Page >
🔥NEFTune: Noisy Embeddings Improve Instruction Finetuning
QA-LoRA:Quantization-Aware Low-Rank Adaptation of Large Language Models
LongLoRA: Efficient Fine-tuning of Long-Context Large Language Models
ROME: Rank-One Editing of Encoder-Decoder Models
Adapter: Parameter-Efficient Transfer Learning for NLP
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 | Project Page | Usage >
PEFT提供的tuners, 如IA3, AdaLoRA等

支持的硬件

硬件环境 备注
CPU
RTX20系列/30系列/40系列等 30序列之后可使用BF16和FlashAttn
计算卡系列 T4/V100等 不支持BF16和FlashAttn
计算卡系列 A10/A100等 支持BF16和FlashAttn
华为昇腾NPU

📃文档

文档编译

make docs
# 浏览器查看docs/build/html/index.html

用户指南

文档名称
使用Web-UI
使用Tuners
LLM推理
LLM微调
LLM评测
LLM量化
LLM部署
DPO人类对齐训练
AnimateDiff训练

参考文档

文档名称
命令行参数
支持的模型和数据集列表
自定义新模型和数据集
运行速度与显存Benchmark
HuggingFace生态兼容

最佳实践

最佳实践名称
Agent微调最佳实践
自我认知微调最佳实践
Qwen1.5最佳实践
多模态模型训练最佳实践
NPU推理与微调最佳实践

深度学习教程

教程名称
深度学习入门
大模型基础知识
提示词工程
Transformer结构介绍
训练技术选型
数据预处理
量化
训练
推理
部署
评估

🏛 License

本框架使用Apache License (Version 2.0)进行许可。模型和数据集请查看原资源页面并遵守对应License。

📎 引用

@Misc{swift,
  title = {SWIFT:Scalable lightWeight Infrastructure for Fine-Tuning},
  author = {The ModelScope Team},
  howpublished = {\url{https://github.com/modelscope/swift}},
  year = {2024}
}

☎ 联系我们

您可以通过加我们的微信群, 来和我们联系和交流:

Star History

Star History Chart

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

暂无描述 展开 收起
Python 等 2 种语言
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/RexHuang936/swift.git
git@gitee.com:RexHuang936/swift.git
RexHuang936
swift
swift
main

搜索帮助