davila7/claude-code-templates/fine-tuning-peft
Claude Code and agent skill by davila7/claude-code-templates
- community
Checking that the SKILL.md file is still in the repository.
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.
Install
npx vskill@latest install davila7/claude-code-templates/fine-tuning-peftSKILL.md
PEFT (Parameter-Efficient Fine-Tuning)
Fine-tune LLMs by training <1% of parameters using LoRA, QLoRA, and 25+ adapter methods.
When to use PEFT
Use PEFT/LoRA when:
- Fine-tuning 7B-70B models on consumer GPUs (RTX 4090, A100)
- Need to train <1% parameters (6MB adapters vs 14GB full model)
- Want fast iteration with multiple task-specific adapters
- Deploying multiple fine-tuned variants from one base model
Use QLoRA (PEFT + quantization) when:
- Fine-tuning 70B models on single 24GB GPU
- Memory is the primary constraint
- Can accept ~5% quality trade-off vs full fine-tuning
Use full fine-tuning instead when:
- Training small models (<1B parameters)
- Need maximum quality and have compute budget
- Significant domain shift requires updating all weights
Quick start
Installation
LoRA fine-tuning (standard)
QLoRA fine-tuning (memory-efficient)
LoRA parameter selection
Rank (r) - capacity vs efficiency
| Rank | Trainable Params | Memory | Quality | Use Case | |
|---|---|---|---|---|---|
| 4 | ~3M | Minimal | Lower | Simple tasks, prototyping | |
| 8 | ~7M | Low | Good | Recommended starting point | |
| 16 | ~14M | Medium | Better | General fine-tuning | |
| 32 | ~27M | Higher | High | Complex tasks | |
| 64 | ~54M | High | Highest | Domain adaptation, 70B models |
Alpha (lora_alpha) - scaling factor
Target modules by architecture
Loading and merging adapters
Load trained adapter
Merge adapter into base model
Multi-adapter serving
PEFT methods comparison
| Method | Trainable % | Memory | Speed | Best For | |
|---|---|---|---|---|---|
| LoRA | 0.1-1% | Low | Fast | General fine-tuning | |
| QLoRA | 0.1-1% | Very Low | Medium | Memory-constrained | |
| AdaLoRA | 0.1-1% | Low | Medium | Automatic rank selection | |
| IA3 | 0.01% | Minimal | Fastest | Few-shot adaptation | |
| Prefix Tuning | 0.1% | Low | Medium | Generation control | |
| Prompt Tuning | 0.001% | Minimal | Fast | Simple task adaptation | |
| P-Tuning v2 | 0.1% | Low | Medium | NLU tasks |
IA3 (minimal parameters)
Prefix Tuning
Integration patterns
With TRL (SFTTrainer)
With Axolotl (YAML config)
With vLLM (inference)
Performance benchmarks
Memory usage (Llama 3.1 8B)
| Method | GPU Memory | Trainable Params | |
|---|---|---|---|
| Full fine-tuning | 60+ GB | 8B (100%) | |
| LoRA r=16 | 18 GB | 14M (0.17%) | |
| QLoRA r=16 | 6 GB | 14M (0.17%) | |
| IA3 | 16 GB | 800K (0.01%) |
Training speed (A100 80GB)
| Method | Tokens/sec | vs Full FT | |
|---|---|---|---|
| Full FT | 2,500 | 1x | |
| LoRA | 3,200 | 1.3x | |
| QLoRA | 2,100 | 0.84x |
Quality (MMLU benchmark)
| Model | Full FT | LoRA | QLoRA | |
|---|---|---|---|---|
| Llama 2-7B | 45.3 | 44.8 | 44.1 | |
| Llama 2-13B | 54.8 | 54.2 | 53.5 |
Common issues
CUDA OOM during training
Adapter not applying
Quality degradation
Best practices
- Start with r=8-16, increase if quality insufficient
- Use alpha = 2 * rank as starting point
- Target attention + MLP layers for best quality/efficiency
- Enable gradient checkpointing for memory savings
- Save adapters frequently (small files, easy rollback)
- Evaluate on held-out data before merging
- Use QLoRA for 70B+ models on consumer hardware
References
- [Advanced Usage](references/advanced-usage.md) - DoRA, LoftQ, rank stabilization, custom modules
- [Troubleshooting](references/troubleshooting.md) - Common errors, debugging, optimization
Resources
- GitHub: https://github.com/huggingface/peft
- Docs: https://huggingface.co/docs/peft
- LoRA Paper: arXiv:2106.09685
- QLoRA Paper: arXiv:2305.14314
- Models: https://huggingface.co/models?library=peft
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingcli-tool/components/skills/ai-research/fine-tuning-peft/SKILL.md
Popularity
- Repository stars
- 30,755
- Repository forks
- 3,491
- Repository npm downloads, 7 days
- 1,736
- 7-day trend score
- 71
Stars and forks are for the whole GitHub repository, not this skill alone. Downloads are for the repository's npm package. Refreshed 16 Sep 2026, a month ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/davila7/claude-code-templates/fine-tuning-peft)