peft-fine-tuning
Agent skill fromOpenRaiser/NanoResearch
Parameter-efficient fine-tuning for LLMs using LoRA, QLoRA, and 25+ methods. Use when fine-tuning large models (7B-70B) with limited GPU memory, when you need to train <1% of parameters with minimal accuracy loss, or for multi-adapter serving. HuggingFace's official library integrated with transformers ecosystem.
How to install peft-fine-tuning
install peft-fine-tuning
# install the NanoResearch pack with the skills CLI
npx skills add OpenRaiser/NanoResearch# or add only this skill to Claude Code: copy the folder
skills/vendor-ai-research/peft/
# into
~/.claude/skills/peft/ (all projects)
.claude/skills/peft/ (one project)
1# PEFT (Parameter-Efficient Fine-Tuning)23Fine-tune LLMs by training <1% of parameters using LoRA, QLoRA, and 25+ adapter methods.45## When to use PEFT67**Use PEFT/LoRA when:**8- Fine-tuning 7B-70B models on consumer GPUs (RTX 4090, A100)9- Need to train <1% parameters (6MB adapters vs 14GB full model)10- Want fast iteration with multiple task specific adapters11- Deploying multiple fine-tuned variants from one base model1213**Use QLoRA (PEFT + quantization) when:**14- Fine-tuning 70B models on single 24GB GPU15- Memory is the primary constraint16- Can accept ~5% quality trade-off vs full fine-tuning1718**Use full fine-tuning instead when:**19- Training small models (<1B parameters)20- Need maximum quality and have compute budget21- Significant domain shift requires updating all weights2223## Quick start2425### Installation2627```bash28# Basic installation29pip install peft3031# With quantization support (recommended)32pip install peft bitsandbytes3334# Full stack35pip install peft transformers accelerate bitsandbytes datasets36```3738### LoRA fine-tuning (standard)3940```python41from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments, Trainer42from peft import get_peft_model, LoraConfig, TaskType43from datasets import load_dataset4445# Load base model46model_name = "meta-llama/Llama-3.1-8B"47model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")48tokenizer = AutoTokenizer.from_pretrained(model_name)49tokenizer.pad_token = tokenizer.eos_token50…
Excerpt shown under the repository's MIT license.
