# fine-tuning-peft

A skill that walks through fine-tuning large language models with LoRA, QLoRA and other adapter methods when GPU memory is tight.

- skill · `type=skill` · Claude Code · 71 installs
- Author: Orchestra Research
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/ai-research/fine-tuning-peft
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/fine-tuning-peft

## What it does

The skill covers training 7B–70B models while updating under 1% of the weights. It builds on HuggingFace's PEFT library, which plugs into the `transformers` stack. Adapters come out in megabytes rather than gigabytes, so keeping several task-specific variants of one base model is cheaper than keeping full copies.

You get working code samples: plain LoRA through `LoraConfig`, QLoRA with 4-bit quantization via `BitsAndBytesConfig`, loading and merging adapters, picking rank and `lora_alpha`, plus target module lists for Llama, Mistral, Qwen, GPT-2, Falcon and BLOOM. A rank table spans 4 to 64, and the guidance suggests starting at 8 or 16.

Dependencies are `peft>=0.13.0`, `transformers>=4.45.0`, `torch>=2.0.0` and `bitsandbytes>=0.43.0`. Skip the last one and quantization will not run. QLoRA targets a single 24GB card, at a cost of roughly 5% quality against full fine-tuning. For models under 1B parameters, or when the domain shift is large, the skill points you to full fine-tuning instead.

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --skill ai-research/fine-tuning-peft
```

2. **Skills CLI (Vercel)**
```bash
npx skills add davila7/claude-code-templates --skill fine-tuning-peft -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/fine-tuning-peft/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/fine-tuning-peft/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/fine-tuning-peft/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/fine-tuning-peft/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install davila7/claude-code-templates fine-tuning-peft
```

2. **Manually: put the files in place**
- File: `.github/skills/fine-tuning-peft/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/ai-research/fine-tuning-peft
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/fine-tuning-peft/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/ai-research/fine-tuning-peft

## When to use it
- fine-tune a 70B model on one GPU
- save an adapter of a few megabytes instead of a full model copy
- choose rank and alpha for a given task
- run several task adapters on top of one base model
- merge a trained adapter into the base model before deployment

## Example prompts
- Set up LoRA for `meta-llama/Llama-3.1-8B` with rank 16 and save only the adapter
- Show a 4-bit QLoRA config so a 70B model fits in 24GB of VRAM
- How do I merge the adapter in `./lora-llama-adapter` into the base model?

## Similar
- [skill-creator](https://affpapa.org/en/nevibecode/skills/skill-creator.md) — skill · 414180 installs
- [writing-for-agents](https://affpapa.org/en/nevibecode/skills/writing-for-agents.md) — skill · 466719 installs
- [media-use](https://affpapa.org/en/nevibecode/skills/media-use.md) — skill · 1100000 installs
- [mcp-builder](https://affpapa.org/en/nevibecode/skills/mcp-builder.md) — skill · 130949 installs
- [subagent-driven-development](https://affpapa.org/en/nevibecode/skills/subagent-driven-development.md) — skill · 237746 installs
- [orchestration](https://affpapa.org/en/nevibecode/skills/orchestration.md) — skill · 350300 installs

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 361 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
