Knowledge distillation copies a teacher model’s wrong guesses

1 hour ago

How do you move what a big AI model knows into a model that is cheaper to run? In 2015, three Google researchers, Jeffrey Hinton, Oriol Vinyals and Jeff Dean, published an answer called knowledge distillation. Distillation trains one model to copy another model's guesses, the wrong ones included. The researchers' biggest test was the listening part of an older Android voice search. That part guesses which speech sound it hears. The team trained ten of these listening models and averaged their guesses together. Then the team trained a single model, the same size as each of the ten, to copy the group. The group and the single copy both made ten point seven word mistakes in every hundred words. In 2024, Google said it built its two smallest Gemma 2 models the same way.

Ask

Ask about this presentation

Answers are generated from this presentation.

Chapters

  1. 0:00Running 1 copy instead of 10 models kept word mistakes at 10.7 per 100
  2. 0:49The teacher’s key keeps the right answer and grades every wrong one
  3. 1:31The teacher’s margin notes are there, but too faint to teach the student much
  4. 1:57At temperature 20, the near misses stop looking like zero
  5. 2:28Copying the teacher cut a smaller model’s digit mistakes nearly in half
  6. 2:55Margin notes about other digits taught the student what a 3 looks like
  7. 3:25With the teacher’s margin notes, a model trained on 3% came within 2 points of the full set
  8. 4:00On sound slices and on digits, the copies stayed a little behind their teachers
  9. 4:25In 2024, Google used the same copying to train its small Gemma 2 models
  10. 5:00A student that copies graded guesses gets most of the way to its teacher
Show transcript

Running 1 copy instead of 10 models kept word mistakes at 10.7 per 100

Running 1 copy instead of 10 models kept word mistakes at 10.7 per 100.

How it’s made · 4

10 speech models · guesses averaged10.7 word mistakes per 100 words1 model copying the 1010.7 word mistakes per 100 wordsa mistake is a wrong, missing or extra wordGOOGLE, 2024Gemma 2’s two smallest models were trained this way

Hinton, Vinyals & Dean 2015 · Table 1, page 5 · Gemma 2 report 2024, abstract

How do you move what a big AI model knows into a model that is cheaper to run? In 2015, three Google researchers, Jeffrey Hinton, Oriol Vinyals and Jeff Dean, published an answer called knowledge distillation. Distillation trains one model to copy another model's guesses, the wrong ones included. The researchers' biggest test was the listening part of an older Android voice search. That part guesses which speech sound it hears. The team trained ten of these listening models and averaged their guesses together. Then the team trained a single model, the same size as each of the ten, to copy the group. The group and the single copy both made ten point seven word mistakes in every hundred words. In 2024, Google said it built its two smallest Gemma 2 models the same way.

The teacher’s key keeps the right answer and grades every wrong one

The teacher’s key keeps the right answer and grades every wrong one.

answer keythe teacher’s marked-up key2012345678920123456789a bit like a 3faintly like a 7THE PAPER’S BMW EXAMPLE“a very small chance of being mistakenfor a garbage truck … many timesmore probable than mistaking itfor a carrot”

Hinton, Vinyals & Dean 2015 · section 1, page 2

Why would copying another model beat learning from the same examples? Normal training grades a model against an answer key. For a handwritten 2, the key says 2, and every other answer counts as equally wrong. A trained model grades the wrong answers too. Take the paper's example, a photo of a BMW. A trained model gives the photo a very small chance of being a garbage truck, and a far smaller chance of being a carrot. Those grades show what the model learned about which things look alike. In distillation, the model being copied is the teacher, and the copy is the student. The student gets the teacher's marked-up key. The right answer stays the same, and every wrong answer gets a note in the margin.

The teacher’s margin notes are there, but too faint to teach the student much

The teacher’s margin notes are there, but too faint to teach the student much.

20123456789a bit like a 3faintly like a 7teacher’s confidence, digit by digit01234567893 · 1 in a million7 · 1 in a billionanother 2 might get the reverse

Hinton, Vinyals & Dean 2015 · section 1, page 2 · the paper’s example

Take one page of the marked-up key. Show the teacher a handwritten 2. The teacher splits its confidence across all ten digits, and almost all of it lands on the 2. The paper's example gives this 2 a one-in-a-million chance of being a 3, and a one-in-a-billion chance of being a 7. Those tiny numbers say which 2s look like 3s and which look like 7s. At that size, the margin notes barely change what the student learns.

At temperature 20, the near misses stop looking like zero

At temperature 20, the near misses stop looking like zero.

temperature10123456789temperature2001234567892 · about 1/33 · about 1/67 · about 1/8this 2 looks a bit like a 3while learning: both at 20 · once trained: student at 1

illustrative · our numbers from the paper’s equation 1 · Hinton, Vinyals & Dean 2015, section 2, page 3

So the paper adds a setting called temperature. Raising the temperature flattens the teacher's guesses. The big guess shrinks, the small guesses grow, and every guess keeps its place in line. The paper used a temperature of twenty on its digits. In our illustration at twenty, the 2 drops to about a third of the confidence. The 3 rises to about a sixth, and the 7 to about an eighth. The teacher and the student both use the high temperature while the student learns. Afterwards, the student goes back to the normal setting of one.

Copying the teacher cut a smaller model’s digit mistakes nearly in half

Copying the teacher cut a smaller model’s digit mistakes nearly in half.

teacher at 20student copies the whole spread01234567890123456789+ the answer key, turned down lowtest mistakesbig teacher67smaller model, answer key only146same smaller model, copying the teacher74

Hinton, Vinyals & Dean 2015 · section 2, page 3 · section 3, pages 3 and 4

The student trains to match the teacher's flattened guesses on every example. The student also gets a little credit for the plain right answer. Each example now carries ten grades instead of one tick. On handwritten digits, a big teacher model made sixty-seven mistakes on the test set. A smaller model, trained alone against the answer key, made a hundred and forty-six mistakes. The same smaller model made seventy-four mistakes when it copied the teacher at a temperature of twenty.

Margin notes about other digits taught the student what a 3 looks like

Margin notes about other digits taught the student what a 3 looks like.

no 3s in the student’s lessons2012456789the teacher’s key20123456789a bit like a 3faintly like a 7test 3s wrongbefore133 of 1,010after the nudge14 of 1,01098.6% rightnudge tuned on this same test

Hinton, Vinyals & Dean 2015 · section 3, page 4

Next, the team removed every 3 from the student's lessons. The teacher had seen plenty of 3s. The student only saw the teacher's guesses about other digits, including how much each digit looked like a 3. Before any fix, the student got a hundred and thirty-three of the test's one thousand and ten 3s wrong. So the team nudged the student toward answering 3. The team picked the size of that nudge using the test itself. After the nudge, the student got ninety-eight point six percent of the test 3s right.

With the teacher’s margin notes, a model trained on 3% came within 2 points of the full set

With the teacher’s margin notes, a model trained on 3% came within 2 points of the full set.

all the recordings3%sound slices labelled right44.5%3%answer key only57.0%3%copying the teacherteacher saw 100%58.9%100%answer keya slice is a hundredth of a second of sound

Hinton, Vinyals & Dean 2015 · Table 5, page 8 · section 4, page 5

Back on speech, the paper scores a model on tiny slices of sound, a hundred every second. The score is the share of slices the model labels with the right speech sound. The team trained a speech model on only three percent of the recordings. With the plain answer key, that model labelled forty-four point five percent of slices right. A second model saw the same three percent, with margin notes from a teacher trained on all the recordings. The second model labelled fifty-seven percent right. An ordinary model trained on all the recordings labelled fifty-eight point nine percent right.

On sound slices and on digits, the copies stayed a little behind their teachers

On sound slices and on digits, the copies stayed a little behind their teachers.

sound slices labelled right58.9%1 ordinary model61.1%10 models averaged60.8%1 model copying the 10on the digitsteacher · 67 mistakesstudent · 74tops of the bars, zoomed in58%62%the group’s gainover 80%kept by the copythe running cost of 1 model

Hinton, Vinyals & Dean 2015 · Table 1, page 5 · section 4.1, page 5 · section 3, page 4

This picture is roughly right, and here is where the picture breaks. On the sound-slice score, one ordinary speech model got fifty-eight point nine percent. The group of ten got sixty-one point one percent. The single copy got sixty point eight percent, three tenths of a point short of the group. The paper says more than eighty percent of the group's gain carried over to the copy. The copy runs as one model instead of ten.

In 2024, Google used the same copying to train its small Gemma 2 models

In 2024, Google used the same copying to train its small Gemma 2 models.

01234567892015 · a fixed list of answers10 digits · 14,000 speech soundsa chat model’s next token · about 256,000 choicestoken · a whole word or part of oneillustrativeGEMMA 2 REPORT, GOOGLE 2024a bigger teacher grades every candidate token

Hinton, Vinyals & Dean 2015 · section 4, page 5 · Gemma 2 report 2024 · section 1 · section 3.1

The second break is the date. The 2015 paper sorted things into fixed lists of answers, ten digits or fourteen thousand speech sounds. A chat model picks its next token, a word or a piece of a word, from a much longer list. Gemma two's list has about two hundred and fifty-six thousand tokens. Google's Gemma 2 report says its small models copied a big model's spread over every possible next token. Normal training would teach only the one token that came next. Google's report names no temperature setting, so the knob in this picture comes from the 2015 paper.

A student that copies graded guesses gets most of the way to its teacher

A student that copies graded guesses gets most of the way to its teacher.

60.8% for 1 copy · 61.1% for 10 models averaged

How it’s made · 4

answer keymarked-up key2012345678920123456789a bit like a 3faintly like a 7teacher0123456789temperature 20teacher at 200123456789student copies0123456789

Hinton, Vinyals & Dean 2015 · Table 1, page 5

Train a big teacher first. Show the teacher an example and keep every guess, the winner and the wrong ones. Turn up the temperature so the small guesses show. Train the student to copy that whole spread, plus a little of the plain right answer. The student picks up which things look alike, graded the way its teacher grades them. That is how one speech model came within three tenths of a point of ten models averaged together.