Fine-Tune Skill
Fine-tune language models efficiently with LoRA, QLoRA, or unsloth.
Quick start
# Prepare dataset
uv run ${CLAUDE_SKILL_DIR}/scripts/prepare_dataset.py data/raw.csv --format alpaca --output data/train.jsonl
# Fine-tune with LoRA (unsloth)
python3 -c "
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained('mistralai/Mistral-7B-v0.1', load_in_4bit=True)
model = FastLanguageModel.get_peft_model(model, r=16, lora_alpha=32, target_modules=['q_proj','v_proj'])
# ... training loop
"
Workflow
- Prepare dataset — convert to alpaca/sharegpt format via
scripts/prepare_dataset.py - Choose method — LoRA (parameter-efficient), QLoRA (memory-efficient), full (highest quality)
- Configure LoRA — set r, lora_alpha, target_modules
- Train — SFTTrainer with packing=True for efficiency
- Merge —
model.merge_and_unload()for deployment - Evaluate — perplexity, ROUGE-L, task benchmarks
See references/fine-tune-guide.md for complete LoRA/QLoRA/unsloth documentation.