LLM Library
Inside the TransformerAnimated
Feed-Forward Layers and Residuals
The per-token network and the shortcuts that make deep stacks train.
The idea
The feed-forward network expands each vector, applies a non-linearity (often SwiGLU), and projects it back. It holds most of the parameters. Residual connections add the layer input to its output so information and gradients flow.
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
- 1Expand the vector to a wider size
- 2Apply the activation
- 3Project back down
- 4Add the original input
Where it is used
Every transformer layer.
Watch out for
The feed-forward layer is where Mixture of Experts makes its savings.