techtree / Transformer
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
- Tokens
- Adding and scaling vectors
- Dot product
- Matrices
- Exp and softmax
- Nonlinearity (ReLU)
- Mean, variance, and normalization
- Length, angle, and cosine similarity
- Matrix times vector
- Embeddings
- A neural network layer
- Position information
- Queries, keys, and values
- MLP
- Residual connections
- 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.