Attention gating: should this head add anything?
A head has collected information. How does the model decide how much of it to use?
Finding information is not the same as needing it
The head has done its work: compare queries and keys, apply softmax, then take a weighted sum of values.
For “the old rabbit”, that result might help rabbit pick up old. For another token, the same head may have little to contribute.
In attention sinks, we saw one way a model handles that pressure. But could it simply turn down the collected information before adding anything to the stream?
Let the token control what passes
We used a gate inside the feed-forward network. We can use the same idea here.
Take the current token’s representation through another learned matrix. Then apply sigmoid, giving a multiplier between zero and one for each coordinate of the collected vector.
Near one, the coordinate passes through. Near zero, it becomes quiet.
Choose Let less through. The collected vector has not changed; the gate changes how much of it continues.
The token makes its gate alongside its query. It does not wait to read the collected result. Training adjusts the gate weights together with the query, key and value weights.
Put it inside the head
The gate sits after the weighted sum, before the output projection Wₒ.
Follow the extra branch from the token representations down to the multiplication. The gated result then takes the familiar route through Wₒ and back into the residual stream.
Each head gets its own gate weights. Here, each coordinate has its own multiplier; a simpler alternative uses one multiplier for the whole head.
The residual stream keeps its existing representation. Turning down this branch only turns down this head’s contribution.
What happens to the sink?
Multiplying the collected vector does not change the attention map that produced it. Its rows still add up to one.
But during training, the head now has a direct way to suppress an unhelpful result. It has less reason to route attention into a sink to achieve that behaviour.
Qiu and colleagues found much less attention going to the first token after training with head-specific output gates. Their experiments also found better training stability.
So the two questions are different: where should I gather information? And how much of what I gathered should pass through?
Sources
- Gated Attention for Large Language Models, Qiu and colleagues: query-dependent sigmoid gating after the attention weighted sum, before the output projection. The paper compares coordinate-wise and head-wise gates, and measures the sink pattern after training.
- Quantizable Transformers: Removing Outliers by Helping Attention Heads Do Nothing, Bondarenko and colleagues, 2023: earlier attention output gating, including a gate computed from the token representation.
The gate widget multiplies token vectors by a fixed gate matrix, applies sigmoid, and multiplies the collected vector coordinate by coordinate. Its two inputs show stronger and weaker gates. The whole-head diagram follows the same attention calculation as the introductory article, with the extra output-gate branch added. The cells show compact samples; dimension labels follow the selected model.