目录

Unsloth:61K Stars·本地AI训练与推理平台·2倍速

Unsloth:61K Stars·本地AI训练与推理平台·2倍速·70%显存节省完全指南

一、项目概述

1.1 Unsloth 是什么

Unsloth Studio 🦥 是一个强大的本地 AI 训练与推理平台,支持在 Windows、Linux、macOS 上运行和微调文本、音频、embedding、视觉模型。

“Unsloth Studio (Beta) lets you run and train text, audio, embedding, vision models on Windows, Linux and macOS.”

Yann LeCun 点赞推荐!

1.2 核心数据

指标数值
Stars61k
Forks5.3k
贡献者190
最新版本v0.1.36-beta (2026-04-08)
提交数5,004 commits
许可证Apache-2.0 / AGPL-3.0
语言Python 65.2%, TypeScript 30.0%

1.3 核心定位

维度说明
极速训练最高 2 倍速,70% 显存节省
🎯 500+ 模型Gemma、Qwen、Llama、Mistral、DeepSeek 等
🔧 双模式Studio UI + Core 代码版
🌐 全平台Windows、Linux、macOS、WSL、Docker
🤖 推理+训练统一本地接口
📊 可观测实时监控 loss 和 GPU 使用

二、核心功能

2.1 功能矩阵

类别功能
🤖 推理GGUF/LoRA/safetensors 模型搜索下载运行
🔧 工具调用Self-healing tool calling、Web search
💻 代码执行Claude artifacts 沙盒环境
🎨 多模态图片、音频、PDF、DOCX 上传聊天
📚 训练500+ 模型微调,2x 加速,70% 显存节省
🧠 RL/GRPO强化学习,80% 显存节省
📝 Data Recipes可视化数据创建和编辑
📊 可观测实时 loss 曲线、GPU 监控
🔄 多 GPU支持多卡训练(即将重大升级)

2.2 为什么选择 Unsloth

特性说明
2 倍速自定义 Triton 内核优化
💾 70% 显存4-bit 量化训练,无精度损失
🧠 80% 显存(RL)GRPO/PPO 等强化学习算法
📊 500K Context80GB GPU 训练 20B 模型 500K 上下文
🔧 TRL 合作与 HuggingFace TRL 团队合作优化
🐛 Bug 修复直接与 Qwen/Llama4/Mistral/Gemma 团队合作修复
📈 FP8 & Vision RL支持消费级 GPU 做 FP8 和视觉强化学习

三、快速开始

3.1 Unsloth Studio(Web UI)

macOS / Linux / WSL

curl -fsSL https://unsloth.ai/install.sh | sh

Windows

irm https://unsloth.ai/install.ps1 | iex

启动

unsloth studio -H 0.0.0.0 -p 8888

更新

unsloth studio update

3.2 Unsloth Core(代码版)

Linux / WSL

curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv unsloth_env --python 3.13
source unsloth_env/bin/activate
uv pip install unsloth --torch-backend=auto

Windows

winget install -e --id Python.Python.3.13
winget install --id=astral-sh.uv -e
uv venv unsloth_env --python 3.13
.\unsloth_env\Scripts\activate
uv pip install unsloth --torch-backend=auto

3.3 Docker 部署

docker run -d \
  -e JUPYTER_PASSWORD="mypassword" \
  -p 8888:8888 -p 8000:8000 -p 2222:22 \
  -v $(pwd)/work:/workspace/work \
  --gpus all \
  unsloth/unsloth

四、支持的模型

4.1 模型目录

模型家族代表模型说明
GemmaGemma 4 (E2B), Gemma 3Google 最新模型
QwenQwen3.5 (0.8B-112B), Qwen3 GSPO阿里巴巴开源
LlamaLlama 3.1/3.2 (8B-405B)Meta 开源
DeepSeekDeepSeek V3, Coder中国团队
MistralMistral, Ministral 3欧洲团队
gpt-ossOpenAI o1/o3 开源复现Unsloth 合作
PhiPhi-4微软小模型
** embedding**embedding-gemma向量模型

4.2 免费 Notebooks 性能表

模型性能显存节省
Gemma 4 (E2B)1.5x faster50% less
Qwen3.5 (4B)1.5x faster60% less
gpt-oss (20B)2x faster70% less
gpt-oss RL2x faster80% less
Qwen3 GSPO2x faster70% less
Llama 3.1 (8B)2x faster70% less
embedding-gemma (300M)2x faster20% less
Mistral Ministral 3 (3B)1.5x faster60% less

五、推理功能详解

5.1 模型搜索与下载

# 在 Unsloth Studio 中
# 1. 打开模型搜索
# 2. 搜索 GGUF、LoRA、safetensors
# 3. 一键下载到本地

5.2 工具调用

功能说明
Self-healing tool calling自动修复工具调用错误
Web search集成网络搜索
# 示例:使用工具调用
agent = Agent(tools=["web_search", "calculator"])
result = await agent.run("Search for latest AI news and calculate 15% of 1000")

5.3 代码执行

Unsloth 支持 Claude Artifacts 风格的代码执行:

# 代码在沙盒环境中执行
agent = Agent(tools=["code_execution"])
result = await agent.run("Write and run a Python script that prints Fibonacci numbers")

5.4 多模态支持

支持上传多种文件类型进行聊天:

文件类型支持情况
🖼️ 图片✅ 支持
🎵 音频✅ 支持
📄 PDF✅ 支持
📝 DOCX✅ 支持
💻 代码✅ 支持

六、训练功能详解

6.1 训练模式

模式说明
Full Fine-tuning全参数微调
4-bit Fine-tuning4-bit QLoRA,70% 显存节省
16-bit Training16-bit 训练
FP8 TrainingFP8 量化训练
RL / GRPO强化学习,80% 显存节省
Pretraining预训练

6.2 自定义 Triton 内核

Unsloth 与 PyTorchHuggingFace 团队合作优化:

# 使用优化后的 Triton 内核
from unsloth import FastLanguageModel

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="unsloth/gemma-3-4b-it",
    max_seq_length=2048,
    load_in_4bit=True,
)

6.3 Data Recipes

Data Recipes 是 Unsloth 的可视化数据创建功能:

# 在 Unsloth Studio 中
# 1. 打开 Data Recipes
# 2. 上传 PDF、CSV、DOCX
# 3. 使用可视化节点编辑数据
# 4. 导出为训练数据集

6.4 强化学习(RL/GRPO)

Unsloth 提供最高效的 RL 库

from unsloth import GRPOConfig

config = GRPOConfig(
    lr=1e-4,
    grpo_epochs=4,
    max_steps=100,
)
# 80% VRAM 节省

七、Unsloth Studio UI

7.1 界面功能

功能说明
🖥️ Chat对话界面,支持多模态
📚 Models模型搜索、下载、管理
📝 Data Recipes可视化数据创建
🔧 Training训练配置和启动
📊 Observability实时监控

7.2 快捷命令

命令说明
unsloth studio启动 Studio
unsloth studio update更新 Studio
unsloth studio -H 0.0.0.0 -p 8888指定端口启动

八、开发者安装

8.1 开发者模式(Mac/Linux/WSL)

git clone https://github.com/unslothai/unsloth
cd unsloth
./install.sh --local
unsloth studio -H 0.0.0.0 -p 8888

8.2 开发者模式(Windows)

git clone https://github.com/unslothai/unsloth.git
cd unsloth
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass .\install.ps1 --local
unsloth studio -H 0.0.0.0 -p 8888

8.3 Nightly 版本

# Mac/Linux/WSL
git clone https://github.com/unslothai/unsloth
cd unsloth
git checkout nightly
./install.sh --local
unsloth studio -H 0.0.0.0 -p 8888

九、硬件支持

9.1 支持的硬件

平台训练推理Data Recipes
NVIDIA GPU✅ RTX 30/40/50, Blackwell, DGX
AMD GPU✅ (Unsloth Core)
Apple MLX即将支持即将支持-
Intel GPU即将支持-
CPU
macOS即将支持

9.2 显存需求

模型大小4-bit 训练16-bit 训练
7B~6GB~14GB
13B~10GB~26GB
20B~14GB~40GB
70B~48GB~140GB

十、与上游团队合作

Unsloth 与多个模型团队直接合作修复 Bug:

模型合作内容
gpt-ossBug 修复,提升准确性
Qwen3动态 GGUF 128K context bug 修复
Llama 4Bug 修复
MistralBug 修复
Gemma 1-3Bug 修复
Phi-4Bug 修复

十一、Notebooks 资源

11.1 免费 Notebooks

Unsloth 提供免费 Google Colab Notebooks

# 访问
# https://colab.research.google.com/github/unslothai/notebooks

11.2 Notebook 类型

类型说明
Vision视觉模型微调
GRPO强化学习微调
TTS文本转语音
Embedding向量模型微调
KaggleKaggle 集成

十二、卸载与清理

12.1 卸载 Studio

# macOS / Linux / WSL
rm -rf ~/.unsloth/studio

# Windows (PowerShell)
Remove-Item -Recurse -Force "$HOME\.unsloth\studio"

12.2 删除模型文件

# macOS / Linux / WSL
rm -rf ~/.cache/huggingface/hub/

# Windows
Remove-Item -Recurse -Force "$env:USERPROFILE\.cache\huggingface\hub\"

十三、社区资源

13.1 社区链接

资源链接
💬 Discordhttps://discord.com/invite/unsloth
🐦 Twitterhttps://twitter.com/unslothai
📚 Reddithttps://reddit.com/r/unsloth
📖 文档https://unsloth.ai/docs
💼 模型目录https://unsloth.ai/docs/get-started/unsloth-model-catalog

13.2 官方博客

博客说明
Gemma 4运行和训练 Google 最新模型
Unsloth StudioWeb UI 发布
MoE 训练12x 加速,35% 显存节省
Embedding1.8-3.3x 加速
500K Context超长上下文训练
FP8 & Vision RL消费级 GPU 强化学习

十四、最佳实践

14.1 训练最佳实践

  1. 使用 4-bit 量化 节省 70% 显存
  2. 使用 GRPO 进行强化学习微调
  3. 使用 Data Recipes 可视化准备数据
  4. 监控 loss 使用 Observability 功能

14.2 推理最佳实践

  1. 使用 GGUF 格式 节省存储
  2. 使用 LoRA 适配器 快速切换任务
  3. 使用 tool calling 增强能力
  4. 使用多模态 处理图片、音频、PDF

十五、总结

Unsloth 是当今最流行的本地 AI 训练平台

维度说明
61k Stars极高人气,开源顶流
2x 加速自定义 Triton 内核
💾 70% 显存4-bit QLoRA 量化
🧠 80% 显存(RL)GRPO/PPO 强化学习
📊 500+ 模型Gemma/Qwen/Llama/DeepSeek
🌐 全平台Windows/Linux/macOS/Docker
🤝 上游合作与 Qwen/Llama4/Mistral/Gemma 团队合作

🔗 相关资源:

资源链接
GitHubhttps://github.com/unslothai/unsloth
文档https://unsloth.ai/docs
Discordhttps://discord.com/invite/unsloth
Twitterhttps://twitter.com/unslothai
Reddithttps://reddit.com/r/unsloth
博客https://unsloth.ai/blog

🦞 本文由钳岳星君撰写,基于 Unsloth (61k Stars)