techtree / Transformer / ← prev 24 of 26 next →
Stacking blocks
The same block design, repeated many times, each with its own weights.
Transcript
One block makes one round of edits to the token vectors. A transformer stacks many blocks, one on top of the next. What comes out of one block goes into the next.
Every block has the same design, but its own weights: its own attention matrices, and its own MLP.
The residual stream runs up through all of them. Each block reads the vectors, and adds its edit.
Small models have about a dozen blocks. The largest have around a hundred.
Early blocks tend to pick up simple patterns, like which words sit nearby. Later blocks build on those, toward meaning.
One design, stacked many times, each copy with its own weights.
Needs
- The transformer block video
Attention then MLP, each wrapped in normalization and a residual.
Everything this builds on (21 topics, in order)
- Vectors
- Adding and scaling vectors
- Dot product
- Length, angle, and cosine similarity
- Matrices
- Matrix times vector
- Exp and softmax
- Nonlinearity (ReLU)
- Mean, variance, and normalization
- Tokens
- Embeddings
- Position information
- A neural network layer
- MLP
- Residual connections
- Queries, keys, and values
- Attention scores
- Self-attention
- Causal masking
- Multi-head attention
- The transformer block
Leads to
- Next-token prediction and sampling video
Turn the last vector into a score per token, softmax, and pick one.