← Master Index
Vol. 12 Module 12.4 Capstone

Adapters

Fine-Tuning Deep Dive — Volume 12 Capstone

How This Lesson Fits the Module & Volume

This Volume 12 capstone unifies bottleneck adapter modules (Houlsby/Pfeiffer-style) with the PEFT zoo you just studied—LoRA, AdaLoRA, QLoRA, IA3, prefix, and prompt tuning—versus full FT and SFT. It also closes the loop to Vol. 11 PEFT / fine-tuning.

Volume 12 moved from tokenization and embeddings through inference optimization to specialization. Volume 13 opens with prompting practice—discrete control complementary to the soft/weight adapters here.

Learning Objectives

By the end of this lesson, students should be able to:

  • Describe classic serial bottleneck adapters (down-project → nonlinearity → up-project).
  • Place adapters among LoRA, IA3, and soft-prompt methods.
  • Choose full FT vs PEFT for a deployment scenario.
  • Configure adapter-style PEFT and sketch multi-adapter serving.
  • Summarize Module 12.3–12.4 as a train/serve specialization stack.
  • Preview how Vol. 13 prompting interacts with frozen specialized models.
Definition

An adapter (in the classic NLP sense) is a small bottleneck module inserted into Transformer blocks—typically after attention and/or feed-forward sublayers—while the original weights stay frozen. More broadly, “adapters” also denote the whole PEFT family of swappable task packs (LoRA included). This lecture covers both the historical module and the comparative map.

Bottleneck Adapter Anatomy

Down

d → r projection

Nonlinearity

e.g., ReLU / GELU

Up

r → d projection

Residual

Add back to stream

import torch from torch import nn class BottleneckAdapter(nn.Module): def __init__(self, d_model: int, bottleneck: int = 64): super().__init__() self.down = nn.Linear(d_model, bottleneck) self.act = nn.ReLU() self.up = nn.Linear(bottleneck, d_model) def forward(self, x): return x + self.up(self.act(self.down(x))) # residual adapter # PEFT also exposes AdapterConfig / LoRA as modern drop-in alternatives: # from peft import LoraConfig, get_peft_model # most common LLM path today

PEFT Comparison Map

MethodMechanismTypical useVs full FT
Full FTUpdate all WMax capacity / big shiftBaseline cost
SFT (+ any)Demo CE objectiveInstruction followingObjective, not PEFT
Bottleneck adapterInserted MLP residualMulti-task NLPTiny modules
LoRA / AdaLoRALow-rank ΔWDefault LLM SFTSmall files; Ada reallocates r
QLoRA4-bit base + LoRAConsumer GPU SFTVRAM win
IA3Activation scalesUltra-light packsTiny vectors
Prefix / promptSoft tokensFrozen-backbone tasksContext tax

Serving Many Specialists

One full FT each

  • N model copies.
  • Huge disk / RAM.
  • Hard hot-swap.

One base + N adapters

  • Share frozen weights.
  • Load task pack on demand.
  • Matches multi-tenant SaaS.

Inference link

  • Module 12.3 KV / batching.
  • Prefix cache ≠ PEFT prefix.
  • Adapters change activations.

Decision Guide

SituationPrefer
Single specialist, unlimited GPUs, large shiftFull FT (or high-capacity LoRA)
Standard open LLM instruction tune on 1–2 GPUsQLoRA / LoRA SFT
Hundreds of task variants, tiny storageIA3 / prompt tuning / adapters
Uneven layer needs, tight budgetAdaLoRA
Must not touch weights; API-only modelDiscrete prompting (Vol. 13)

Strengths and Tradeoffs (Adapter Family)

Strengths

  • Modular specialization without full copies.
  • Lower forgetting risk than aggressive full FT.
  • Composes with SFT and preference tuning.

Tradeoffs

  • Inductive bias may underfit extreme shifts.
  • Routing / merging ops add engineering.
  • Naming collision: “adapter” vs LoRA colloquially.
Common Misconception

“Inference prefix cache is the same as prefix tuning.” Prefix cache reuses KV for identical token prefixes at serve time. Prefix tuning learns continuous PEFT parameters. Related vocabulary, different layers of the stack.

Knowledge Check

  1. Short Answer: What is a classic bottleneck adapter? Answer: A small down-up MLP residual inserted in Transformer blocks with frozen base weights.
  2. True/False: LoRA is often called an adapter method in the broad PEFT sense. Answer: True.
  3. Multiple Choice: Best default for 7B SFT on one GPU: (a) QLoRA, (b) train from scratch, (c) only CSS. Answer: (a).
  4. Short Answer: Why do multi-tenant products prefer adapters over full FT copies? Answer: Share one base; store/swap small task packs.
  5. True/False: SFT describes the objective; adapters describe parameterization. Answer: True.
  6. Multiple Choice: IA3 primarily: (a) rescales activations, (b) rebuilds tokenizers, (c) batches HTTP. Answer: (a).
  7. Short Answer: Name one Module 12.3 technique that raises serve throughput. Answer: Continuous batching / Flash Attention / KV paging / speculation / prefix cache (any).
  8. True/False: Prefix cache and prefix tuning are identical. Answer: False.
  9. Multiple Choice: Volume 13 starts with: (a) basic prompting, (b) CUDA drivers only, (c) CNNs. Answer: (a).
  10. Short Answer: When might full FT still beat PEFT? Answer: Large domain shift with enough compute / need maximum capacity.

Key Takeaways

  • Adapters (narrow and broad) specialize frozen backbones cheaply.
  • Pick LoRA/QLoRA for most LLM SFT; IA3/prompts for ultra-light packs; full FT for ceilings.
  • SFT is the usual objective layered on these parameterizations.
  • Serve-time optimizations (12.3) and train-time PEFT (12.4) compose.
  • Next volume: Basic Prompting.
Trainer’s Guide

Hands-on idea: Capstone lab—same SFT dataset with prompt tuning, LoRA, and (if VRAM allows) full FT; compare trainable params, disk, and quality.

Discussion prompt: Design a multi-tenant assistant: where do adapters live relative to continuous batching and prefix cache?

Recap: Adapters close Volume 12 by mapping PEFT choices against full FT and linking train-time specialization to serve-time systems. Continue to Vol. 13 Basic Prompting.