techtree / Transformer / ← prev 26 of 26 next →
What is a transformer?
The whole machine, end to end.
Transcript
A transformer takes in text, chops it into tokens, and looks up a vector for each one, with its position added.
The vectors rise through a stack of blocks. In each block, attention lets the tokens share information, and an MLP works on each token by itself.
At the top, the last vector becomes a score for every token in the vocabulary. Softmax makes them probabilities, and one token is picked.
It is added to the text, and the whole machine runs again.
All of its skill lives in its weights: the embedding table, the attention matrices, and the MLPs.
Text in. One token out. Again and again. That is a transformer.
Needs
- Next-token prediction and sampling video
Turn the last vector into a score per token, softmax, and pick one.
Everything this builds on (23 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
- Stacking blocks
- Next-token prediction and sampling
Leads to
This is the top of the tree.