Injecting noise into pre-softmax attention scores, goal and risk?
Noise on pre-softmax scores regularizes attention against winner take all collapse. Too much noise flattens softmax into uniform mixing and destroys the ability to focus.
Imagine a kid given a single bag of mixed candy and told to grab their favorite. Every time, the kid grabs the same chocolate, ignoring the rest. To teach the kid to try new things, you blindfold them slightly with a thin scarf, just enough that their reach wobbles. Sometimes they still pick chocolate, sometimes a gummy, sometimes something else. Now they learn that several candies are interesting. But if you blindfold them too tight, their reach is purely random and they have no preference at all. Attention noise during training works the same way: a small wobble keeps the model open to alternatives; too much wobble turns it into a coin flip.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Attention noise is a training-time regularizer that adds small perturbations to pre-softmax attention scores. The technique sits in a family that includes attention dropout and entropy regularization, all targeting the same failure mode: heads that collapse into overconfident, low-entropy routing patterns that overfit on training data.
This deep dive walks through why the failure mode happens, why noise injection fixes it, what the risk knob looks like in the opposite direction, and how the technique relates to neighbors like attention dropout, softmax temperature, and Entmax.
Mental model: noise on pre-softmax scores is a stochastic flattener. Small coefficient prevents head collapse without destroying routing. Large coefficient destroys routing entirely.
The failure mode: over-peaked attention
Why heads collapse
Softmax is exponential. A score gap of 5 nats between the top key and the runner-up produces a post-softmax weight ratio of about 150 to 1. A gap of 10 nats gives 22000 to 1. So once the model nudges scores even modestly toward one key, the softmax amplifies the preference into near one-hot routing.
The positive-feedback trap
Once a head routes nearly all weight to a single key, that key's value vector dominates the head's output. Gradients on the suppressed alternatives are vanishing because their post-softmax weights are near zero. The head cannot easily learn to consider other keys; the collapse is locally stable.
Why this hurts generalization
A collapsed head has effectively memorized: 'for queries that look like X, route to key Y'. This works on the training distribution but breaks on inputs that need a slightly different routing. The head is now a shortcut, not a feature detector.
Diagnosing the failure
Researchers diagnose this by measuring attention entropy. Healthy heads have moderate entropy (not uniform, not one-hot). Collapsed heads have near-zero entropy. Several training metrics monitor per-head entropy as a sanity check.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Attention dropout (a post-softmax cousin) is built into the original Transformer paper and ships with every PyTorch nn.MultiheadAttention implementation.
- Several efficient-training recipes (T5 v1.1, some PaLM variants) experimented with score-level noise injection alongside attention dropout.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does attention noise differ from attention dropout?
Attention dropout zeros entries of the post-softmax weight matrix. Attention noise perturbs pre-softmax scores. The first removes connections; the second shifts the temperature of the softmax. Both target the same over-peaked failure mode but at different stages.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Confusing attention noise with FFN dropout or with sampling temperature at the output. Attention noise specifically targets the pre-softmax scores inside the attention layer.
60 second bullets to scan on the way to the call.
Where in the attention pipeline noise injection acts
Why over-peaked attention distributions are a training failure mode
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.