unsloth-finetuning
ما الذي تفعله
تساعد هذه المهارة على تدريب نماذج الذكاء الاصطناعي على حاسوب واحد ذي ذاكرة فيديو (VRAM) محدودة. تجعل التدريب أسرع وتستهلك ذاكرة أقل، مما يتيح تخصيص نماذج كانت تحتاج من قبل إلى حواسيب قوية جدًا.
متى تستخدمها
- ✓عندما تريد تدريب نموذج ذكاء اصطناعي على حاسوبك وذاكرة الفيديو محدودة.
- ✓عندما يفشل التدريب بسبب مشكلات الذاكرة وتحتاج إلى تعديله.
- ✓عندما تريد تصدير نموذج مدرّب إلى صيغة محددة (GGUF أو vLLM).
رابط المهارة
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/unsloth-finetuning/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“كيف أدرّب النموذج «unsloth/Qwen3-8B» باستخدام 16 غيغابايت فقط من VRAM، وأصدّره بصيغة GGUF؟”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تعمل المهارة بتحسين استخدام 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 هي ذاكرة مخصصة في كرت الرسوميات. تحتاج نماذج الذكاء الاصطناعي إلى كمية كبيرة منها للتدريب، وتساعد هذه المهارة على استخدام قدر أقل منها.
ما هما LoRA وQLoRA؟
هما تقنيتان تتيحان تدريب جزء صغير فقط من نموذج الذكاء الاصطناعي، مما يوفر ذاكرة ووقتًا كبيرين. وQLoRA نسخة أكثر توفيرًا للذاكرة.
ما هو «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
التعليقات
- …
المزيد من المهارات من هذا المستودع
00-andruia-consultant
48kيساعد وكيلك على بدء مشاريع الذكاء الاصطناعي أو تحسينها. يحلل الكود ويقترح الأدوات ويُعد خطط عمل بالإسبانية.
007
48kيتيح لوكيلك إجراء تدقيقات أمنية ونمذجة التهديدات. مفيد لحماية المشاريع من الهجمات والثغرات الأمنية.
10-andruia-skill-smith
48kيساعد وكيلك على إنشاء أدوات الذكاء الاصطناعي أو تحسينها. يحدد طريقة عملها، ويكتب توثيقها، ويتحقق من بنيتها.
20-andruia-niche-intelligence
48kيتيح لوكيلك إعداد ملخص عن صناعة محددة. مفيد لفهم السياق والقواعد وأنماط الاستخدام والمخاطر لمشروع ما، باستخدام مصادر موثوقة.
مهارات مشابهة
add-model-provider
394kتتيح لوكيلك ربط مزوّد نموذج ذكاء اصطناعي جديد بـ OpenClaw باستخدام أوامر إعداد آمنة، وإبقاء مفاتيح API خارج النص العادي، وإجراء اختبار حي.
acp-router
394kيساعد وكيلك على إرسال مهمة إلى مساعد برمجة مثل Claude Code أو Cursor عبر OpenClaw، فيعمل العمل داخل تلك الأداة.
browser-automation
394kتعلّم وكيلك التحكم في صفحات الويب خطوة بخطوة، بما في ذلك تسجيل الدخول والتبويبات والتعافي عندما تتوقف الصفحة عن الاستجابة.