How models learn
← The series

Chapter 13 · Not written yet

Attention

Reading everything is not knowing where to look.

The model weighs every part of what it reads, and the weights are computed rather than fixed. Drawn as a heat map, the mechanism stops being mysterious.

  • weighting
  • context
  • heat map

How this chapter will go

Say what is being weighted, and where the weights come from.

The image it is built onTranslating a sentence. You read the whole thing, and then you keep going back to the one word you are working on.

  1. Reading is not looking

    A model that receives a whole paragraph receives all of it equally. Something has to decide which parts matter for the word being produced right now.

  2. A weight for every position

    Each position gets a number saying how much it counts. The numbers add up to one, so this is a way of dividing attention rather than choosing a winner.

  3. The weights are computed

    They are not fixed in advance and not learnt once and for all. They are worked out from the content itself, which is why the same model attends differently to two different sentences.

  4. Drawn as a grid

    Words down one side, words across the other, and brightness for the weight. The mechanism stops being mysterious the moment it is a picture.

    thethecatanimalsatactiononthethethematsurfaceitpronounsleptactionthecatsatonthematitslepteach row looks along"it" is asking forsomething that acts · 1.5something being done · 0.4"cat" offerssomething that acts · 1.5q · k = 1.30weight = 74%brightness is the weight, on a fixed nought-to-one scale
    how decisively the weights pick a winner
    reading
    it
    most weight to
    cat
    that weight
    0.74
    row total
    1.000
    spread, bits
    1.55

    Nothing was written into this grid. Change one word and watch every number move.

    Every number here was worked out from the words, not written into the grid. Pick a row to see what that word is looking for, then change a word and watch the weights move.

The misreading to head off

Attention weights are not an explanation of the model. They show what was combined, not why the answer came out the way it did.

There is no date, no list to join and nothing to subscribe to. The chapter simply appears here once the drawing works.