AI Anatomy Class · Part 7 · Teaching GPT: pre-training

65. Measuring surprise

Q. A model that bet 52% on the right answer: how wrong was it? Can we measure wrongness with a single number?

  1. After 'I walk to', the model gave 'school' 52%. The answer was 'school'. So how wrong was the model?
  2. Think of it as surprise. If what you expected happens, you're hardly surprised; if the unlikely happens, you're shocked.
  3. Let's put a number on it. A sure thing (probability 1) means surprise 0. Each halving of the probability adds 1.
  4. 1/4 gives 2, and 1/8 gives 3. Count how many 2s you multiply to get 8: 2 × 2 × 2 = 8, so 3.
  5. Connect the dots: near probability 0, surprise shoots up without end. In math this is a logarithm; you'll meet it later on.
  6. school at 52% gives a surprise of about 0.94. Had it given school just 12%, about 3.06. Bet more on the answer, less surprise.
  7. Average the surprise over all the questions and you get cross-entropy. That's GPT's loss; training means making it smaller.

Chapter summary