Attention and transformers (intuition)
For engineers
How a transformer decides which earlier tokens matter, why attention cost grows with context, and how blocks stack into a model
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
In "The backup job slowed the server because it was copying two terabytes of files", what decides what "it" refers to?
Check yourself · 2 of 5
In attention, what is compared with a token's query to produce a score?
Check yourself · 3 of 5
What is the main benefit of using many attention heads in a layer?
Check yourself · 4 of 5
What does the causal mask do in a decoder model?
Check yourself · 5 of 5
A prompt grows from 2,000 to 4,000 tokens. Roughly how does the attention score grid change?
Topics
- Why tokens need context from others3 min read · A word's meaning depends on earlier words, and fixed-size memory in older networks lost long-range links
- Queries, keys and values as lookup4 min read · Attention as a soft lookup: each token asks a question, scores every earlier token and mixes their values
- Many attention heads across layers4 min read · Why many small attention patterns in many layers beat one big one, and what single heads learn
- Inside one decoder transformer block5 min read · Attention, the feed-forward layer, residual connections, normalization, position encoding and the causal mask
- Attention cost and long-context tricks5 min read · Attention cost grows with the square of context length; KV caching, grouped-query and sliding-window attention cut it
Start here
- The Illustrated Transformer (Jay Alammar) (opens in a new tab)ArticleFree
Step-by-step pictures of queries, keys, values, multi-head attention and the encoder-decoder stack.
- Transformer Explainer (Georgia Tech Polo Club) (opens in a new tab)ToolFree
Runs a small GPT-2 in your browser so you can watch attention weights change as you edit the prompt.
- 3Blue1Brown: Attention in transformers, step-by-step (opens in a new tab)VideoFree
A visual video lesson, with a written version, on queries, keys, values, masking and multi-head attention.
Scenarios
Helps to know first
110 questions · last verified 2026-12