Quant Memo
Advanced

Adapter Modules and Prefix Tuning

Two ways to specialize a huge pretrained model for a new task by training a tiny number of new parameters instead of touching the model's original weights at all.

Prerequisites: The Self-Attention Mechanism

Fully fine-tuning a large language model for every new task means storing and updating a full copy of all its weights — billions of parameters — per task, which is expensive and makes it hard to serve many tasks from one base model. Adapter modules and prefix tuning are two answers to the same problem: freeze the pretrained model entirely, and add a small number of new, trainable parameters that steer its behavior.

An adapter is a tiny extra layer (often a bottleneck: shrink the dimension, then expand it back) inserted inside each transformer block; only these small layers get trained, often under 5% of the original parameter count. Prefix tuning takes a different route: instead of adding layers, it prepends a set of trainable "virtual tokens" to the input at every attention layer, which the frozen model attends to as if they were real context — effectively learning a task-specific prompt the model can't ignore, without writing any English words at all.

Both methods get task-specific behavior from a frozen, shared base model by training only a small add-on — adapters insert new layers inside the network, prefix tuning inserts new "tokens" at the input of each layer — letting one base model serve many tasks by swapping in a small, cheap module per task instead of many full copies.

Worked example. A 7-billion-parameter model fully fine-tuned for 10 different tasks would require storing 10 full 7B-parameter copies. Using adapters with a bottleneck of a few million trainable parameters each, the same 10 tasks need one shared 7B base plus 10 small adapter files — cutting total storage by well over 99% while reaching accuracy close to full fine-tuning on many benchmarks.

Related concepts

Further reading

  • Houlsby et al., 'Parameter-Efficient Transfer Learning for NLP'
  • Li & Liang, 'Prefix-Tuning: Optimizing Continuous Prompts for Generation'
ShareTwitterLinkedIn