How AI Understands Context
Imagine each new speaker can hear everyone who spoke earlier, not just the previous person. During generation, a causal mask keeps future speakers unheard until their turn.
Use the arrows below, the dots above, or your keyboard arrow keys to move through the stages.
Before Attention: The Phone Chain
The old way. Left to right, losing information with every step. By the end, the model barely remembers that "cat" is the subject of "ran." Long-distance relationships are lost.
Attention: The Room
The goal of this stage is simple: the action word ran should reconnect directly to cat. Watch the important words lift up, then follow the curved lines.
With attention, "ran" can connect directly to earlier context such as "cat." During generation, a simple causal mask hides future tokens—like covering the unread part of a sentence.
Click the Highlighted Word
This stage shows why the same word can mean different things. Click the purple word and follow the arrows to the strongest context clues.
Three Heads, Three Perspectives
Multi-head attention means the model does not use only one spotlight. Different heads look for grammar, references, and meaning at the same time.
Multiple heads work simultaneously -- grammar, meaning, references, all in parallel. Each head specializes in a different type of relationship.