A bottleneck inserted into a frozen stack
- : projects down to a small width.
- : projects back up.
- : the bottleneck, typically 8 to 64 against a model width of 4,096.
Two small matrices and a nonlinearity are inserted after each sublayer. Everything around them is frozen.
With and that is 131,000 parameters per insertion point, so a 32-layer model with two per layer trains about 8 million of them.
Why it starts as the identity
The up projection is initialised to zero, so the adapter contributes nothing at step one and the model behaves exactly as it did before.
Training then moves it away from zero gradually. Without that, inserting random matrices into a trained network destroys its behaviour before any learning happens.
The residual connection around the bottleneck is what makes the identity reachable at all, and it is the same reasoning as in a transformer block.
One adapted model, in order
- Freeze every original parameter.
- Insert an adapter after the attention sublayer and after the feed-forward sublayer in each block.
- Initialise the up projection to zero and the down projection normally.
- Train only the adapters and the normalisation parameters.
- Save the adapters alone, which is a file of tens of megabytes rather than tens of gigabytes.
Leaving the layer norm parameters trainable is a small addition that reliably helps, since it lets the model rescale what the adapter changed.
The cost LoRA removed
Latency rises by 2 to 6 percent.
An adapter is a genuine extra operation in the forward pass, so it is still there at inference and every token pays for it.
LoRA's update is a linear term parallel to an existing weight matrix, so it can be added into that matrix once and disappear entirely.
That single property is why LoRA displaced adapters as the default, despite the two performing about the same on quality.
Where adapters still win
LoRA and adapters both serve many tasks from one base model, and adapters do it without the merge step, so switching task is swapping a small module rather than rewriting weights.
AdapterFusion is the clearest example.
Several adapters trained on different tasks can be combined with a learned attention over their outputs, which is a composition story LoRA has no direct equivalent for.
The nonlinearity inside the bottleneck also gives them strictly more expressive power than a low-rank linear update at the same parameter count, which occasionally shows on hard tasks.