Knowledge distillation: A good teacher is patient and consistent
Paper · 2022 · Lucas Beyer, Xiaohua Zhai, Amélie Royer et al.
Summary
A large image classifier may give excellent predictions and still be too expensive to run wherever those predictions are needed. Knowledge distillation offers a way to keep a smaller classifier in service. During training, the smaller student learns to reproduce the predictions of a stronger teacher. The authors ask which training choices make that transfer effective. Their answer begins with the image itself. If the student sees a random crop, the teacher should predict from that crop too. A probability distribution produced from another view may describe evidence that the student cannot see.
The paper treats distillation as learning how the teacher responds to different inputs. The student receives the teacher’s full distribution over classes, including probabilities for alternatives to its first choice. A shared crop lets both classifiers respond to the same visible evidence. The authors then use mixup, which blends images, to give both classifiers additional inputs on which to compare their responses. The teacher evaluates each blend directly. As these views and blends change during training, the student has more opportunities to learn the teacher’s behavior. The authors find that this setup needs an unusually long training schedule to show its full advantage.
In experiments on Flowers102, Pets, Food101 and SUN397, the best long runs bring a ResNet-50 student close to a much more expensive ResNet-152x2 teacher, with the student recording slightly higher test accuracy on some datasets. The distinction between fitting the training targets and doing well on held-out images matters. On Flowers102, a student trained with fixed teacher predictions can reach a lower training loss while doing worse on the validation set than a student trained on shared views. On ImageNet, the fixed-target approach begins to overfit as training continues, while shared views keep yielding improvements over the schedules tested.
The strongest ImageNet result uses a teacher that combines predictions from classifiers operating at different resolutions. After 9600 epochs, the ResNet-50 student reaches 82.82% top-1 accuracy on the split the authors use for final testing. The recipe also works when the student uses a different architecture or receives a lower-resolution version of the teacher’s crop. The practical tradeoff is between the cost of training the student and the cost of using it afterward. The paper shows how extra work during training can improve a compact classifier whose deployment still requires only the student.
Deep dive: Knowledge distillation: A good teacher is patient and consistent
Knowledge distillation compresses image classifiers by having a smaller student learn from the same augmented images as its teacher over long training runs. · about 32 minutes to read
The problem and its context
Why compress a capable classifier?
The paper starts from a difference between the classifiers that set research benchmarks and those that practitioners can afford to use. Its introduction points to developments in image classification, object detection and semantic segmentation for which large architectures had achieved strong results. Its experiments concentrate on classification, where an image is assigned to a category. This setting gives the authors a direct way to ask how much of a strong classifier’s performance can be transferred to an architecture that costs less to run.
The authors use downloads of Big Transfer, or BiT, checkpoints to illustrate the demand for smaller architectures. Within the set they examine, the smallest ResNet is downloaded much more frequently than its larger relatives. Download counts provide a measure of interest in those checkpoints. The paper uses that observation to motivate a particular engineering problem. Given a strong classifier for an application and a compact architecture that would be practical to deploy, how can training bring the compact one closer to the stronger one?
That formulation starts with a teacher already trained for the task. The student has its own architecture and eventually has to answer by itself. A teacher may be expensive enough to rule out routine use while remaining feasible as a source of supervision during a training project. The authors’ usual teacher, BiT-M-R152x2, requires approximately 10x the compute of a standard ResNet-50. That estimate concerns the architectures’ compute requirements. It frames the potential benefit of serving predictions with the student even when producing the student is expensive.
The approaches available to the authors
Pruning addresses compression by removing parts of a trained network. The paper distinguishes pruning individual connections from removing larger structures such as channels. Some pruning schemes revisit their choices over several stages or train the remaining network further. The starting architecture matters because the pruned result still inherits much of its organization. The authors give group normalization as an example of a complication. Removing channels may leave the channel groups needing to be balanced again. A different architecture family can be a more natural starting point when the deployment requirements favor a MobileNet over a ResNet.
Distillation allows that choice because the student can learn by comparing predictions with the teacher. Both networks can assign probabilities to the same categories even when the computations that produce those probabilities differ. The paper follows the early formulation in which the student learns from the teacher’s distribution over classes. It also recognizes a broader usage of distillation in which the comparison can involve internal activations, the intermediate values produced as a network processes an input. Its own main recipe uses the final class probabilities. The earlier prediction-based formulation is described in Distilling the Knowledge in a Neural Network.
The related work describes several ways in which researchers had already used distillation for compression. They had varied the widths and depths of the teacher and student, and had combined distillation with other efficiency techniques. The authors single out the MEAL approach as a predecessor that trains a smaller ResNet with an ensemble of larger teachers and an adversarial loss. The present paper asks how far a conventional prediction-matching objective can go when the authors reconsider how they prepare the inputs and how long they train. An ensemble appears in their strongest run, but the main study of the training procedure begins with a single teacher.
The paper also places pruning and distillation alongside methods that address a different part of the cost. Quantization and decomposition can reduce memory or accelerate operations by approximating expensive computations. Architectural work can design compact classifiers around a specified compute budget. These lines of work help explain why the student architecture is a choice in the experiments. ResNet-50 gives the authors an established point of comparison, and MobileNet lets them test the same training idea with a different design. The original residual architecture is described in Deep Residual Learning for Image Recognition.
What should the teacher predict from?
A familiar way to supervise a classifier is to attach a category to each training image and retain it when generating a crop. Distillation can be organized in much the same way. A practitioner can run the teacher over the images ahead of time and store its probabilities, then use those probabilities to supervise the crops the student encounters. This makes sense as a way to amortize the cost of a large teacher. It also gives a concrete meaning to the authors’ question about consistency. Is a prediction stored for a whole image or a chosen crop a good target for a different crop of that image?
Consider a photograph of a pet in which a wide crop contains the animal’s head and body, while a tight crop shows only part of its coat. The teacher could assign different probabilities if asked to classify the two views. An offline target from the wide view can ask the student to express the same confidence from the smaller amount of evidence. A shared crop answers a different question. It asks what the teacher itself predicts given what the student can observe. The distinction applies even when the teacher would make the same first choice on both crops, because the distribution over other categories can still change.
Other uses of teacher–student training motivate different relationships between views. The paper discusses work in semisupervised learning that supplies different perturbations to the teacher and student. It also cites self-supervised work as another context in which one network learns from another. In those settings, what it means for the training signal to succeed can differ from reproducing the predictions of a fixed, strong classifier on particular inputs. One cited example from self-supervised learning is Bootstrap Your Own Latent.
This distinction gives the paper its organizing question. If the purpose is compression, each teacher prediction can be understood as an evaluation of a function at a particular input. The student’s assignment is to approximate that function. The authors use this view to connect decisions that can otherwise look independent. The crop determines which input the function is evaluated on, augmentation determines the variety of available inputs, and the schedule determines how long the student has to learn from them.
The method, step by step
From an image to a training target
The teacher learns the task before student training starts. The authors usually begin with BiT-M-R152x2, a wide residual network pretrained on ImageNet-21k, and adapt it to the classification task at hand. In its name, 152 describes the depth in layers and x2 describes its width multiplier. The default student is a BiT variant of ResNet-50. The BiT versions use group normalization and weight standardization in place of the standard ResNet’s batch normalization setup. Group normalization arranges channels into groups for normalization, and weight standardization operates on the network’s weights. Using a teacher adapted from prior training is an instance of fine-tuning.
The procedure begins with an image from the training data. A randomly chosen crop determines what part of that image the classifiers will see, and resizing puts the crop into the expected input dimensions. In the shared-view setup, the choice of crop is made once. A common augmentation pipeline gives both networks the same resulting view. When mixup is enabled, the pipeline also combines images, and the mixture itself becomes the input to both networks. For a reader following one example through training, the important fact is that there is a single choice of visual evidence behind each pair of predictions.
The teacher maps that view to a probability distribution over the task’s categories. The student produces a distribution over the same categories. If an image carries an ordinary category label, that label specifies the annotated class. The teacher’s distribution can express degrees of confidence and spread some weight among competing classes. Those weights enter the training objective. A teacher that assigns appreciable probability to several categories provides a different target from one that puts nearly all its probability on its first choice.
The comparison changes the student’s weights. The teacher remains fixed throughout this process, although its outputs change from view to view. When training returns to the same source image, a fresh crop or a new mixture can yield a new prediction. That difference between fixed teacher weights and fixed teacher targets is central to the recipe. At evaluation time the student classifies images by itself, and its predictions are scored against the dataset’s labels.
How the student learns from shared image views
The steps in order.
How mixup changes the training inputs
Ordinary random crops let the student encounter different views of existing photographs. Mixup adds inputs along the line between pairs of images. A blend can lie near one endpoint, where it resembles one of the original images more closely, or further from the endpoints, where both contribute substantially. The authors draw the mixing coefficient uniformly from [0, 1]. They describe this as an aggressive variant of the earlier mixup procedure, which draws coefficients from a beta distribution.
The linear blend described in the paper can be written as follows.
x̃ = λx + (1 − λ)x′
Here x and x′ are the two views being mixed, and x̃ is the resulting image. The symbol λ is the sampled mixing coefficient. The expression 1 − λ is its complementary weight, so the two contributions sum to 1. Multiplication scales each image’s pixel values, and addition combines them at corresponding positions.
For distillation, the significant detail is where the teacher enters this operation. The teacher receives x̃ and computes a distribution for that input. The target therefore comes from a fresh evaluation on the blended image. Combining predictions that were made separately on the endpoint images would make a different assumption, namely that the teacher’s responses interpolate in step with the pixels. In the authors’ procedure, the teacher determines how confidence changes on the blend.
Some blended or heavily cropped images can be difficult to assign to a single ordinary category. A shared-view distillation objective still gives a defined comparison for them. For any generated input, the student has a target distribution, even if it is spread out. The authors’ rationale is that response matching on a wider set of inputs can help the student generalize to ordinary held-out images. The held-out results are needed to test that rationale, since producing more synthetic inputs by itself establishes only that the training procedure can make more comparisons.
The objective and temperature
The loss is the Kullback–Leibler divergence from the teacher’s probability distribution to the student’s. It measures discrepancy on a shared input and gives more influence to categories on which the teacher places more probability. Here is the form used in the paper.
KL(pₜ ∥ pₛ) = ∑ᵢ∈C [−pₜ,ᵢ log(pₛ,ᵢ) + pₜ,ᵢ log(pₜ,ᵢ)]
KL denotes Kullback–Leibler divergence, and the symbol ∥ separates its arguments in order. The vector pₜ is the teacher’s class distribution and pₛ is the student’s. The subscripts ₜ and ₛ indicate teacher and student. The set C contains the possible classes, i indexes a class in that set, and ∑ᵢ∈C adds the bracketed contribution for every class. The expressions pₜ,ᵢ and pₛ,ᵢ are the teacher’s and student’s probabilities for class i. The function log takes the logarithm, and the minus and plus signs combine the student-dependent term with the term determined by the teacher’s own distribution.
For a fixed teacher and a given view, the teacher-only term is constant with respect to the student’s weights. The student can reduce the loss by moving probability towards classes to which the teacher assigns substantial weight. The order matters because it is the teacher’s probabilities that weight the contributions. The paper uses this objective by itself for student training, with no additional loss against the original hard labels. Those labels have a separate role in evaluating accuracy and in training the supervised baselines.
The authors also adjust the sharpness of the distributions with a temperature. Written with an explicit normalizer, the paper’s proportional rescaling has this form.
pᵣ,ᵢ = exp(log(qᵣ,ᵢ) / T) / ∑ⱼ∈C exp(log(qᵣ,ⱼ) / T)
The index r identifies either the teacher, t, or the student, s. The value qᵣ,ᵢ is that classifier’s original softmax probability for class i, and pᵣ,ᵢ is the probability after temperature adjustment. Softmax converts the classifier’s scores into a probability distribution. The symbol T is the temperature, log is the logarithm, exp is the exponential function, and / denotes division. The index j ranges over classes in C. The sum in the denominator normalizes the values so that they form a distribution over those classes.
A temperature of 1 leaves the distribution as it was. Raising the temperature makes the distribution less concentrated and increases the relative influence of alternatives to the top category. The comparison uses temperature-adjusted probabilities for both teacher and student. Temperature is a training setting the authors sweep in the smaller-dataset experiments. It is distinct from the coefficient in mixup, which is sampled to construct a new image.
The input alternatives in the study
The authors define several ways to supply views while keeping the general prediction-matching objective. The simplest fixed-target setting uses resized images and a precomputed teacher prediction. Another fixed setting takes the teacher’s prediction from a central crop and gives the student a mild random crop. A more elaborate fixed target averages teacher predictions over 1k inception-style crops. The student encounters random crops in that setting too. The authors verified that crop averaging improves the teacher’s performance, which makes it a stronger test of whether a carefully constructed stored target can serve the student.
In the independent-view setting the teacher evaluates an augmented input during training, but the crop decisions are separate. One version uses mild random crops and another uses heavier inception-style cropping. Inception-style cropping is the paper’s default random crop procedure before resizing unless an experiment specifies something else. The independent settings test whether it is enough to provide varied, freshly computed teacher predictions. The corresponding shared-view settings make the mild or heavy crop once and pass it to both sides. The final version adds mixup to the shared pipeline. The paper calls this version FunMatch, its short name for function matching.
The experiments at different resolutions preserve the same sequence of decisions about content. The authors crop the original high-resolution image before resizing it separately for the teacher and the student. In that setup the arrays can have different dimensions while depicting the same region. For the ensemble experiment the authors use teachers at different resolutions and average their logits, the scores before the conversion to probabilities. The student still receives one distribution as its training target and still serves as the only classifier needed after training.
How the authors train and choose runs
The default optimizer is Adam. The authors vary the initial learning rate, which controls the scale of parameter updates, and use a cosine decay schedule without warm restarts. They also vary decoupled weight decay, which applies weight shrinkage separately from the loss-gradient update. Gradient clipping caps the global L2 norm of the gradient at 1.0 to stabilize training. The usual batch contains 512 images. On ImageNet the batch size is 4096. Most of the smaller-dataset analysis uses 128 × 128 inputs to keep the experimental campaign manageable, while the standard ImageNet setup uses 224 × 224 inputs. The runs use Google Cloud TPUs.
On the smaller datasets, each distillation setting gets a grid over learning rate, weight decay and temperature. The initial learning rates are 0.0003, 0.001, 0.003 and 0.01. The weight decays are 1 · 10⁻⁵, 3 · 10⁻⁵, 1 · 10⁻⁴, 3 · 10⁻⁴ and 1 · 10⁻³. The temperatures are 1, 2, 5 and 10. This matters for the interpretation of the comparisons. A stored-target approach and a shared-view approach may fit at different rates, and the authors give the alternatives separate opportunities to work well under the grid. The validation set determines which run to highlight. Test results are reported for the selected runs.
The paper names Big Vision as the release location for code and checkpoints and uses TensorFlow Datasets to define its data splits. Its example ImageNet configuration is for 1200 epochs, with an initial learning rate of 0.03, weight decay of 0.0003, temperature of 1.0 and 5000 warmup steps before cosine decay. It uses an inception-style crop and horizontal flipping. The configuration illustrates a concrete training run. The paper also explores other durations, optimizers, resolutions and teacher choices, so the example settings describe only one part of the experimental program.
Experiments and results
What is measured and on which images?
The study uses Flowers102, Pets, Food101 and SUN397 for the extensive comparisons, then tests the recipe at ImageNet scale. The paper puts the range across its benchmarks at 37 to 1000 classes and 1020 to 1,281,167 training images. In the overview of the smaller benchmarks it gives 1020 training images for Flowers102, 3312 for Pets, about 68k for Food101 and 76k for SUN397. The sizes matter because an epoch counts passes through a training set. A schedule with a very large epoch count on Flowers102 and a shorter one on ImageNet operate on different amounts of data per epoch.
Classification accuracy is the reported measure. On ImageNet the paper explicitly reports top-1 accuracy, which checks whether the category with the highest predicted score matches the recorded label. Accuracy is measured on held-out images. Training loss answers a complementary question about agreement with the teacher on training inputs. A student can reproduce its training targets closely and still do poorly on new images, so the paper tracks the two quantities separately in its analyses of the training curves.
The split conventions are especially important for reading the ImageNet comparisons. For Flowers102 and SUN397, the authors use the named training, validation and test splits. For Pets and Food101, they use the first 90% of the named training split for fitting and the remainder for validation, with the named test split supplying the final results. For ImageNet they use the first 98% of the named training split for fitting and the remainder for selecting settings. The official ImageNet validation split serves as the final test set in the paper. The appendix overview of ImageNet runs uses the authors’ internal validation set, whereas the headline literature comparison uses the final test convention.
Smaller benchmarks and the supervised alternatives
The smaller-dataset comparisons ask whether the distilled student offers an advantage over other ways of training a ResNet-50. One baseline starts from scratch and uses the original class labels. The other transfers a ResNet-50 pretrained on ImageNet-21k to the classification task. The authors tune learning rate and weight decay for the baselines. The transferred ResNet-50 is an especially relevant reference because it already brings information from pretraining into the task while retaining the same compact architecture used for the student. The larger teacher supplies another reference, showing how close the student gets to the performance that motivated the transfer.
Flowers102 shows how sharply the outcome depends on the schedule. The student trained for 1000 epochs gives 77.51% final test accuracy. The reported result rises to 92.83% at 10,000 epochs and 95.54% at 100,000 epochs. At 1,000,000 epochs the selected student reaches 96.93%. The large teacher has 97.82% test accuracy and the transferred ResNet-50 has 97.50%. The supervised ResNet-50 trained from scratch has 66.38%. The longest reported student comes close to the strongest reference scores and remains below both of them on this split.
Flowers102 final test accuracy by training approach and student duration
Longer FunMatch runs move the student closer to the teacher and the transferred ResNet.
The numbers
| System or setting | accuracy % |
|---|---|
| ResNet-50 trained from scratch | 66.38 |
| FunMatch at 1000 epochs | 77.51 |
| FunMatch at 10,000 epochs | 92.83 |
| FunMatch at 100,000 epochs | 95.54 |
| FunMatch at 1,000,000 epochs (this paper) | 96.93 |
| Transferred ResNet-50 | 97.50 |
| ResNet-152x2 teacher | 97.82 |
The Pets benchmark appears as Pet37 in the appendix results. There, the student starts at 82.75% final test accuracy with 300 epochs and reaches 88.01% at 1000 epochs. The transferred ResNet-50 scores 88.20%, close to the student at that stage, while the scratch baseline scores 74.24%. With 3000 epochs the student reaches 90.08%, and with 30,000 epochs it reaches 91.06%. The teacher’s test accuracy is 91.03%. The student and teacher consequently finish with very similar observed accuracy even though their architecture costs differ.
Food101 gives an example in which brief training can lead to a different judgment of whether distillation helps. The student scores 83.29% on the test set at 100 epochs, below the transfer baseline’s 85.05%. It reaches 86.64% at 1000 epochs and 87.20% at 3000 epochs, compared with 86.24% for the teacher and 74.56% for supervised training from scratch. The transfer baseline is stronger than the short run and weaker than the longer ones. A comparison limited to the earliest reported endpoint would miss that change.
On SUN397 the sequence is similar. The student’s final test accuracy is 68.28% at 100 epochs, 73.46% at 1000 epochs and 74.26% at 3000 epochs. The transferred ResNet-50 scores 71.61%, training from scratch gives 60.63%, and the teacher scores 74.22%. The gains in these comparisons concern performance on the dataset labels. Since accuracy aggregates decisions across images, close scores for a teacher and student can come from different predictions on individual examples.
The appendix gives the learning rate, weight decay and temperature selected for individual durations. Thus the tabulated results compare trained recipes under different schedule budgets, each with its own validation-selected settings. They are more informative about what the authors could obtain at those budgets than about the effect of a single hyper-parameter in isolation. The transfer and supervised references likewise have their own tuned settings. The point of comparing them is to test the practical alternatives available for the same compact architecture.
ImageNet and the strongest ResNet-50
The move to ImageNet tests whether shared views still help with a much larger training collection and the standard input size. The base teacher reaches 83.0% top-1 accuracy. The paper compares the learning curves of a fixed teacher target, randomly selected views shared by teacher and student, and shared views with mixup. The fixed-target student begins to overfit after 600 epochs. Both shared-view approaches continue to improve as the authors extend the schedules. With the default teacher and the standard-resolution ResNet-50 student, the longest function-matching run gives 82.31% top-1 accuracy.
The schedule comparison also shows that a higher-capacity training setup can look worse at first. Function matching with mixup performs slightly worse than simple shared-view teaching on short ImageNet schedules. With longer training, its advantage becomes visible. The authors report that 1200 epochs of function matching are enough to match the performance of simple consistent teaching at 4800 epochs. They describe this comparison as a saving of 75% in compute resources. It refers to those training settings and should be read with the schedule and augmentation choices that produced the comparison.
The strongest student uses an ensemble teacher. One member runs on 224px inputs, the other on 384px inputs, and the pair’s logits are averaged. Students of the ensemble do better than students of the default teacher at every duration the authors tried for this comparison. After 9600 epochs the ensemble-trained student records 82.82% top-1 accuracy on the final ImageNet test split. The abstract and the literature comparison give the headline as 82.8%. The improved result comes from spending more resources on the source of supervision while retaining a single ResNet-50 for prediction.
The paper compares its strongest ResNet-50 with the original residual architecture, a BiT-M ResNet-50 pretrained on ImageNet-21k, and MEAL V2, another distillation approach. At 224 × 224 input resolution, the comparison reports 77.2% for the original ResNet, 78.4% for BiT-M-R50, 80.7% for MEAL V2 and 82.8% for FunMatch. These are literature comparisons at a common student architecture scale and input resolution. They put the result in context alongside training procedures that use different sources of supervision and different amounts of training.
ImageNet final test top-1 accuracy for ResNet-50 at 224 × 224
The student trained with FunMatch and the ensemble teacher has the highest reported accuracy in this comparison.
The numbers
| System or setting | top-1 accuracy % |
|---|---|
| Original ResNet-50 | 77.2 |
| BiT-M-R50 | 78.4 |
| MEAL V2 | 80.7 |
| FunMatch with ensemble teacher (this paper) | 82.8 |
Different resolutions and student architectures
The cross-resolution experiments probe how much freedom the shared-view approach leaves in choosing the deployment inputs. A ResNet-50 student operating at 160px, trained from a teacher operating at 224px, reaches 80.49% top-1 test accuracy. The paper describes that student as twice as fast, and compares its accuracy with the published 78.8% for a ResNet-50 at that lower resolution. In the literature comparison, the authors give their result as 80.5%. The comparison at the lower input size is with Revisiting ResNets.
In the reverse direction the student stays at 224px while the authors use a teacher adapted to 384px. This teacher attains 83.7% top-1 accuracy. Among the paired entries in the paper’s resolution study, the higher-resolution teacher gives the student a modest improvement at every schedule shown. The highest reported final test accuracy for that pairing is 82.64%, compared with 82.31% for the pairing with both teacher and student at 224px. This experiment changes the quality and detail available to the teacher while preserving the student’s input size and the region of the image that both classifiers inspect.
ImageNet top-1 test accuracy for the reported teacher and student resolution pairings
The higher-resolution teacher gives the strongest result among these single-teacher pairings, while the lower-resolution student retains substantial accuracy.
The numbers
| System or setting | top-1 accuracy % |
|---|---|
| Teacher at 224px and student at 160px | 80.49 |
| Teacher at 224px and student at 224px | 82.31 |
| Teacher at 384px and student at 224px (this paper) | 82.64 |
The student architecture can also change. The authors train MobileNet v3 Large from their teacher using function matching. In most of these experiments the MobileNet variant uses group normalization with 8 groups in place of batch normalization. The ImageNet experiment reports 74.60% accuracy after 300 epochs and 76.31% after 1200 epochs. The authors describe the latter as the best published MobileNet v3 result at the time. This experiment addresses an important part of the compression problem introduced at the start. The transfer can give supervision to a network from a different family because the teacher and student compare class predictions rather than requiring corresponding internal components.
What the ablations show
A good target depends on the view
The Flowers102 consistency study compares the fixed, independent and shared input strategies over 10,000 epochs. The fixed-target variants ask whether one stored probability distribution can supervise all student views of a training image. The comparison among them gives that strategy progressively more favorable conditions. It includes a simple resize, a central crop for the teacher and a teacher target that aggregates many crops. The independent-view alternatives go further by generating a fresh teacher prediction, leaving the mismatch between teacher and student crops as the central difference from the shared-view settings.
The shared-view alternatives obtain better validation performance on Flowers102, and function matching with mixup performs best in that comparison. The heavy-crop and mild-crop comparisons help identify what is changing. The relevant improvement comes from agreeing on which random view to classify. Fresh teacher predictions are useful when they describe the input presented to the student. Averaging predictions over many possible views can improve the teacher’s own performance as measured by the authors while leaving the student with a target that does not reflect its particular crop.
The training loss makes the comparison more revealing. The fixed teacher reaches a lower loss while generalizing worse on held-out Flowers102 images. A finite set of stored predictions gives the student a collection of targets that can be fitted closely. When the shared input changes, the student has to approximate the teacher on a broader collection of views, and a small training loss is harder to obtain. The measured result is better validation accuracy even with the higher training loss. This supports the authors’ focus on the usefulness of the target for the current view, rather than judging success by how quickly or completely the student fits the training targets.
The appendix compares the view strategies at multiple durations on the smaller datasets. The early rankings can be misleading because a setup that fits its training targets quickly has time to show its strengths sooner. A view strategy paired with a sufficiently long schedule reveals a different tradeoff. The repeat comparisons across datasets and durations let the authors ask whether the Flowers102 result is confined to a single small benchmark or a single set of choices for optimizer settings.
Longer training helps when the objective keeps supplying useful variation
The patience analysis varies the budget given to function matching and follows held-out accuracy through training. The long-run Flowers102 results keep improving through the durations the authors report, including the run at 1,000,000 epochs, without the overfitting they observe in fixed-target experiments. On ImageNet the fixed-target curve saturates and then degrades, while shared-view training keeps making progress. These results give content to the paper’s recommendation of long training. The effect depends on what the student is learning during those extra updates.
The comparison with ordinary supervised training makes that dependence clearer. The authors apply the long schedule and aggressive augmentations to ResNet-50 training on ImageNet with the dataset labels. They also try stochastic gradient descent with momentum, or SGD with momentum, as a stronger supervised optimization baseline alongside Adam. Momentum carries information from earlier gradients into subsequent updates. The label-trained classifiers perform worse than the distilled student and begin to overfit with long schedules. In this controlled comparison, the teacher’s targets are an important part of why the recipe works.
Mixup also changes what a short run can establish. Simple consistency already gives a meaningful teacher target for each crop. Adding blends expands the variety of inputs, and with short schedules the authors observe slightly worse ImageNet performance from the expanded training procedure. They suggest underfitting as an explanation. Over the longer schedules, function matching gains the advantage. The evidence is the reversal in the curves and the comparison between schedule endpoints. The explanation about the difficulty of fitting the expanded task is the authors’ interpretation of that pattern.
Changing the optimizer and starting weights
The authors test whether long schedules are partly a consequence of how they optimize the student. They replace Adam with Shampoo, an optimizer that uses a second-order preconditioner to adapt the scale and direction of updates. The paper reports that Shampoo reaches in 1200 epochs the ImageNet test accuracy Adam reaches at 4800 epochs, with little extra time per step in their setup. The authors also report consistent improvement over Adam across the settings they examine. This comparison keeps the function-matching task in view and changes the way the student moves towards a solution.
The Shampoo appendix describes an implementation intended to keep the added computation manageable. The preconditioning calculations are divided into blocks of at most 128x128, and inversions are distributed across TPU cores. The schedule warms up linearly through 1800 steps and then decays quadratically towards zero. The settings include weight decay of 0.000375. The efficiency claim consequently refers to a configured optimizer on the authors’ system, with a different schedule as well as a different update rule. It is a comparison of working training recipes.
Starting from pretrained student weights offers a different way to make early progress. The authors initialize ResNet-50 with BiT-M weights and compare it with a student initialized from scratch. For short ImageNet distillation runs the pretrained initialization improves accuracy by more than 2%, as the paper reports the change. At 1200 epochs the scratch student matches the initialized student, and at 4800 epochs it slightly overtakes it. A pretrained starting point can improve the result available under a short budget while offering a smaller benefit after the student has had time to learn from the teacher.
The initialization and optimizer experiments therefore examine distinct parts of the same cost problem. An optimizer affects how rapidly a run can make use of the training signal. Initialization affects which predictions and features the student starts with. The paper’s schedule comparisons show that a ranking measured early in training may be a poor guide to the best attainable result. They also show why that early ranking can still matter for someone working with a short training budget.
Changing the source of training images
The out-of-domain experiment asks how much of the method depends on having images from the teacher’s own task. The authors keep a teacher for Pets or SUN397 and change the images used for matching. They compare training on images from the task itself with training on images drawn from Food101 or ImageNet. The predictions always come from a teacher for the intended task. A food image passed to the Pets teacher receives a probability distribution over pet categories, so the training input source changes while the output categories remain fixed.
The task’s own images work best. Completely unrelated inputs still carry some usable supervision, but the resulting accuracies are weaker. The paper’s concrete example is a student that learns to classify pets with approximately 30% accuracy using food images annotated only by the Pets teacher’s soft predictions. Where the source images are related to or overlap with the task, the reported outcomes can approach those from in-domain distillation. The authors also observe that reaching that level can require more training.
These comparisons qualify the function-matching intuition in a practical way. A teacher can be evaluated on any input that meets the architecture’s format, and every such evaluation gives a target. The value of that target for the final task depends on the inputs chosen. A distribution produced on an unrelated photograph may convey something about the teacher’s response to visual patterns, yet coverage of responses on relevant images remains important. The experiment measures the resulting student’s accuracy on the intended task, which is the criterion against which the usefulness of those unusual targets is judged.
Limitations
Limits identified by the authors
The authors frame their contribution around compression. They distinguish this purpose from semisupervised and self-supervised uses of teacher–student training, where the choice of views may serve a different objective. Their evidence for shared inputs concerns a student trained to reproduce a strong classifier’s predictions. The paper begins from the wider deployment problem in vision, but the reported experiments evaluate image classification. The recipe’s behavior for the detection and segmentation systems mentioned in the introduction remains open.
The authors identify the cost of optimization as a bottleneck. Evaluating a large teacher during training and running the student for long schedules can make a training project costly. Their use of lower-resolution inputs on most datasets makes the extensive comparisons feasible, and they describe the Shampoo analysis as an initial exploration of a possible improvement. Their conclusion concerns the quality of the compact result that can be obtained with these resources. The amount of training required can be a central consideration even when the eventual student is inexpensive to run.
The out-of-domain study also gives an explicit boundary to the authors’ claim about flexible supervision. The data closest to the target task perform best, and the unrelated images yield weaker students. Related images can be a plausible substitute in the tasks examined, sometimes with an extended schedule. The paper also leaves the combination of its training method with quantization and decomposition for future study. Its measured results concern the students trained in the experiments, with their stated architectures and input sizes.
Limits of the evidence
The tables support a conclusion about classification accuracy, which is a narrower claim than reproducing the entire teacher function. Two classifiers can have similar top-1 accuracy and differ in which images they classify correctly, how much probability they assign to alternatives, or how they respond outside the observed benchmark. The distillation objective compares distributions during training, but the main numerical endpoints summarize agreement with labels on held-out images. The phrase “function matching” describes the training perspective and the loss being optimized. It does not certify pointwise agreement with the teacher.
The recorded Flowers102 endpoints are a useful check on how broadly to read the paper’s account of catching up. The longest tabulated student has 96.93% test accuracy, while the teacher has 97.82% and the transferred student architecture has 97.50%. On other datasets the distilled student sometimes finishes numerically ahead of the teacher. These are selected test endpoints, and the small differences alone do not establish that either classifier has a reliably better expected accuracy under repeated training. The paper reports numerous hyper-parameter runs, but its highlighted final scores serve a different purpose from uncertainty estimates over repeated runs with the same settings.
Most of the evidence comes from variants of a large BiT teacher and a ResNet-50 student. The MobileNet result extends that evidence to another student family, and the ensemble experiment extends it to a more expensive source of targets. They demonstrate that identical architectures are unnecessary. The evidence remains tied to the teacher quality, datasets, augmentations and schedules used. The results offer no general rule for which teacher a student of a given size can match, or how many updates will be needed on a new task.
The comparisons also address different resource questions. The literature table establishes the reported accuracy of compact classifiers at specified input sizes. The supervised control tests whether long training and aggressive augmentation are enough to account for the distillation gain in the authors’ ImageNet setup. The Shampoo experiment addresses training efficiency under the authors’ optimizer configurations. These experiments do not provide a complete accounting of teacher construction, student training and serving costs across every baseline. The lower-resolution speed result and the estimate of the base teacher’s compute give concrete deployment context, with their scope limited to the reported comparisons.
Finally, the fixed-target experiments cover the particular forms of caching the authors study. They test a simple fixed prediction, a central crop and an average over many crops. A system that stored targets indexed by the exact augmented views it would later present to a student would preserve the pairing examined in the shared-view conditions. Its practical costs and coverage would depend on how the views were chosen and stored. The paper’s result establishes the weakness of reusing an image-level target across the tested varying views. It leaves the broader design space of computation and storage tradeoffs open.
What came after
Distillation as a question of supervision and scale
Later citing work takes up related questions about what a teacher supplies and how that signal changes what a student can learn. The titles establish the scope of these connections. They identify work on reasoning, supervision, scaling, and other ways of using or improving strong systems. They give less detail about whether any particular work adopts shared augmentations, the same prediction loss, or the long schedules used for image classification.
A direct continuation of the question about training budgets is the study titled Distillation Scaling Laws. The vision experiments compare selected endpoints across schedule lengths and show that conclusions can change as the budget grows. The later work’s title puts the relation between scale and distillation at the center of the investigation. That is a broader question than whether a longer schedule helps a particular ResNet student on a particular benchmark. The concept itself is scaling laws. The later study is Distillation Scaling Laws.
Distilling Step-by-Step makes training data and student size explicit in its comparison with larger language systems. Its title describes a method under which a smaller system can outperform a larger one with less training data. Beyer and colleagues demonstrate the importance of budget in a different setting, where matching a vision teacher can improve with many more updates. The connection is the experimental question of what a teacher makes learnable under a constraint on the student. The task and the relevant constraints move from image classification and long training schedules to the setting identified by Distilling Step-by-Step!.
Mixed Distillation places the target capability at the center of its stated result. It studies whether a smaller language system reasons better when trained with mixed distillation. The name identifies a use of distillation concerned with the form of supervision. The image-classification study’s mixup has a more specific meaning, the linear blending of two images before they are classified. The later title gives no basis for equating those operations. Its stated focus is Mixed Distillation Helps Smaller Language Model Better Reasoning.
Weak-to-Strong Generalization takes up a different direction of supervision. The vision paper starts from a teacher chosen for high task accuracy and asks how well a smaller student can learn from it. The later work asks how weak supervision can elicit strong capabilities. That makes the quality of the supervision part of a different experimental question. Both works treat the relationship between teacher and learner as consequential, while their goals call for different meanings of success. The later question is set out in Weak-to-Strong Generalization.
Different outputs and routes to practical systems
Contextualization Distillation names a transfer from a language system to a knowledge graph completion task. In the vision paper, the output to be learned is a distribution over image classes for a view. The later title identifies contextualization as the object of distillation and completion as the application. It shows how the transfer question can be framed around information useful to a structured prediction task. The relevant representation is a knowledge graph. The study is Contextualization Distillation for Knowledge Graph Completion.
PURR addresses hallucinations in language outputs through denoising corruptions. Its focus makes altered examples part of learning how to edit an output. That gives it a point of comparison with the vision paper, where altered images make additional teacher responses available for learning. The operations serve different tasks. One is named as editing through denoising, and the other evaluates a classifier on a shared visual input. The citing work is PURR.
Model soups addresses the goal of improving accuracy while preserving inference time through an operation on weights. Its title specifies averaging weights from multiple fine-tuned systems. In the vision paper’s strongest experiment, aggregation occurs over teacher scores during training, and the resulting supervision is used to fit a single student. The two studies give concrete examples of where aggregation can enter a procedure aimed at better predictions within a serving budget. The weight-averaging approach is Model soups.
Scaling Vision Transformers and Gemini 1.5 place related questions in settings where the capabilities of large systems are themselves the focus. The former studies scaling Vision Transformers to 22 billion parameters, directly relevant to the vision paper’s motivation that strong vision architectures can be costly. Its title does not establish a compression result or a particular teacher–student procedure. The architecture belongs to the Transformer and attention family. The study is Scaling Vision Transformers to 22 Billion Parameters.
Gemini 1.5 concerns multimodal understanding over very long contexts. That scope places it within work on vision and language. It supplies a further setting in which a large system’s capabilities and the cost of making them available can matter, beyond classification over a fixed set of labels. The cited title establishes the long-context and multimodal subject, while the connection to the vision paper is the broader problem of how capabilities are made practical. The work is Gemini 1.5.
Cite
Cite as Lucas Beyer, Xiaohua Zhai, Amélie Royer, Larisa Markeeva, Rohan Anil and Alexander Kolesnikov. 2022. Knowledge distillation: A good teacher is patient and consistent. IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings - IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings.
@inproceedings{beyer2022knowledge,
title = {{Knowledge distillation: A good teacher is patient and consistent}},
author = {Lucas Beyer, Xiaohua Zhai, Amélie Royer, Larisa Markeeva, Rohan Anil and Alexander Kolesnikov},
booktitle = {IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings - IEEE Computer Society Conference on Computer Vision and Pattern Recognition/Proceedings},
year = {2022},
doi = {10.1109/cvpr52688.2022.01065},
eprint = {2106.05237},
archivePrefix = {arXiv},
url = {https://doi.org/10.1109/cvpr52688.2022.01065}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/beyer-2022-knowledge-distillation-good-teacher-is/