Skip to content
The Daily Triptych013 / 365
One residual block in a transformer

The input is normalised, transformed, then added back to the original. The addition creates a gradient path that bypasses the transformation entirely, allowing the signal to flow through dozens of layers without vanishing.

II · THE IDEA · ARTIFICIAL INTELLIGENCE

Residual Connections and Normalisation

Foundations · Residual connections 2015, RMSNorm 2019 · Deep Residual Learning for Image Recognition

▶ Listen · narrated

Stack enough layers and the network stops learning entirely. Not slowly — it stops. Two small changes fixed that, and neither one looks like it should matter as much as it does.

At a glance

Residual connection
Add the input back to the output of each layer
Layer normalisation
Rescale activations to stable statistics before each operation
Combined effect
Networks can train reliably at hundreds of layers deep
Transformer use
Every attention and feedforward block uses both techniques

Imagine training a very tall stack of translators, where each one refines the translation from the one below. If the bottom translator makes a mistake, the correction has to propagate all the way up the stack, and by the time it reaches the top, the signal is too weak to matter. The bottom translator never learns.

Residual connections solve this by giving each translator two jobs: refine the translation, but also pass the original input straight through unchanged. If a translator has nothing useful to add yet, the original can still flow upward. The correction signal can travel back down the same shortcut, so even the bottom translator gets feedback.

Normalisation is simpler: before each translator starts work, you adjust the input so it is always in a predictable range. This stops the stack from drifting into extreme values that make learning unstable. The combination — shortcut plus normalisation — is why modern networks can have hundreds of layers and still train reliably.

Look closer

  1. The residual path is an identity shortcut

    Instead of asking a layer to learn the function you want, you ask it to learn the difference between what you want and what you already have. The input bypasses the layer's computation entirely and gets added back at the end. If the layer learns nothing useful, the gradient can still flow backward through the addition operation as though the layer were not there. Early in training, when weights are random, this shortcut is the only reason anything works at all.

  2. Normalisation happens before the operation, not after

    The original batch normalisation paper put the normalisation after the layer's computation. Transformers reverse this: they normalise the input before it enters the attention or feedforward block. This is called pre-norm, and it makes training more stable because the normalisation statistics do not depend on the layer's current weights, which are still changing rapidly early in training. Root Mean Square normalisation removes the mean-centring step entirely, keeping only the rescaling by standard deviation, and empirical results suggest the mean was not doing much work.

  3. The residual stream accumulates information

    Because every layer adds its output to the existing activation rather than replacing it, the vector flowing through the network becomes a running sum of contributions. Early layers add positional and token information. Middle layers add syntactic and semantic refinements. Late layers add task-specific adjustments. The final output is not the result of the last layer alone — it is the sum of every layer's edits to the original input, and in principle you can subtract a single layer's contribution to see what that layer added.

The story

In 2015, researchers at Microsoft trained a network with over a hundred layers and won the ImageNet competition. The achievement was not the depth for its own sake — it was that the network trained at all. A year earlier, the same team had found that adding more layers made performance worse, not better. The problem was not overfitting. The problem was that the network could not learn in the first place.

The gradients were vanishing. During backpropagation, the learning signal has to flow backward through every layer to update the early weights. Each layer multiplies the gradient by its own derivatives, and if those derivatives are small — which they often are — the gradient shrinks exponentially with depth. By the time the signal reaches the first few layers, it has decayed to nothing. The early layers stop learning, and the network as a whole gets stuck.

The solution was the residual connection. Instead of computing y = f(x), the layer computes y = f(x) + x. The input is added back to the output. This seems trivial, but it changes the gradient behaviour completely. When the gradient flows backward through the addition, it splits: one copy goes through the layer's computation, where it may shrink, and one copy passes straight through unchanged. That second path — the identity shortcut — means the gradient can always reach the early layers, no matter how deep the network is.

The improvement was immediate and dramatic. Networks with fifty layers trained faster and better than shallower networks without residual connections. Networks with over a hundred layers became practical. The technique transferred to every domain: vision, speech, language. By 2017, the transformer architecture had absorbed the same idea, and every attention block and feedforward block in every modern language model uses residual connections.

Normalisation was the other half of the solution. Even with residual connections, activations can drift to extreme values during training, and extreme values make gradients unstable. Layer normalisation rescales the activations at each layer to have stable statistics — typically zero mean and unit variance, though Root Mean Square normalisation drops the mean-centring and keeps only the variance rescaling. The effect is that every layer receives inputs in a predictable range, no matter what the previous layers did.

Transformers use pre-norm: the input is normalised before it enters the attention or feedforward computation, not after. This makes training more stable because the normalisation does not depend on the layer's weights, which are changing rapidly early in training. The residual connection then adds the layer's output to the original, unnormalised input. The combination — normalise, compute, add back — appears in every transformer block, twice per layer, and it is the reason transformers can train at all at the scales we now use.

The residual stream, as it is sometimes called, is the vector that flows through the network, accumulating contributions from every layer. It is not rewritten by each layer; it is edited. Early layers add token embeddings and positional information. Middle layers add syntactic structure and semantic relationships. Late layers add task-specific adjustments. The final output is the sum of all these edits, and because the additions are linear, you can in principle isolate what each layer contributed by subtracting its output from the stream.

Why it mattered then

Before residual connections, depth was a liability. Networks with more than a dozen layers were difficult to train, and adding layers often made performance worse. The ImageNet competition in 2015 made this concrete: the winning network had 152 layers, and it trained more easily than the 20-layer networks that had competed the year before. The result was not incremental — it was a qualitative change in what was possible. Residual connections removed depth as a bottleneck, and suddenly the question was not whether a network could be deep, but how deep it should be. The transformer architecture, introduced two years later, inherited the technique directly, and every large language model since has used it.

Why it matters now

Residual connections and normalisation are so standard now that they are almost invisible. Every transformer block has them, and no serious architecture omits them. But they are not just historical curiosities — they are active constraints. The residual stream is a shared workspace, and every layer is editing the same vector. This means layers can interfere with each other, and it means the model's behaviour is the sum of many small contributions rather than the output of a single decisive computation. Understanding this matters for interpretability: if you want to know why a model produced a particular output, you cannot look at the last layer alone. You have to trace the contributions backward through the entire residual stream. It also matters for efficiency: because the additions are linear, some research has explored removing entire layers at inference time without retraining, and the model degrades gracefully rather than collapsing. The architecture is not just deep — it is redundant by design.

The surprising detail

The residual connection was not invented to solve the vanishing gradient problem. The original 2015 paper framed it as a way to make optimisation easier by reformulating the learning task: instead of learning a complicated function from scratch, learn the difference between what you have and what you want. The vanishing gradient explanation came later, after researchers observed that the gradients were flowing more easily and worked backward to understand why. The technique succeeded before the theory caught up, which is not unusual in deep learning but is still worth remembering — the reason it works and the reason it was tried are not the same thing.

Remember this

Residual connections let gradients bypass layers entirely. Normalisation keeps activations stable. Together they make depth practical, and depth makes transformers possible.

Test yourself

A researcher removes all residual connections from a trained transformer and runs inference. The output is nonsense. Why does this break the model more severely than removing a single layer would?

Go deeper

Image: Original diagram, The Daily Triptych. Licence: Original work. Source.

← Back to day 13