Identify the locations where dropout typically sits inside a transformer block
Three canonical dropout sites: attention weights (post-softmax), FFN output, and residual stream. Norm internals and Q/K/V projections do NOT get dropout.
Think of dropout like a coach who randomly benches a few players every practice so the team can't rely on one star. In a transformer block, there are three sensible benches. The first is right after the model decides which earlier words to focus on (so it doesn't get hooked on one word-to-word connection). The second is on the output of the per-word processing layer (so each word learns sturdier features). The third is on the shared bus that carries information between blocks (so the model does not depend on any single layer). Don't bench players inside the rescaling step (that ruins the whole point of stabilizing the signal). Don't bench the players that build the focus scores either (that adds useless noise). In frontier LLMs, dropout is often turned off during pretraining because the data is so vast the model is under-fit anyway.
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.
Dropout placement inside a transformer block is one of those details that seems trivial until you try to put it in the wrong place. The 2017 paper specified three standard sites (attention weights, FFN output, residual stream) and almost no published architecture has deviated. The placements are not arbitrary. They reflect a careful choice about which activation surfaces are well conditioned for stochastic regularization and which would be destabilized by it.
The three standard sites
Attention dropout sits on the post-softmax attention weights, before the weighted sum over V. The softmax produces a distribution over tokens for each query. Dropout zeros random entries in that distribution. Implementations vary on whether the result is renormalized, but the standard is to drop without renormalization, accepting the lossy sum. The regularization effect is to perturb which tokens get attended to on each forward pass. This prevents the model from over-relying on any single token to token edge.
FFN output dropout sits on the output of the position-wise feed-forward network, before the residual add. This is standard MLP dropout: zero random dimensions of the FFN output vector, forcing the model to maintain redundant feature representations.
Residual / post-sublayer dropout sits on the sublayer output before it is added to the residual stream. This regularizes how much each sublayer contributes to the running residual. It's the strongest dropout location because it perturbs the residual stream itself, which every later sublayer reads from.
In BERT, T5, and the original 2017 transformer, these three sites all use the same dropout rate (typically 0.1). Modern setups sometimes vary the rate per site or disable some sites entirely.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- BERT base (2018): dropout 0.1 on attention weights, FFN output, and residual stream: the canonical three.
- Llama 3.1 pretraining: dropout set to 0 across all sites. The model is data bound, not parameter bound.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy is attention dropout applied to post-softmax weights rather than pre-softmax logits?
Pre-softmax dropout would zero some logits. After softmax, the remaining nonzero logits would absorb almost all the probability mass via the exp normalization, defeating the regularization. Post-softmax dropout zeros some attention edges while keeping the rest correctly normalized (after renormalization).
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.
Placing dropout inside the RMSNorm computation. The norm exists to stabilize activation statistics. Injecting dropout there defeats its purpose. Dropout on Q/K/V projections is also wrong because it destabilizes the attention dot product.
60 second bullets to scan on the way to the call.
The three canonical dropout sites in a transformer block
Why post-softmax weights are the right attention dropout target, not Q/K/V projections
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.