peft-fine-tuning

Fine-tune LLMs with LoRA, QLoRA, and adapter methods using HuggingFace PEFT.

Updated Jun 7, 2026
One-click install
npx skills add https://github.com/Chensihakniroth/ANAKOT-AGENT --skill peft-fine-tuning-chensihakniroth
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: peft-fine-tuning
Source: https://github.com/Chensihakniroth/ANAKOT-AGENT/tree/main/optional-skills/mlops/peft
Command: npx skills add https://github.com/Chensihakniroth/ANAKOT-AGENT --skill peft-fine-tuning-chensihakniroth

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 parameters) requires expensive GPU clusters and produces multi-gigabyte checkpoints. This Skill enables parameter-efficient fine-tuning that trains less than 1% of model parameters, fitting 70B models on a single 24GB GPU and producing adapters of only a few megabytes. ## Core Features & Use Cases - LoRA and QLoRA Fine-Tuning: Train low-rank adapters on consumer GPUs, with 4-bit quantization support via bitsandbytes for memory-constrained environments. - 25+ PEFT Methods: Includes AdaLoRA, IA3, Prefix Tuning, Prompt Tuning, DoRA, and LoftQ with guidance on rank, alpha, and target module selection per architecture. - Multi-Adapter Serving: Load, switch, merge, and compose multiple adapters at runtime, with integration patterns for TRL, Axolotl, and vLLM. - Use Case: Fine-tune Llama 3.1 70B on a single RTX 4090 using QLoRA with rank 64, then serve three task-specific adapters from one base model in vLLM. ## Quick Start Fine-tune Llama 3.1 8B on my instruction dataset using LoRA with rank 16 and save the adapter to ./lora-adapter.

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 in Python?▼

Load the base model with transformers, create a LoraConfig specifying rank, alpha, and target modules like q_proj and v_proj, then wrap the model with get_peft_model. Train with the standard Trainer and save only the adapter weights with save_pretrained.

What is the difference between LoRA and QLoRA?▼

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

What LoRA rank should I use for fine-tuning?▼

Start with rank 8-16 for general fine-tuning, which trains about 0.17% of parameters. Use rank 32-64 for complex tasks, domain adaptation, or 70B models, and set lora_alpha to twice the rank as a starting point.

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

Yes, PEFT supports loading multiple adapters with load_adapter and switching at runtime via set_adapter. vLLM also supports concurrent LoRA requests using LoRARequest with enable_lora=True for batched multi-adapter inference.

Why does CUDA run out of memory during LoRA training?▼

OOM occurs from large batch sizes, missing gradient checkpointing, or unquantized base models. 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?▼

Use full fine-tuning for models under 1B parameters, when maximum quality is required with available compute, or when significant domain shift demands updating all weights. PEFT targets scenarios where training under 1% of parameters is acceptable.