Notes

Adapter Layers

You have a 7-billion-parameter model that is good at everything and excellent at nothing you need. Full fine-tuning means updating all 7 billion weights and storing a complete second copy of the model for every task. Adapter layers avoid that: freeze the original and insert small trainable modules between its layers.

What gets inserted

An adapter is a tiny bottleneck network — a down-projection to a few dozen dimensions, a nonlinearity, an up-projection back — placed after the attention and feed-forward sub-blocks of each transformer layer. It is initialised near the identity, so the model behaves exactly as before at the start of training and then learns a small correction. Fewer than 1% of the parameters are trainable.

Why that is useful
  • Training memory collapses, because gradients and optimizer state exist only for the adapter weights.
  • Each task ships as a few megabytes alongside one shared frozen base, instead of a full model copy.
  • Adapters are trained independently and swapped at serving time, so tasks cannot degrade one another.
The cost, and the alternative

Adapters add real layers to the forward pass, so every token pays a small latency tax that no kernel can optimize away. That is precisely why LoRA — which learns a low-rank update to existing weight matrices and can be folded back into them before serving — has largely displaced the classic bottleneck adapter in large-model work. The idea survives inside it: train something small, leave the pretrained weights alone. Hugging Face's PEFT library exposes both behind one interface.

Adapter layers are small trainable bottleneck modules inserted into a frozen pretrained model, so adapting it to a task updates under 1% of its parameters. They cut fine-tuning memory sharply and let one shared base serve many tasks, each stored as a few megabytes of adapter weights rather than a full model copy. The cost is extra layers in the forward pass, a permanent latency penalty that LoRA avoids by merging its update into the existing weights.

Picture a well-trained chef who cooks in one style. Rather than sending them back to culinary school, you hand them a short set of notes to glance at for each new cuisine. The chef is unchanged; the notes do the adjusting. Adapter layers are those notes for a language model. The original model is left completely untouched, and only a very small add-on is trained for the new job. That add-on is tiny enough to email, and you can keep a different one for every task — customer support, legal summaries, medical questions — all sharing a single underlying model.