AI Anatomy Class · Part 5 · Mastering attention

51. No peeking at the future

Q. If you're supposed to guess the next word but can see it in advance, are you really learning anything?

  1. GPT guesses the next word (ch. 1). But in chapter 47's score table, 'I' is also looking at the words that come after it.
  2. In training, the whole sentence goes in at once. A word that sees the words after it is peeking at the answer, and learns nothing.
  3. So we pull down a curtain. Each word may see only itself and the words before it. Every cell above the diagonal is covered.
  4. Covered cells get the score −∞, an endlessly small number. e to the −∞ is 0, so after softmax those cells get 0%.
  5. Softmax each row again: 'I' gives 100% to itself, and 'walk' gives 97.2% to 'I' and 2.8% to itself.
  6. The row of 'school' doesn't change: every word it looks at is already before it. Chapter 49's mix (2.25, 1.52) stays the same too.
  7. This triangle curtain lets every position train at once without seeing the future. It's called the causal mask.
  8. Writing works the same way. It writes one word at a time (ch. 2), so the future it hasn't written yet can't be seen.

Chapter summary