What does “it” refer to?
In “The robot carried the battery because it was heavy,” the word “it” needs the words around it. The sentence is the clue.
LESSON 04 The context spotlight
A weighted spotlight that helps a model decide which nearby tokens matter right now.
00 Overview / start here
A word can be ambiguous on its own. Attention gives a model a way to look around, decide what matters, and carry a useful blend forward.
In “The robot carried the battery because it was heavy,” the word “it” needs the words around it. The sentence is the clue.
Attention lets a model compare one token with the available context, give each context token a weight, and mix the useful information.
The current token, such as “it,” is the question: what information would help me here?
Scores are normalized into percentages. A larger percentage means more of that token enters the mixture.
The model carries a new representation made from the weighted values, ready for the next calculation.
If “battery” gets 70%, “robot” 20%, and “heavy” 10%, the mixed signal is mostly battery information, with smaller contributions from the other clues.
01 Spotlight on a sentence
Choose a sentence, then click any token. The toy model treats that token as the query and redistributes attention across the available context.
Every context bar is a visible percentage. The bars share one whole: the visible weights always add to 100%.
The spotlight is strongest on the clue that makes “it” understandable.
Attention is not a spotlight because the model “sees.” It is a calculated mixture.
02 Change the focus
The focus control changes how concentrated the illustrative weights are. The causal-mask mode then hides tokens that would arrive later in a left-to-right prediction.
A low focus spreads attention across more context. A high focus concentrates it on the strongest clue. This is a visualization of the effect, not a training control.
The useful clue is bright, but nearby context still contributes to the mixture.
In a normal full-context view, the query can compare tokens on both sides of it.
A mask changes the available evidence. Unavailable context gets no percentage.
03 Three jobs
These three names describe jobs in the attention operation. Step through them to see how a question becomes a weighted mixture.
Select a job. The diagram highlights the part currently doing the work, and the number panel shows the matching intermediate state.
The letters are jobs, not three extra words to memorize. Ask, match, mix.
04 Do the small math
Weights only say how much each source contributes. The values supply the information that is actually mixed.
The vectors below are two-number toy values. Drag focus in Experiment 02 or use this panel’s control to see the mixture change.
70% × [0.80, 0.10] + 20% × [0.20, 0.70] + 10% × [0.10, 0.20]
At balanced focus, battery information dominates while robot and heavy still leave a trace.
A weighted sum is not a vote with a winner. It is a blend with visible proportions.
Before revealing the hint, switch Experiment 01 to “fragile,” keep the query on “it,” and raise focus. Which context token should take the largest share, and why?
“battery” should still be important, but “fragile” is the strongest material clue in this toy sentence. A higher focus makes that clue take a larger share of the visible mixture.
PRIMARY SOURCE The original transformer paper introduces attention as a way to relate positions in a sequence: Attention Is All You Need. These attention weights are a teaching visualization, not a guarantee of human-readable reasoning.
FAQ Attention / quick answers
A few plain answers for the most common questions about the spotlight.
Attention is a calculation that gives context tokens different weights, then combines their value vectors into a new signal for the current position.
The query describes what the current position is looking for, keys help compare available positions, and values carry the information that gets mixed after scoring.
Not by itself. An attention map shows one part of a computation. It can make data flow easier to inspect, but it is not a guaranteed explanation of a model’s internal reasoning.