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

unsloth-finetuning

하는 일

메모리가 제한된 한 대의 컴퓨터에서 AI 모델을 학습하도록 돕는 도구입니다. 학습을 더 빠르게 하고 메모리를 덜 쓰게 해서, 이전에는 아주 강력한 컴퓨터에서만 학습할 수 있던 AI 모델을 맞춤 설정할 수 있게 합니다.

사용하는 경우

  • ✓내 컴퓨터에서 AI 모델을 학습하고 싶은데 VRAM이 제한적일 때.
  • ✓메모리 문제로 학습이 실패해 설정을 조정해야 할 때.
  • ✓학습된 모델을 특정 형식(GGUF, vLLM)으로 내보내고 싶을 때.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/unsloth-finetuning/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

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

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

AI에게 요청하는 예시

“16GB VRAM만 사용해 'unsloth/Qwen3-8B' 모델을 학습하고, GGUF 형식으로 내보내려면 어떻게 해야 하나요?”

매주 새 스킬 5개. 읽는 데 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은 무엇이고 왜 중요한가요?

그래픽 카드에 있는 전용 메모리입니다. AI 모델은 학습하는 데 많은 VRAM이 필요하며, 이 도구는 VRAM을 덜 쓰도록 돕습니다.

LoRA와 QLoRA는 무엇인가요?

AI 모델의 아주 작은 부분만 학습하게 해서 메모리와 시간을 크게 아끼는 기법입니다. QLoRA는 메모리를 더 효율적으로 쓰는 버전입니다.

'채팅 템플릿'은 무엇인가요?

AI 모델이 대화가 어떻게 구성되어야 하는지 이해하는 데 쓰는 형식입니다. 잘못된 채팅 템플릿은 모델이 잘못된 응답을 만들게 할 수 있습니다.

상세 정보

작성자의 원본 설명

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.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#6066
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬