GPT
A decoder-only transformer trained to predict the next token.
The idea
GPT reads text left to right: a causal mask stops each token from attending to later tokens, and the model learns to predict the next token. Scaled to huge data and size, this single objective yields models that can write, summarise, translate and reason in context from a prompt.
p(x) = Π p(xₜ | x₍<t₎)
Watch it run
This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.
- positive
- negative
- attention weight
Take the sentence. We will compute what the word "cat" (highlighted) should pay attention to.
The vectors here are random, so the pattern of attention is arbitrary. In a trained model these weights are learned. Pick another query word with the slider.
Step by step
- 1Tokenise the text.
- 2Apply masked (causal) self-attention so each token only sees the past.
- 3Predict a probability distribution over the next token.
- 4Train with cross-entropy; at inference sample a token and feed it back in.
Where it is used
Chat assistants, code completion, writing tools.
Watch out for
It can state falsehoods fluently (hallucinate), and its context window is limited.