On the Surprising Efficacy of Distillation as an Alternative to Pre-Training Small Models

Sean Farhat, Deming Chen · DOI

TL;DR

This paper proposes a novel approach to training small machine learning models by leveraging large, pre-trained "teacher" models. Instead of costly pre-training, small "student" models can achieve comparable or better performance by learning from a teacher through a contrastive learning-based distillation method, significantly reducing training time and computational resources.

What Problem Does This Paper Address?

The field of machine learning is increasingly dominated by massive "foundation models" that exhibit impressive performance and generalization capabilities. However, these models are computationally expensive to train and deploy, making them unsuitable for resource-constrained environments. Small models offer advantages in terms of cost, energy efficiency, and deployment flexibility, but they typically lag behind larger models in performance, especially when trained from scratch or with limited data. The authors address the challenge of enabling small models to benefit from the advancements in large models without incurring the prohibitive costs of pre-training. They question whether extensive pre-training is truly necessary for small models or if their performance can be boosted by effectively transferring knowledge from a pre-trained teacher.

Methods

The core of the paper's contribution lies in a novel distillation paradigm that connects knowledge distillation (KD) with modern contrastive learning. The proposed method, termed "Alignment/Uniformity" (A/U) based contrastive distillation, works as follows:

  1. Pre-trained Teacher: Utilize an existing, large pre-trained model (the "teacher") as a source of knowledge. This teacher can be optionally fine-tuned on the target task.
  2. Contrastive Distillation Loss: The student model learns by mimicking the teacher's behavior. This is achieved through a distillation loss that is formulated based on contrastive learning principles. Specifically, it pulls "positive pairs" (representations of the same input from teacher and student) closer together and pushes "negative pairs" apart. The authors adapt the Alignment and Uniformity (A/U) objective from contrastive learning, which is computationally efficient.
  3. Generative Data Augmentation: For data-limited scenarios, the authors leverage pre-trained generative models (specifically, Stable Diffusion) to create synthetic data. This augmented dataset is then used for distillation, further improving the student's performance and generalization.

This approach allows for flexible teacher-student architecture pairings and integrates well with existing contrastive learning frameworks.

Datasets

The paper evaluates its method on a variety of datasets:

  • Standard Vision Benchmarks: CIFAR-10 and CIFAR-100.
  • Data-Limited Datasets: MIT-67, CUB-2011, DTD, and Caltech-101.

The authors do not introduce new datasets but rather focus on demonstrating the efficacy of their method on existing benchmarks, particularly highlighting its benefits in data-limited regimes.

Key Insights and Ideas

  • Pre-training is not always necessary for small models: The paper challenges the conventional wisdom that small models must undergo extensive pre-training to achieve high performance. Instead, they can effectively "inherit" the benefits of pre-training by learning from a larger, pre-trained teacher.
  • Distillation as a shortcut to pre-training benefits: By framing distillation through the lens of contrastive learning, the authors show that a small model can learn a rich representation that mimics a pre-trained model, achieving comparable or superior results without the associated computational cost.
  • Flexibility in architecture pairings: The contrastive learning formulation makes the distillation process agnostic to the specific architectures of the teacher and student models, opening up possibilities for diverse pairings.
  • Generative models as powerful data augmenters for distillation: For data-scarce tasks, synthetic data generated by diffusion models can significantly boost the performance of distilled small models, bridging the gap to pre-trained models.
  • Computational efficiency is key: The A/U contrastive loss is chosen for its low computational cost, aligning with the goal of making powerful models accessible for smaller-scale applications.

Key Results

  • Performance: The proposed method (A/U) often matches or surpasses the performance of standard pre-training followed by linear probing (S-LP) on various datasets. For instance, on CIFAR-10, their method achieved 94.55% accuracy with a MobileNetV2 student and ViT-B-16 teacher, compared to 74.84% for S-LP.
  • Speedup: The most striking result is the significant reduction in training time. The paper highlights training speedups of up to 94% compared to the standard pre-training paradigm, without sacrificing performance.
  • Data-Limited Regimes: The method shows particular promise in data-limited scenarios (MIT-67, CUB-2011, DTD, Caltech-101), where it can achieve performance close to, and often surpass, pre-training, especially when augmented with synthetic data.
  • Comparison to prior KD methods: The A/U method is shown to be competitive with or superior to other state-of-the-art KD algorithms like KD (Hinton et al., 2015), CRD++, and SRRL, while being computationally cheaper.

Limitations and Future Work

  • Data-Limited Dependency: The paper notes that the phenomenon of surpassing pre-training performance tends not to occur if the task is data-limited. However, this is alleviated by generative data augmentation.
  • Generative Model Cost: While the distillation itself is efficient, the cost of generating synthetic data using diffusion models can be non-trivial, though it is still often less than full pre-training.
  • Future Work: The authors suggest exploring other contrastive learning algorithms and their integration into distillation. They also imply that further advancements in generative models could further enhance this approach. The work aims to keep the door open for practitioners who might be discouraged by the scale of foundation models.

Summary updated

BibTeX
@misc{farhat2024surprising,
  author = {Sean Farhat and Deming Chen},
  title = {{On the Surprising Efficacy of Distillation as an Alternative to Pre-Training Small Models}},
  year = {2024},
  eprint = {2404.03263},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.03263},
}
Figure