LLM Library
Inside the TransformerAnimated
The Transformer Block
Attention plus a feed-forward network, wrapped in norms and shortcuts.
The idea
One layer is normalisation, attention, a residual add, normalisation, a feed-forward network, another residual add. Models stack dozens of identical layers.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
Raw text enters the system, for example "The cat sat on the".
- stage:
- 1/12
- part:
- Text in
1/12
The green dot is one token travelling through the model. The boxed section repeats for every layer.
Step by step
- 1Normalise
- 2Attention
- 3Add the shortcut
- 4Feed-forward and add the shortcut again
Where it is used
Everything from GPT-2 to current models.
Watch out for
Details such as pre-norm and the activation function differ between families.