Similarity Transfer for Knowledge Distillation

Haoran Zhao, Kun Gong, Xin Sun, Junyu Dong, Hui YuarXiv 2021

Abstract

Deep learning models often face deployment challenges due to their massive computational requirements. Knowledge Distillation (KD) addresses this by training a smaller "student" model to mimic a larger "teacher." However, standard KD often overlooks the "dark knowledge" found in inter-class relationships. This paper introduces Similarity Transfer for Knowledge Distillation (STKD), a method that utilizes the mixup technique to create virtual training samples. By training on these interpolated samples, the student captures subtle similarity correlations between categories, leading to state-of-the-art performance without manual hyperparameter tuning. Experiments across multiple benchmarks demonstrate that STKD consistently outperforms vanilla KD and other advanced distillation methods.

Introduction

The deployment of high-performing deep neural networks on edge devices is limited by their size and complexity. Knowledge Distillation (KD) has emerged as a primary solution, where a compact student model learns from the output probabilities of a cumbersome teacher model.

Traditional "vanilla" KD typically focuses on instance-level predictions. For example, if a teacher identifies an image as a cat, it provides a high-probability label for that specific class. The authors argue that this approach ignores the rich information contained in the relationships between classes—such as the fact that a cat is semantically closer to a dog than to a car. Standard KD often produces over-confident predictions that obscure these useful similarity correlations. Furthermore, existing methods to capture these relationships frequently require complex loss functions or the manual tuning of a "temperature" hyperparameter to soften the probability distributions.

Proposed Method: Similarity Transfer Knowledge Distillation (STKD)

The core innovation of STKD is the integration of Mixup Data Augmentation into the distillation process to naturally reveal inter-class similarities.

Comparison between Vanilla Knowledge Distillation and the proposed Similarity Transfer Knowledge Distillation (STKD).

1. Creating Virtual Samples

Instead of using raw images, STKD employs mixup to generate "virtual samples" by linearly interpolating two random images and their corresponding labels (e.g., a blend of 40% cat and 60% dog).

2. Natural Softening of Distributions

Because these virtual samples are inherently ambiguous, the teacher model naturally produces a "softer," more distributed probability output. This eliminates the need for the manually tuned temperature parameter ($t$) used in vanilla KD to prevent over-confident, one-hot-like distributions.

3. The STKD Loss Function

The student is trained using a total loss ($L_{total}$) that combines a classification loss based on the mixed labels and a distillation loss (KL Divergence). This forces the student’s output to match the teacher’s nuanced predictions on the virtual samples.

Experimental Results

The authors evaluated STKD on four widely recognized image classification benchmarks: CIFAR-10, CIFAR-100, CINIC-10, and Tiny-ImageNet. STKD consistently outperformed vanilla KD and other state-of-the-art methods like Attention Transfer (AT), Similarity Preservation (SP), and Relational Knowledge Distillation (RKD) across various architectures (ResNet, WideResNet, VGG).

Top-1 Accuracy curves on CIFAR-100 comparing (a) Teacher, Student, and STKD, and (b) STKD against other state-of-the-art KD methods.

Key Findings

  • Accuracy Gains: On CIFAR-100, STKD improved the accuracy of a WRN-40-1 student by 2.55% over the baseline and 1.29% over vanilla KD.
  • Effective Compression: A student model with only 0.56M parameters trained via STKD achieved 85.94% accuracy on CINIC-10, nearly matching the 2.20M parameter teacher model.
  • Robustness: The method proved effective even when the teacher and student belonged to different architectural families, such as distilling from a ResNet-50 to a MobileNetV2.
  • Optimal Mixing: Empirical results showed that a mixup coefficient ($\lambda$) of 0.50—a 50/50 blend—provided the best results by maximizing the "softness" of the teacher's guidance.

Conclusion

Similarity Transfer for Knowledge Distillation (STKD) provides a simple yet powerful framework for improving model compression. By forcing the student to learn from the semantic space between categories using virtual samples, STKD captures "dark knowledge" more effectively than traditional methods. It simplifies the training pipeline by removing the need for temperature tuning while delivering superior accuracy and robustness across diverse datasets and architectures.

Summary updated

BibTeX
@misc{zhao2021similarity,
  author = {Haoran Zhao and Kun Gong and Xin Sun and Junyu Dong and Hui Yu},
  title = {{Similarity Transfer for Knowledge Distillation}},
  year = {2021},
  eprint = {2103.10047},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.10047},
}
Figure