unsloth-finetuning
できること
このツールは、VRAM(ビデオメモリ)が限られた1台のパソコンで、AIモデルを学習させる手助けをします。学習を速くし、使用するメモリも少なくするため、これまでは非常に高性能なコンピューターでしか学習できなかったAIモデルを、自分好みに調整できるようになります。
使う場面
- ✓自分のパソコンでAIモデルを学習させたいが、VRAMが限られているとき。
- ✓メモリ不足で学習が失敗し、設定を調整する必要があるとき。
- ✓学習済みのモデルを特定の形式(GGUF、vLLM)で書き出したいとき。
スキルのリンク
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/unsloth-finetuning/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“16GBのVRAMだけを使って「unsloth/Qwen3-8B」モデルを学習させ、GGUF形式で書き出すにはどうすればよいですか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
このツールは、VRAMの使用量と学習時間を最適化することで動作します。LoRAやQLoRAなどの技術を使ってモデルを微調整でき、書き出す前にモデルが会話の形式を正しく理解できるようにします。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Unsloth Fine-Tuning
Overview
Unsloth trains LLMs with custom kernels that cut VRAM use and step time without changing the math, which makes single-GPU fine-tuning practical on hardware that would otherwise OOM. This skill covers Unsloth Core — the Python API — because that is what an agent can drive programmatically; the Desktop app and Studio web UI are interactive and out of scope.
The hard parts of an Unsloth run are not the training call. They are sizing the job against available VRAM, getting the chat template and loss masking right, and choosing an export format the target runtime can actually load. This skill covers those three.
When to Use This Skill
- Use when fine-tuning an LLM on one GPU and VRAM is the binding constraint.
- Use when a training run OOMs and needs to be resized rather than rewritten.
- Use when doing preference or RL post-training (GRPO, DPO) on consumer hardware.
- Use when a fine-tuned model must be exported to GGUF, vLLM, or merged 16-bit weights.
- Use when a fine-tune "ran fine" but the model's output format is wrong — usually a chat template or loss-masking bug, not a hyperparameter one.
Do not use this skill when
- The training is multi-node or large-scale multi-GPU. Use plain TRL with Accelerate/DeepSpeed.
- The architecture is unsupported by Unsloth. Fall back to TRL; do not force it.
- The user wants managed cloud training. That is Hugging Face Jobs, not local Unsloth.
- The user wants the Desktop or Studio GUI. Point them at the installer, not this skill.
How It Works
Step 1: Size the run before writing code
VRAM is the constraint that decides everything else. Estimate weights first, then leave room for activations and optimizer state:
| Load mode | Weight cost | 8B model | Use when |
|---|---|---|---|
load_in_4bit (QLoRA) |
~0.55 GB per 1B params | ~4.5 GB | Default. Under 16 GB VRAM. |
load_in_8bit |
~1.1 GB per 1B params | ~9 GB | Quality-sensitive, 16-24 GB. |
load_in_16bit |
~2 GB per 1B params | ~16 GB | LoRA at full precision, 24 GB+. |
full_finetuning=True |
~2 GB weights + ~12 GB optimizer | ~112 GB | Rarely justified. Prefer LoRA. |
Add roughly 2-6 GB for activations, scaling with max_seq_length and batch size. Treat these
as planning figures and confirm against nvidia-smi on the first run — they vary by
architecture, attention implementation and vocabulary size.
If the estimate does not fit, reduce in this order: max_seq_length, then batch size (raising
gradient_accumulation_steps to hold the effective batch constant), then LoRA rank, then model
size. Cutting rank before sequence length usually costs more quality than it saves memory.
Step 2: Load the model
import unsloth must come before transformers, trl or peft. Unsloth patches those
libraries at import time; importing them first silently disables the optimizations.
import unsloth # must be first
import os
import re
from unsloth import FastLanguageModel
def reviewed_revision(variable):
revision = os.environ.get(variable, "")
if re.fullmatch(r"[0-9a-fA-F]{40}", revision) is None:
raise RuntimeError(f"{variable} must be a reviewed full 40-character Hub commit SHA")
return revision.lower()
model_revision = reviewed_revision("UNSLOTH_MODEL_REVISION")
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "unsloth/Qwen3-8B",
revision = model_revision,
max_seq_length = 2048,
load_in_4bit = True,
dtype = None, # auto-detects bf16 where supported
)
Pick the loader that matches the modality: FastLanguageModel for text-only causal LMs,
FastVisionModel for vision-language models, FastModel when the modality is decided at runtime.
The unsloth/ Hub namespace holds pre-quantized copies that download faster and skip a local
quantization pass. Upstream repos such as Qwen/ or meta-llama/ work identically.
Before setting UNSLOTH_MODEL_REVISION, inspect that exact Hub commit and obtain approval for the
download. Record the repository and full revision with the run; never substitute a branch, tag,
range, or moving default.
Step 3: Fix the chat template before training
This is the most common silent failure. A run with the wrong template converges cleanly and produces a model that ignores its stop tokens or emits prompt scaffolding at inference.
from unsloth.chat_templates import (
get_chat_template,
standardize_data_formats,
…
よくある質問
VRAMとは何で、なぜ重要ですか?
VRAMは、グラフィックボードに搭載された専用のメモリです。AIモデルの学習には多くのVRAMが必要になるため、このツールは使用するVRAMを減らす手助けをします。
LoRAとQLoRAとは何ですか?
AIモデルの一部だけを学習させる技術です。これにより、メモリと時間を大幅に節約できます。QLoRAは、さらにメモリ効率を高めたバージョンです。
「チャットテンプレート」とは何ですか?
AIモデルが会話の構造を理解するために使う形式のことです。チャットテンプレートが正しくないと、モデルが誤った応答を生成する原因になります。
詳細
作者による元の説明
Fine-tune and post-train LLMs with Unsloth Core on a single consumer GPU: VRAM sizing, LoRA/QLoRA, GRPO/DPO, chat-template correctness, and GGUF export.
人気
- GitHubのスター
- 48k
- ランキング
- #6066
- ライセンス
- MIT
- 更新日
- 2026/10/15
コメント
- …
このリポジトリの他のスキル
00-andruia-consultant
48kエージェントがAIプロジェクトの立ち上げや改善を支援します。コードを分析し、ツールを提案し、スペイン語で行動計画を作成します。
007
48kエージェントがセキュリティ監査と脅威モデリングを行えるようにします。攻撃や脆弱性からプロジェクトを守るのに役立ちます。
10-andruia-skill-smith
48kエージェントがAIツールの作成や改善を支援します。ツールの動作を定義し、ドキュメントを書き、構造を検証します。
20-andruia-niche-intelligence
48kエージェントが特定の業界に関する要約を作成できるようにします。信頼できる情報源を使って、プロジェクトの背景、ルール、利用パターン、リスクを把握するのに役立ちます。
似ているスキル
add-model-provider
394k安全なセットアップコマンドで新しいAIモデルプロバイダーをOpenClawに接続し、APIキーを平文で残さず、ライブテストを行うようエージェントを支援します。
acp-router
394kClaude CodeやCursorなどのコーディングアシスタントに、OpenClaw経由でタスクを渡し、その作業がそのツール内で行われるようエージェントを支援します。
browser-automation
394kログイン、タブ、応答しなくなったページからの復旧を含め、Webページを段階的に操作するようエージェントに教えます。