Spotlight
Tap the words "it" should look at. Keep tapping to brighten a spotlight, and a fourth tap turns it off.
The attention network, live
Each word sends its vector into "it". The thicker the edge, the bigger that word's attention weight. "it" mixes what arrives into a context vector (middle), and fixed connections score each answer from it.
The model reads: The animal didn't cross the street because ??? was too tired.
It's dark in here. With no words to read, I can only guess 50/50.
How to play
Tap a word to shine a spotlight on it. The more spotlights a word gets, the larger its share of the attention, and the answers move as you tap. Win each round by getting the right answer to 80%, and use as few spotlights as you can to earn three stars.
What each round teaches
- What is "it"? A pronoun has no meaning of its own here, so it has to read from other words.
- Change one word: the right spotlights change too, so attention has to depend on the sentence.
- Which "bank"? Attention separates the meanings of one word, using clues from far away.
- Two questions at once: a single head's weights must add up to 100%, so a second head is what lets the model do two things well.
What's real and what's simplified
The softmax, the weighted sum and the dot product are the real arithmetic of attention. Three things are simplified. The word vectors are nine hand-made numbers, not learned ones. You choose the spotlight scores, where a real model computes them from learned query and key vectors. And here each head answers its own question, where a real model combines the heads' outputs first.
context = Σ weight × word vector
For the full explanation, read Attention Mechanisms.
Common questions
What is attention in machine learning?
Attention lets a word gather information from other words. Each word gets a score, softmax turns the scores into weights that add up to 100%, and the weighted sum of the word vectors becomes the context.
What is self-attention?
Self-attention is attention where the words look at other words in the same sentence. This is how a transformer works out what a word like "it" refers to.
Why do attention weights share a budget?
Softmax makes all the weights add up to 100%, so giving one word more attention leaves less for the others. This is why one head struggles to do two jobs.
Why use more than one attention head?
Each head has its own weights, so it can look for something different. One head might track what a pronoun refers to while another tracks negation.