unsloth-finetuning
यह क्या करती है
यह टूल सीमित VRAM वाले एक ही कंप्यूटर पर AI मॉडल्स को ट्रेन करने में मदद करता है। यह ट्रेनिंग को तेज़ बनाता है और कम मेमोरी लेता है, जिससे वे AI मॉडल्स भी कस्टमाइज़ किए जा सकते हैं जिन्हें पहले सिर्फ़ बहुत शक्तिशाली कंप्यूटरों पर ट्रेन किया जा सकता था।
कब इस्तेमाल करें
- ✓जब आप अपने कंप्यूटर पर AI मॉडल ट्रेन करना चाहते हों और VRAM सीमित हो।
- ✓जब मेमोरी की समस्या से ट्रेनिंग फ़ेल हो जाए और उसे एडजस्ट करना हो।
- ✓जब ट्रेन किए गए मॉडल को किसी खास फ़ॉर्मेट (GGUF, vLLM) में एक्सपोर्ट करना हो।
Skill का लिंक
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/unsloth-finetuning/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मैं 'unsloth/Qwen3-8B' मॉडल को सिर्फ़ 16GB VRAM में कैसे ट्रेन करूँ और उसे GGUF फ़ॉर्मेट में एक्सपोर्ट कैसे करूँ?”
हर हफ़्ते 5 नई skills, 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 इसका और भी ज़्यादा मेमोरी-बचत वाला वर्शन है।
'chat template' क्या है?
यह वह फ़ॉर्मेट है जिससे AI मॉडल समझता है कि बातचीत कैसे व्यवस्थित होनी चाहिए। गलत 'chat template' से मॉडल गलत जवाब दे सकता है।
जानकारी
लेखक का मूल विवरण
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
- अपडेट की गई
- 15/10/2026
कमेंट
- …
इस repository की और skills
00-andruia-consultant
48kआपके एजेंट को AI प्रोजेक्ट शुरू करने या उन्हें बेहतर बनाने में मदद करता है। यह code का विश्लेषण करता है, tools सुझाता है और स्पेनिश भाषा में action plan बनाता है।
007
48kआपका एजेंट security audit और threat modeling करता है। यह प्रोजेक्ट को हमलों और कमजोरियों से बचाने में काम आता है।
10-andruia-skill-smith
48kआपके एजेंट को AI tools बनाने या उन्हें बेहतर करने में मदद करता है। यह तय करता है कि tools कैसे काम करेंगे, documentation लिखता है और structure की जांच करता है।
20-andruia-niche-intelligence
48kआपका एजेंट किसी खास industry का summary बनाता है। भरोसेमंद स्रोतों की मदद से यह प्रोजेक्ट का संदर्भ, नियम, इस्तेमाल के तरीके और जोखिम समझने में मदद करता है।
मिलती-जुलती skills
add-model-provider
394kयह आपके एजेंट को सुरक्षित कमांड से OpenClaw में नया AI मॉडल प्रोवाइडर जोड़ने, API कीज़ को सादे टेक्स्ट से बचाने और लाइव टेस्ट चलाने देती है।
acp-router
394kयह आपके एजेंट को OpenClaw के ज़रिए Claude Code या Cursor जैसे कोडिंग असिस्टेंट को काम भेजने देती है, ताकि काम उसी टूल में चले।
browser-automation
394kयह आपके एजेंट को लॉगिन, टैब और अटकी वेब पेज से उबरने समेत, वेबसाइट पर चरण-दर-चरण काम करना सिखाती है।