Attention demo

When a model reads a sentence, every word decides how much to look at every other word — that deciding is attention. The heatmaps at the top of this page are computed live, by the same code the learning modules use, on a sentence from the default collection — or from your own, if you have saved one — with several attention heads working side by side, each reading the sentence through its own slice of the projections. Nothing here is a picture of attention. The weights it computes with are seeded stand-ins, not a trained model's: random starting values, fixed by a seed so they come out the same every time. Further down, a second panel shows what a model that was trained made of the same sentence — a different, larger stack, whose maps were saved when it was trained and are shown as stored rather than recomputed here.

Step through it slowly: What is Attention? · Scaled Dot-Product Attention · Multi-Head Attention

Reading the corpus…

Computing…

Attention demo — TransformerLab