मुख्य सामग्री पर जाएँ
Skillpedia
एजेंट41k · #6733

lora-qlora-recipes

यह क्या करती है

यह टूल LoRA और QLoRA नाम की तकनीकों से AI मॉडल की ट्रेनिंग सेट करने में मदद करता है। यह आप क्या सिखाना चाहते हैं, उसके आधार पर सबसे अच्छे पैरामीटर सेट करता है।

कब इस्तेमाल करें

  • ✓जब आप AI मॉडल को किसी खास तरीके से व्यवहार करना सिखाना चाहते हों।
  • ✓जब आप किसी खास काम के लिए AI मॉडल को फाइन-ट्यून करना चाहते हों।
  • ✓जब आपको LoRA, QLoRA या फुल फाइन-ट्यूनिंग में से चुनना हो।

Skill का लिंक

https://github.com/wshobson/agents/blob/main/plugins/llm-finetuning/skills/lora-qlora-recipes/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/wshobson/agents/blob/main/plugins/llm-finetuning/skills/lora-qlora-recipes/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे चैट मॉडल के लिए LoRA सेट करो, rank 32 और alpha 64 के साथ।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह टूल तय करता है कि AI मॉडल के किन हिस्सों (modules) को बदलना है, 'rank' और 'alpha' पैरामीटर सेट करता है (जो सीखने को नियंत्रित करते हैं), और learning rate भी। यह ऑप्टिमाइज़ेशन के लिए सुझाई गई सेटिंग्स का इस्तेमाल करता है।

तकनीकी सामग्री (मूल 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 * r is 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_state fixed — 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 क्या हैं?

ये AI मॉडल को कुशलता से फाइन-ट्यून करने की तकनीकें हैं। इनमें मॉडल के सिर्फ एक छोटे हिस्से में बदलाव किया जाता है, जिससे समय और कंप्यूटर संसाधन दोनों बचते हैं।

LoRA और QLoRA में क्या फर्क है?

QLoRA एक अतिरिक्त तकनीक (quantization) का इस्तेमाल करता है, जिससे मेमोरी का उपयोग और कम हो जाता है। यह तब काम आता है जब मॉडल उपलब्ध मेमोरी में फिट नहीं होता।

'rank' और 'alpha' क्या हैं?

ये फाइन-ट्यूनिंग की सीखने की क्षमता को नियंत्रित करने वाले पैरामीटर हैं। 'rank' बदलाव की जटिलता तय करता है, और 'alpha' उस बदलाव की ताकत से जुड़ा है। आम तौर पर alpha, rank का दोगुना रखा जाता है।

जानकारी

लेखक का मूल विवरण

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
अपडेट की गई
15/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills