Similarity-Preserving Knowledge Distillation

Frederick Tung, Greg Mori

Introduction

Knowledge Distillation (KD) is a cornerstone technique for model compression, enabling the transfer of knowledge from large, computationally expensive "teacher" networks to smaller, efficient "student" networks. Traditional approaches typically force the student to mimic the teacher's softened output class scores (logits) or its intermediate feature maps. However, these methods can be overly restrictive, particularly when the student architecture lacks the capacity to replicate the teacher's exact representation space. Furthermore, logit-based KD is often limited to scenarios where the source and target domains share the same class labels.

This paper introduces Similarity-Preserving (SP) Knowledge Distillation, a novel paradigm that shifts the focus from absolute feature values to the relationships between inputs. By ensuring that semantically similar inputs elicit similar activation patterns in both networks, SP distillation provides a more flexible and robust supervisory signal.

Proposed Method

The core intuition behind SP distillation is that a well-trained network's knowledge is implicitly stored in how it groups and separates data points in its latent space. If a teacher network considers two images to be similar, the student should preserve this relative relationship, even if its internal coordinate system differs.

Overview of the Similarity-Preserving (SP) Knowledge Distillation framework.

The SP distillation process follows three primary steps:

  1. Mini-batch Extraction: For a mini-batch of $b$ images, activation maps are extracted from corresponding layers in the teacher and student.
  2. Similarity Matrix Computation: These maps are reshaped, and a $b \times b$ pairwise similarity matrix is generated for each network. This matrix is calculated as the row-wise L2-normalized outer product of the activations, representing how the network perceives the similarity between every pair of images in the batch.
  3. Distillation Loss: The student is trained using a loss function defined as the Frobenius norm (mean element-wise squared difference) between the teacher’s and student’s similarity matrices.

Key Insights

  • Relational Transferability: The teacher's "relational knowledge"—how it structures the manifold of data—is highly transferable. This approach allows the student to find its own optimal representation space while maintaining the semantic clustering learned by the teacher.
  • Domain Shift Robustness: Unlike logit-based methods, SP distillation does not require class labels. This makes it exceptionally effective for transfer learning tasks where the target domain (e.g., textures) differs significantly from the teacher's source domain (e.g., ImageNet).
  • Layer Specificity: Empirical results suggest that activation similarities are most informative in deeper layers (final convolutional blocks). While early layers capture generic features, deeper layers encode the specialized semantic distinctions necessary for meaningful similarity matrices.

Experimental Results

The authors evaluated SP distillation across multiple benchmarks, including CIFAR-10, the Describable Textures Dataset (DTD), and CINIC-10.

Comparison of similarity matrices between student (WideResNet-16-1) and teacher (WideResNet-40-2) architectures, demonstrating how relational patterns are preserved across different capacities.
  • CIFAR-10: SP distillation consistently outperformed standard training and traditional KD. For a WideResNet-16-1 student, SP distillation achieved an error rate of 8.13%, compared to 8.48% for traditional KD and 8.30% for Attention Transfer (AT).
  • Transfer Learning (DTD): When fine-tuning MobileNet architectures on specialized texture data, SP distillation reduced error by up to 1.3% absolute compared to standard fine-tuning.
  • Hybrid Approaches: The study found that SP distillation is complementary to spatial Attention Transfer. Combining both techniques on a ShuffleNetV2-0.5 student for CINIC-10 resulted in a significant error reduction of 1.9% over the baseline, reaching 18.20%.

Conclusion and Future Work

Similarity-Preserving Knowledge Distillation offers a powerful alternative to traditional feature-mimicking methods by focusing on the structural relationships within data. While current implementation relies on mini-batch statistics, the label-agnostic nature of the similarity matrix opens significant avenues for omni-supervised learning. Future research could leverage massive unlabelled datasets to distill relational knowledge from teachers at a scale previously impossible with supervised distillation methods.

Summary updated

BibTeX
@inproceedings{tung2019similarity,
  author = {Frederick Tung and Greg Mori},
  title = {{Similarity-Preserving Knowledge Distillation}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2019},
  doi = {10.1109/iccv.2019.00145},
}
Figure