lora-qlora-recipes
できること
このツールは、LoRAとQLoRAという手法を使ったAIモデルの学習設定を支援します。学習させたい内容に基づいて、ファインチューニングに最適なパラメーターを設定します。
使う場面
- ✓AIモデルに特定の振る舞いを教えたいとき。
- ✓特定のタスク向けにAIモデルをファインチューニングしたいとき。
- ✓LoRA、QLoRA、フルファインチューニングのどれを選ぶか決めたいとき。
スキルのリンク
https://github.com/wshobson/agents/blob/main/plugins/llm-finetuning/skills/lora-qlora-recipes/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“チャットモデル用にLoRAを設定してください。rankは32、alphaは64でお願いします。”
毎週5つの新しいスキル。1分で読めます。
仕組み
ツールは、調整するAIモデルの部分(モジュール)を選び、学習を制御する「rank」と「alpha」のパラメーター、そして学習率を設定します。推奨設定を使って処理を最適化します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
LoRA & QLoRA Recipes
This skill assumes the routing decision already
happened — finetuning-method-selection should
have already pointed here because the data shape
is demonstrations (SFT), not preference pairs or
a verifiable reward signal. What follows is the
current best-practice recipe for configuring the
adapter itself: which modules to target, how to
size rank and alpha, what learning rate to use,
and when QLoRA buys real headroom versus when it
just adds risk. Dataset preparation and quality
checks are a separate concern — see
dataset-curation.
Input: a routing decision (SFT via LoRA/
QLoRA) plus a target size class.
Output format: a validated adapter config —
the kwarg values below, not free-form advice —
that llm-finetuning-training-engineer consumes
directly when it generates a runnable script.
The Reference Recipe
The reference recipe is "LoRA Without Regret" (Thinking Machines/Schulman, 2025-09), now the settled convention for LoRA/QLoRA SFT.
Target Modules
Target all-linear modules, not just attention:
target_modules = [
"q_proj", "k_proj", "v_proj", "o_proj", # attention
"gate_proj", "up_proj", "down_proj", # MLP — matters most
]
The MLP layers (gate_proj, up_proj,
down_proj) matter most — attention-only
targeting was the older, weaker convention.
Dropping modules to save memory is a Failure
Mode below, not a valid optimization.
Alpha and Learning Rate
lora_alpha = 2 * ris the settled convention (NeurIPS 2025 "intruder dimensions" result). Don't hand-tune alpha independently of rank — derive it from rank every time.- LoRA learning rate ≈ 10x the equivalent
full-fine-tune LR. For QLoRA specifically,
2e-4 is the standard starting point. Full
hyperparameter tables and worked examples:
references/hyperparameters.md.
Rank by Task
Rank is task-shaped, not a single global default:
| Task | Rank |
|---|---|
| RL (GRPO/RLVR adapters) | 1–32 |
| General default | 16–32 |
| SFT at scale | up to ~256 |
Higher rank isn't automatically better — it raises capacity to memorize as fast as it raises capacity to generalize. Start at the row matching the task, and only move up a row if the lower rank measurably underfits on held-out eval, not as a default hedge.
Effective Batch Size
Keep effective batch size under 32. This recipe was validated at that scale — pushing effective batch higher is an untested extrapolation, not a free throughput win.
Unsloth Defaults
Unsloth is the reference implementation this
plugin assumes as the default fast path — except
for messages-shaped conversational SFT with
assistant_only_loss=True, where Unsloth
2026.7.x's compiled trainer has no messages-shaped
path at all and the plain-TRL escape hatch
(references/unsloth-trl-mapping.md) is the
default for that combination, not a rare-regression
fallback. Its out-of-the-box defaults, and why
each one is set that way:
lora_dropout=0— the optimized kernel path assumes zero dropout; setting a nonzero value forfeits the fused-kernel speedup.bias="none"— bias terms add adapter parameters for negligible quality gain at this rank range.use_gradient_checkpointing="unsloth"— Unsloth's checkpointing variant, not vanilla HF checkpointing; saves roughly 30% VRAM over no checkpointing.optim="adamw_8bit"— 8-bit AdamW cuts optimizer-state memory with negligible quality impact at LoRA/QLoRA adapter scale.random_statefixed — pins LoRA initialization for reproducibility across runs; treat it like any other seed, not a tunable.
These show up together on the get_peft_model
call:
model = FastLanguageModel.get_peft_model(
model,
r=32,
target_modules=target_modules,
lora_alpha=64, # 2 * r
lora_dropout=0,
bias="none",
use_gradient_checkpointing="unsloth",
random_state=3407,
)
Exact kwarg names and their plain-TRL/PEFT
equivalents, plus a full worked config including
SFTConfig: references/unsloth-trl-mapping.md
and references/hyperparameters.md.
LoRA vs QLoRA vs Full FT
| Situation | Default choice |
|---|---|
| Adapting behavior on demonstrations | LoRA |
| Base model doesn't fit in bf16 at target rank | QLoRA |
| Injecting dense new domain knowledge | Full FT (see finetuning-method-selection) |
| Unsure which one | LoRA — upgrade to QLoRA only if memory forces it |
…
よくある質問
LoRAとQLoRAとは何ですか?
モデルの小さな一部だけを変更して効率よくファインチューニングする手法で、時間と計算資源を節約できます。
LoRAとQLoRAの違いは何ですか?
QLoRAは量子化という追加の技術を使ってメモリ使用量をさらに減らします。モデルが利用可能なメモリに収まらないほど大きい場合に役立ちます。
「rank」と「alpha」とは何ですか?
ファインチューニングの学習能力を制御するパラメーターです。「rank」は調整の複雑さを、「alpha」はその調整の強さを表します。一般的に、alphaはrankの2倍に設定します。
詳細
作者による元の説明
Configure LoRA and QLoRA supervised fine-tuning with current best-practice hyperparameters. Use when writing or reviewing a LoRA/QLoRA training configuration, choosing rank/alpha/target modules, or deciding between LoRA, QLoRA, and full fine-tuning.
repo: wshobson/agents
人気
- GitHubのスター
- 41k
- ランキング
- #6733
- ライセンス
- MIT
- 更新日
- 2026/10/15
コメント
- …
このリポジトリの他のスキル
screen-reader-testing
41kエージェントにスクリーンリーダーを使ってWebサイトをテストさせ、アクセシビリティを確認します。
wcag-audit-patterns
41kエージェントがWebサイトのアクセシビリティを監査し、WCAGガイドラインに沿って問題を修正できるようにします。
multi-reviewer-patterns
41kエージェントが複数のコードレビューを並行して調整できるようにします。指摘事項の重複を排除し、レポートにまとめます。
parallel-debugging
41kエージェントが並行調査と根本原因分析を使って、複雑な問題をデバッグできるようにします。
似ているスキル
add-model-provider
394k安全なセットアップコマンドで新しいAIモデルプロバイダーをOpenClawに接続し、APIキーを平文で残さず、ライブテストを行うようエージェントを支援します。
acp-router
394kClaude CodeやCursorなどのコーディングアシスタントに、OpenClaw経由でタスクを渡し、その作業がそのツール内で行われるようエージェントを支援します。
browser-automation
394kログイン、タブ、応答しなくなったページからの復旧を含め、Webページを段階的に操作するようエージェントに教えます。