Transformers and Attention
In this article
- Sketch the path from token IDs to next-token probabilities, naming each step in order.
- Say which positions a token may read under the causal mask, and why training needs the mask.
- Explain why relevance scores are worked out afresh for each text while the weights stay fixed.
- Predict how many forward passes a reply takes and how a doubled prompt changes the attention work of each.
- Terms defined here: transformer, token embedding, positional encoding, attention, causal mask, transformer layer, logits, softmax, forward pass.
Overview
In Tokens and Next-Token Prediction, the question "In which city is the Eiffel Tower?" went into the model as 10 token IDs, the numbers that stand for its text pieces, and came back as a table of next-token probabilities with ␣Paris at 0.90 (␣ marks the space before the word). In between lies a puzzle: the text ends on ?, the tower's name sits several tokens earlier, yet the scores for the token after ? point at Paris. Something inside carries information forward. Afterwards you can sketch that inside from IDs to scores, say what each position can draw on, and tell what a longer prompt costs.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- From IDs to vectors
- Attention: mixing earlier positions
- A layer, then a stack
- From the last vector to scores, and what a pass costs
- Sources
- Check yourself, 5 questions