TL;DR
Adapter tuning adapts a large pretrained network to a new task by freezing every original weight and training only small modules, called adapters, that are inserted into each block. Each adapter squeezes its input down to a narrow vector, applies a nonlinearity, and expands it back, then adds the result to the input. Because only the adapters are trained and stored, each new task costs a few percent of the parameters of a full copy.
Builds on: Fine-Tuning, Transformer · Leads to: Low-Rank Adaptation (LoRA), QLoRA, IP-Adapter: Text Compatible Image Prompt Adapter for Diffusion Models
Where it's used
- Serving many tasks from one model. A company that answers questions for dozens of customers can keep one frozen base model and store one small adapter per customer. Each adapter is a few megabytes, while a full copy of a base model with a hundred million or more parameters is hundreds of megabytes.
- Early transfer to language tasks. In 2019 Houlsby and colleagues inserted adapters into BERT, a transformer pretrained on text, and tuned it on many classification benchmarks. They reported results close to full fine-tuning while training only a few percent of the parameters per task.
- Conditioning image models. Image diffusion models such as Stable Diffusion were adapted with IP-Adapter, a small add-on that lets an image prompt steer generation. The base model stays frozen, in the same spirit as an adapter.
How it works
We follow one tiny adapter on a vector of size 4, with a bottleneck of size 1.
- Start with the frozen block's output. The block produces the vector h = (1, 2, 3, 4). Its weights are frozen and will not change.
- Squeeze down. Multiply h by a down-projection with row (0.5, 0, 0, 0). The result is 0.5. Check: 0.5 times 1 is 0.5, and the other terms are 0.
- Apply a nonlinearity. Pass 0.5 through a ReLU, which replaces negative numbers with 0 and keeps positive ones, so it leaves 0.5 unchanged. This is the only place the adapter bends its input.
- Expand back up. Multiply the bottleneck value by a up-projection with column (2, 0, 0, 0). The result is (1, 0, 0, 0). Check: 2 times 0.5 is 1.
- Add back the input. Add the adapter's output to the original vector: (1, 2, 3, 4) plus (1, 0, 0, 0) gives (2, 2, 3, 4). The adapter changes only the first entry here.
- Start from no change. If the up-projection is initialised to zeros, step 4 gives (0, 0, 0, 0) and the output is exactly h. Training then moves the adapter away from identity only as far as the task needs.
flowchart LR H[block output h] --> D[down-project to bottleneck] D --> A[nonlinearity] A --> U[up-project back to full width] H --> ADD((add)) U --> ADD ADD --> N[next layer]
The math
Step 1 in symbols
The frozen block produces . The example above has and , with and .
Step 2 in symbols: the bottleneck
is a vector of length . In the example , and .
Step 3 in symbols: expansion and residual sum
. In the example , so .
Step 4 in symbols: parameter count
An adapter has weights in and , and in and , so in total. With one adapter per block and blocks, the trainable count is .
Worked examples
Use , , and , with all biases zero. The input is .
- The bottleneck is .
- The expansion is in the first entry and 0 elsewhere.
- The output is .
- The first entry changed from 1 to 2 and the rest did not change, because the adapter's weights only read and write the first coordinate.
Example 2 (standard). Take a transformer with , bottleneck , blocks, and two adapters per block, one after each sublayer. A full copy of a base model of this size has about 110 million parameters.
- One adapter has trainable parameters.
- There are adapters, so the total is .
- The fraction is , about 2 percent.
- Training 2.4 million numbers is much cheaper than training 110 million, and the saved task file is about 9.5 MB in 32-bit floats instead of about 440 MB.
Example 3 (realistic). A team runs one frozen base model for 500 customers. Each customer gets an adapter, so the team stores one base copy and 500 adapters. Using the Example 2 numbers, each adapter takes about 9.5 MB. The team stores MB, about 5.2 GB. Storing 500 full copies would take MB, about 220 GB.
Try it: a model has and bottleneck , with one adapter in each of blocks. How many trainable parameters are there? Answer: one adapter has , and .
Common mistakes and tradeoffs
It is tempting to think that adapters are a separate model that runs beside the original. In fact the adapter sits inside the block, and its output is added to the frozen block's output, so the adapted model is one network with extra modules in its path.
It is tempting to think that the bottleneck width is a free choice that does not matter. In fact a narrow bottleneck stores fewer task-specific parameters and can limit how much the model can change, while a wide one approaches full fine-tuning in cost. The width is the main knob.
It is tempting to think that adapters always add latency at inference. In fact each adapter adds a small matrix product per block, which costs some time. Methods such as Low-Rank Adaptation (LoRA) can merge their update into the frozen weights after training, so the deployed model has no extra layers.
Use adapters when many tasks share one base model and storage or switching cost matters. Do not use them when a single task needs maximum accuracy and memory is not a concern, because full Fine-Tuning often does slightly better. Alternatives include Low-Rank Adaptation (LoRA), which learns a low-rank change to each existing weight matrix, and Transfer Learning with only the final layer trained.
History
Before 2019, adapting a large pretrained language model usually meant copying the whole model and training it on each task. This made many tasks expensive to store and serve. Houlsby and colleagues showed in 2019 that a small bottleneck module inserted into each transformer block, trained while the rest stayed frozen, could come close to full fine-tuning on many benchmarks. The idea caught on because it turned a per-task copy into a small file. Later methods, including LoRA in 2021, kept the same goal and changed the form of the small update.
Recap
- A transformer block can be adapted by inserting a small bottleneck module whose output is added to the block's output.
- The bottleneck squeezes the vector down, applies a nonlinearity, and expands it back, so only a few percent of the parameters are trained.
- Starting the up-projection at zero makes the adapted model begin exactly as the frozen one.
- Many tasks can share one base model, with one small adapter stored per task.
- Read next: Low-Rank Adaptation (LoRA), which learns a low-rank update to existing weights, and QLoRA, which combines this with quantized base weights.