peft-fine-tuning

Fine-tune LLMs with LoRA, QLoRA, and adapter methods training under 1% of parameters.

1|Updated Mar 5, 2026
One-click install
npx skills add https://github.com/Clay-HHK/claude-skills --skill peft-fine-tuning-clay-hhk
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: peft-fine-tuning
Source: https://github.com/Clay-HHK/claude-skills/tree/main/peft
Command: npx skills add https://github.com/Clay-HHK/claude-skills --skill peft-fine-tuning-clay-hhk

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires peft, transformers, torch, bitsandbytes, and includes references (resource) components.

What problem does it solve? Full fine-tuning of large language models (7B-70B) requires enormous GPU memory and produces multi-gigabyte checkpoints, making it impractical on consumer hardware. This Skill guides parameter-efficient fine-tuning with HuggingFace PEFT so you can train adapters of only a few megabytes while keeping the base model frozen. ## Core Features & Use Cases - LoRA and QLoRA workflows: Configure rank, alpha, dropout, and target modules, with 4-bit NF4 quantization via bitsandbytes to fit a 70B model on a single 24GB GPU. - 25+ PEFT methods: Includes AdaLoRA, IA3, Prefix Tuning, Prompt Tuning, DoRA, LoftQ, and rsLoRA with guidance on when each method fits. - Multi-adapter serving and merging: Load, switch, compose, and merge adapters at runtime, with integration patterns for TRL, Axolotl, and vLLM. - Use Case: Fine-tune Llama-3.1-8B on an instruction dataset with LoRA r=16, producing a 6MB adapter instead of a 16GB checkpoint, then merge it for deployment or serve multiple task adapters from one base model. ## Quick Start Ask the assistant to set up a LoRA fine-tuning script for your chosen base model and dataset, specifying rank, target modules, and whether to use 4-bit QLoRA quantization.

Frequently Asked Questions about peft-fine-tuning

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fine-tune a Llama model with LoRA?▼

Load the base model with transformers, create a LoraConfig with rank r=16, lora_alpha=32, and target_modules covering attention projections, then wrap the model with get_peft_model. Train with the standard Trainer and save only the adapter weights, which are a few megabytes instead of gigabytes.

What is the difference between LoRA and QLoRA?▼

QLoRA combines LoRA adapters with 4-bit NF4 quantization of the base model via bitsandbytes, cutting memory from around 18GB to 6GB for an 8B model. Use QLoRA when memory is the primary constraint, accepting roughly a 5% quality trade-off versus standard LoRA.

How do I choose the LoRA rank and alpha values?▼

Start with rank r=8 or r=16 for general fine-tuning and increase to 32-64 for complex tasks or 70B models. Set lora_alpha to twice the rank as a baseline, and target attention plus MLP layers for the best quality-to-efficiency balance.

Can I serve multiple LoRA adapters from one base model?▼

Yes, PEFT supports loading multiple adapters with load_adapter and switching between them at runtime using set_adapter. For production serving, vLLM supports concurrent LoRA requests via LoRARequest with configurable max_loras.

Why does LoRA training run out of CUDA memory?▼

OOM usually comes from large batch sizes, missing gradient checkpointing, or targeting too many modules. Enable gradient checkpointing with prepare_model_for_kbit_training, reduce per-device batch size with gradient accumulation, or switch to QLoRA with 4-bit quantization.

When should I use full fine-tuning instead of PEFT?▼

Full fine-tuning is preferable for small models under 1B parameters, when maximum quality is required with sufficient compute budget, or when significant domain shift demands updating all weights. PEFT trades a small quality margin for drastically lower memory and storage costs.