Transformer: 5 articles and lessons
5 stories tagged Transformer on Learning Fanatic.
- Lesson 3.2: Self-attention: queries, keys and values Build self-attention from queries, keys and values. See why scores are scaled by the square root of the key size, then train it to solve a lookup task.
- Lesson 3.3: Causal masking and multi-head attention See why a language model must not look at future tokens, what happens when it does (a loss below the best possible), and how several heads split the work.
- Lesson 4.1: Residual connections and layer normalisation See why deep stacks are hard to train, how residual connections keep gradients alive, and how layer normalisation keeps each layer's input in a steady range.
- Lesson 4.2: The feed-forward network and activations Add the second half of the transformer block: a two-layer network applied to each token. See why it needs a nonlinearity, what GELU is, and how big it is.
- Lesson 4.4: Initialisation, parameter counts and shapes Read a transformer's shapes, count its parameters exactly, and start it well: check the loss at step 0, scale the residual layers and test on one batch.