본문으로 건너뛰기
Skillpedia
에이전트41k · #6733

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/wshobson/agents/blob/main/plugins/llm-finetuning/skills/lora-qlora-recipes/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“채팅 모델에 랭크 32와 알파 64로 LoRA를 설정해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

도구는 조정할 AI 모델의 부분(모듈)을 고르고, 학습을 조절하는 '랭크'와 '알파' 매개변수, 학습률을 설정합니다. 과정을 최적화하기 위해 권장 설정을 사용합니다.

기술 내용 (원본 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는 양자화라는 추가 기법을 써서 메모리 사용량을 더 줄입니다. 모델이 사용 가능한 메모리에 맞지 않을 만큼 클 때 유용합니다.

'랭크'와 '알파'란 무엇인가요?

미세 조정의 학습 능력을 조절하는 매개변수입니다. '랭크'는 조정의 복잡도를, '알파'는 조정의 강도와 관련이 있습니다. 보통 알파는 랭크의 두 배로 설정합니다.

상세 정보

작성자의 원본 설명

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.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬