Purpose
ms-swift (Scalable lightWeight Infrastructure for Fine-Tuning) is a fine-tuning and deployment framework for large models and multimodal large models provided by the ModelScope community. It targets the entire workflow of large model training (pre-training, fine-tuning, human alignment), inference, evaluation, quantization, and deployment, and supports more than 600 pure-text large models and more than 400 multimodal large models.
Main Capabilities
Model Support: Supports 600+ pure-text large models, 400+ multimodal large models, and All-to-All omni-modal models, covering the entire workflow from training to deployment, and provides Day-0 support for popular models. Text models include Qwen3, Qwen3.5, InternLM3, GLM4.5, Mistral, DeepSeek-R1, Llama4, etc.; multimodal models include Qwen3-VL, Qwen3-Omni, Kimi-K3, Llava, InternVL3.5, MiniCPM-V-4, Ovis2.5, GLM4.5-V, DeepSeek-VL2, etc.
Datasets: Built in with 150+ datasets, covering tasks such as pre-training, fine-tuning, human alignment, and multimodal, and supports custom datasets.
Hardware Support: Supports NVIDIA GPU (A100/H100/RTX series, via CUDA), AMD GPU (MI300 series, via ROCm), domestic hardware such as Ascend NPU, MetaX GPU, and Moore Threads GPU (via MUSA), as well as Apple MPS and CPU.
Lightweight Training: Supports lightweight fine-tuning methods such as LoRA, QLoRA, DoRA, LoRA+, LLaMAPro, LongLoRA, LoRA-GA, ReFT, RS-LoRA, Adapter, and LISA.
Quantized Training: Supports training on BNB, AWQ, GPTQ, AQLM, HQQ, and EETQ quantized models; a 7B model requires only 9GB of training resources.
Memory Optimization: Supports GaLore, Q-Galore, UnSloth, Liger-Kernel, Flash-Attention 2/3, as well as Ulysses and Ring-Attention sequence parallelism techniques, reducing memory consumption for long-text training.
Distributed Training: Supports distributed data parallel (DDP), device_map simple model parallelism, DeepSpeed ZeRO2/ZeRO3, FSDP/FSDP2, and Megatron distributed training techniques.
Multimodal Training: Supports multimodal packing techniques, increasing training speed by 100%+, supports training on mixed-modal data of text, images, videos, and audio, and supports independent control of vit/aligner/llm.
Agent Training: Supports Agent templates, allowing one dataset to be used to train different models.
Training Tasks: Supports pre-training and instruction fine-tuning, as well as training tasks such as DPO, GKD, KTO, RM, CPO, SimPO, and ORPO, and supports Embedding/Reranker and sequence classification tasks.
Megatron Parallelism: Provides TP/PP/SP/CP/ETP/EP/VPP parallelism strategies, significantly improving MoE model training speed. Supports full-parameter and LoRA training for 300+ pure-text large models and 100+ multimodal large models, and supports CPT/SFT/GRPO/DPO/KTO/RM training tasks.
Reinforcement Learning: Built in with a rich family of GRPO algorithms, including GRPO, DAPO, GSPO, SAPO, CISPO, CHORD, RLOO, Reinforce++, etc. Supports synchronous and asynchronous vLLM engine inference acceleration, and allows extension of reward functions, multi-turn inference Scheduler, and environments through plugins.
Full-Workflow Capabilities: Covers the complete workflow of training, inference, evaluation, quantization, and deployment.
UI Training: Provides a Web-UI interface for training, inference, evaluation, and quantization, completing the full large model workflow.
Inference Acceleration: Supports Transformers, vLLM, SGLang, and LmDeploy inference acceleration engines, and provides an OpenAI interface to accelerate the inference, deployment, and evaluation modules.
Model Evaluation: Uses EvalScope as the evaluation backend, supports 100+ evaluation datasets, and is used to evaluate pure-text and multimodal models.
Model Quantization: Supports AWQ, GPTQ, FP8, and BNB quantized export. The exported models support inference acceleration using vLLM/SGLang/LmDeploy.
Usage
Installation: Supports pip installation and source code installation.
Command-line interface (recommended): Training can be performed via the command line, for example, conducting a 10-minute self-cognition fine-tuning of Qwen3-4B-Instruct-2507 on a single 3090 GPU. If using a custom dataset, refer to the guide to organize the dataset format and specify --dataset <dataset_path>。--model_author and --model_name parameters only take effect when the dataset contains swift/self-cognition . To change the model, simply modify --model <model_id/model_path>. By default, ModelScope is used to download models and datasets. If you need to use HuggingFace, specify --use_hf true.
After training is complete, you can use the command for inference, where --adapters is replaced with the last checkpoint folder generated by training. Since the adapters folder contains the training parameter file args.json, there is no need to specify --model、--systemseparately; Swift will automatically read these parameters. If you need to disable this behavior, you can set --load_args false. Finally, you can use the command to push the model to ModelScope.
Web-UI: Based on Gradio interface technology, it provides a zero-threshold training and deployment interface solution.
Python: ms-swift also supports training and inference using Python.
Minimal example: A minimal example from training to deployment. If you need to use other models or datasets (including multimodal models and datasets), simply modify --model to specify the corresponding model ID or path, and modify --dataset to specify the corresponding dataset ID or path.
Applicable scenarios
Applicable to scenarios such as pre-training, instruction fine-tuning, human preference alignment, reinforcement learning training, inference acceleration, model evaluation, quantization, and deployment of large models and multimodal large models, covering needs from single-GPU lightweight fine-tuning to large-scale cluster training, MoE model training, and more.
Limitations
This framework uses the Apache License 2.0 license. For models and datasets, please refer to the original resource pages and follow the corresponding licenses.