peft-fine-tuning

Fine-tune large language models using LoRA, QLoRA, and other parameter-efficient adapter methods.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Full fine-tuning of 7B-70B parameter LLMs requires enormous GPU memory and produces multi-gigabyte model copies, making customization impractical on consumer hardware. This Skill enables training less than 1% of parameters with minimal accuracy loss, so a 70B model can be fine-tuned on a single 24GB GPU. ## Core Features & Use Cases - LoRA and QLoRA Fine-Tuning: Train low-rank adapters on attention and MLP layers, with optional 4-bit NF4 quantization for memory-constrained environments. - 25+ PEFT Methods: Includes AdaLoRA, IA3, Prefix Tuning, Prompt Tuning, DoRA, LoftQ, and rsLoRA with guidance on rank, alpha, and target module selection. - Multi-Adapter Serving: Load, switch, merge, and compose multiple adapters on one base model, with integration patterns for TRL, Axolotl, and vLLM. - Use Case: Fine-tune Llama 3.1 8B on the Dolly-15k instruction dataset using LoRA r=16 on a single RTX 4090, producing a 6MB adapter instead of a 16GB model copy. ## Quick Start Fine-tune Llama 3.1 8B with LoRA rank 16 on my instruction dataset and save the adapter weights to a local directory.

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 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, 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, drastically reducing memory usage. LoRA on an 8B model needs about 18GB of GPU memory while QLoRA needs about 6GB, with roughly a 5% quality trade-off.

What LoRA rank should I use for fine-tuning?

Start with rank 8 to 16 for general fine-tuning, which trains around 7-14M parameters on an 8B model. 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 on 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 with enable_lora=True and configurable max_loras.

Why am I getting CUDA out of memory during LoRA training?

Enable gradient checkpointing with prepare_model_for_kbit_training, reduce per-device batch size while increasing gradient accumulation steps, or switch to QLoRA with 4-bit quantization. Lowering the LoRA rank and targeting fewer modules also reduces memory.

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

Use full fine-tuning for models under 1B parameters, when maximum quality is required and compute budget is available, or when significant domain shift requires updating all weights. PEFT is better for large models and memory-constrained environments.