Overview
ms-swift (Scalable lightWeight Infrastructure for Fine-Tuning) is a training and deployment framework from the ModelScope community. It covers the full pipeline for large models: pre-training, fine-tuning, human alignment, inference, evaluation, quantization, and deployment. It supports 600+ text models such as Qwen3, GLM4.5, Mistral, DeepSeek-R1, and Llama4, plus 400+ multimodal models like Qwen3-VL, InternVL3.5, and DeepSeek-VL2.
It is aimed at ML engineers and researchers who want to adapt open models to their own data without wiring together many separate tools. You point the `swift` CLI at a model and a dataset, pick a tuning method, and it handles the training loop, checkpointing, and later inference or deployment.
As a fine-tuning framework, ms-swift sits alongside tools like Axolotl and LLaMA-Factory. Its scope is broad: lightweight methods (LoRA, QLoRA, DoRA), full-parameter SFT, preference learning (DPO, KTO, ORPO), the GRPO family of reinforcement learning algorithms, and Megatron-based parallelism for larger MoE models.
What it does
- Supports 600+ text models and 400+ multimodal models, with Day-0 support for popular new releases
- Lightweight fine-tuning with LoRA, QLoRA, DoRA, LoRA+, LongLoRA, and other PEFT methods, plus full-parameter SFT
- Preference learning and RL: DPO, KTO, RM, CPO, SimPO, ORPO, and the GRPO family (GRPO, DAPO, GSPO, RLOO, Reinforce++)
- Inference and deployment acceleration via vLLM, SGLang, and LMDeploy, exposed through OpenAI-compatible endpoints
- Distributed training with DDP, DeepSpeed ZeRO2/ZeRO3, FSDP/FSDP2, and Megatron TP/PP/CP/EP parallelism
- Single `swift` CLI plus a Web-UI covering training, inference, evaluation, and quantization (AWQ, GPTQ, BNB, FP8)
Getting started
Install the package from PyPI, then use the swift CLI to run a LoRA fine-tune and serve the result. ms-swift needs Python 3.10+ and PyTorch 2.0+.
Install ms-swift
Install the latest release from PyPI. Installing from source is also supported via git clone.
pip install ms-swift -UFine-tune a model with LoRA
Run supervised fine-tuning on a single GPU. This trains Qwen3-4B-Instruct with LoRA on a sample dataset and writes checkpoints to the output directory.
CUDA_VISIBLE_DEVICES=0 \
swift sft \
--model Qwen/Qwen3-4B-Instruct-2507 \
--tuner_type lora \
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
--torch_dtype bfloat16 \
--num_train_epochs 1 \
--per_device_train_batch_size 1 \
--learning_rate 1e-4 \
--lora_rank 8 \
--lora_alpha 32 \
--output_dir outputRun inference on the trained adapter
Load the LoRA adapter produced by training and chat with the model in streaming mode.
CUDA_VISIBLE_DEVICES=0 \
swift infer \
--adapters output/vx-xxx/checkpoint-xxx \
--stream true \
--temperature 0 \
--max_new_tokens 2048Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Adapt an open model like Qwen3 or Llama4 to a domain dataset using LoRA or QLoRA on a single GPU
- Align a model to human preferences with DPO, KTO, or GRPO reinforcement learning
- Fine-tune multimodal models (vision, video, audio) such as Qwen3-VL or InternVL3.5
- Quantize a trained model and serve it through an OpenAI-compatible endpoint with vLLM or SGLang
How ms-swift compares
ms-swift alongside other open-source fine-tuning frameworks tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| LLaMA-Factory | ★ 72.3k | An end-to-end training suite with a web UI that covers pre-training, supervised fine-tuning, and RLHF for hundreds of LLMs and multimodal models. |
| Unsloth | ★ 66.9k | A library that speeds up LoRA and QLoRA fine-tuning while cutting memory use, aimed at training models on a single GPU. |
| PEFT | ★ 21.3k | Hugging Face's library of parameter-efficient fine-tuning methods such as LoRA, DoRA, and prompt tuning that train small adapters instead of full models. |
| FinGPT | ★ 20.5k | FinGPT is an open-source project of financial LLMs, fine-tuned with LoRA on news and tweet data for tasks like sentiment analysis, relation extraction, and stock-move forecasting. |
| ms-swift | ★ 14.6k | Train, fine-tune, and deploy 600+ LLMs and 400+ multimodal models from one CLI |
| LitGPT | ★ 13.4k | An open-source toolkit from Lightning AI to pretrain, finetune, and serve 20+ large language models, each written from scratch for speed and full control. |
| Axolotl | ★ 12.1k | A config-driven tool for fine-tuning and post-training open LLMs that supports SFT, LoRA/QLoRA, DPO, GRPO, and multi-GPU training across many model families. |
| Ludwig | ★ 11.7k | Ludwig is a low-code framework that lets you train, fine-tune, and deploy LLMs, multimodal, and tabular models using a YAML config instead of boilerplate Python. |