# ms-swift

> Fine-tuning and deployment framework from the ModelScope community for training, evaluating, quantizing and serving text and multimodal large models.

ms-swift (SWIFT, Scalable lightWeight Infrastructure for Fine-Tuning) is an open-source framework from the ModelScope community for fine-tuning and deploying large language models and multimodal models. According to its README, it covers pre-training, fine-tuning, human alignment, inference, evaluation, quantization and deployment for 600+ text-only and 400+ multimodal models. The latest release listed is v4.6.0.

## What It Is

ms-swift is a Python training and deployment toolkit driven mainly by a command-line interface (`swift sft`, `swift rlhf`, `swift infer`, `swift deploy`, `swift eval`, `swift export`), with a Gradio-based Web-UI and a Python API as alternatives. Users pick a model and a dataset (built-in or custom), choose a tuning method such as full-parameter, LoRA or QLoRA, and run training. Models and datasets are downloaded from ModelScope by default, with HuggingFace as an option.

## Training and Reinforcement Learning

Supported tasks include pre-training, supervised fine-tuning, DPO, KTO, CPO, SimPO, ORPO, reward models, GKD distillation, embedding, reranker and sequence classification training. A family of GRPO-style reinforcement learning algorithms is built in, including GRPO, DAPO, GSPO, SAPO, CISPO, CHORD, RLOO and Reinforce++, with vLLM-accelerated rollouts and plugin-based reward functions and multi-turn schedulers. Megatron-SWIFT adds TP/PP/CP/EP parallelism for large-scale and MoE training.

## Inference, Evaluation and Export

Inference and deployment can use Transformers, vLLM, SGLang or LMDeploy, exposing OpenAI-compatible interfaces. Evaluation uses EvalScope as backend. Models can be quantized with GPTQ, AWQ, BNB or FP8, merged from LoRA adapters, and pushed to ModelScope.

## Hardware Support

Documentation covers NVIDIA GPUs, AMD GPUs, Ascend NPU, MetaX, Moore Threads MUSA, Apple MPS and CPU. The README states a 7B model can be trained with quantized training in about 9GB.

## Features
- Pre-training, SFT, and human alignment (DPO, KTO, CPO, SimPO, ORPO, RM)
- GRPO family reinforcement learning (GRPO, DAPO, GSPO, SAPO, CISPO, CHORD, RLOO, Reinforce++)
- LoRA, QLoRA, DoRA and other lightweight tuning methods
- Megatron-SWIFT parallelism (TP/PP/CP/EP) for MoE and large-scale training
- Embedding, reranker and sequence classification training
- Multimodal training with packing and mixed modality data
- Agent templates for tool-calling training
- Inference and deployment via Transformers, vLLM, SGLang, LMDeploy
- Evaluation through EvalScope
- Quantization export (GPTQ, AWQ, BNB, FP8)
- Web-UI for training, inference, evaluation and quantization
- Support for NVIDIA, AMD, Ascend NPU, MetaX, MUSA, Apple MPS and CPU

## Integrations
ModelScope, HuggingFace, vLLM, SGLang, LMDeploy, EvalScope, DeepSpeed, Megatron, Ray, PEFT, Gradio

## Platforms
LINUX, WEB, API, DEVELOPER_SDK, CLI

## Pricing
Open Source

## Version
v4.6.0

## Links
- Website: https://swift.readthedocs.io/zh-cn/latest/
- Documentation: https://swift.readthedocs.io/en/latest/
- Repository: https://github.com/modelscope/ms-swift
- EveryDev.ai: https://www.everydev.ai/tools/ms-swift
