[Paper Review] Comparing Kullback-Leibler Divergence and Mean Squared Error Loss in Knowledge Distillation
This paper proposes replacing the standard Kullback-Leibler (KL) divergence loss in knowledge distillation with mean squared error (MSE) loss between teacher and student logit vectors, demonstrating that direct logit matching via MSE outperforms KL divergence across multiple benchmarks. The key contribution is that MSE enables more accurate logit matching, leading to improved generalization, especially when the student model is smaller than the teacher.
Knowledge distillation (KD), transferring knowledge from a cumbersome teacher model to a lightweight student model, has been investigated to design efficient neural architectures. Generally, the objective function of KD is the Kullback-Leibler (KL) divergence loss between the softened probability distributions of the teacher model and the student model with the temperature scaling hyperparameter tau. Despite its widespread use, few studies have discussed the influence of such softening on generalization. Here, we theoretically show that the KL divergence loss focuses on the logit matching when tau increases and the label matching when tau goes to 0 and empirically show that the logit matching is positively correlated to performance improvement in general. From this observation, we consider an intuitive KD loss function, the mean squared error (MSE) between the logit vectors, so that the student model can directly learn the logit of the teacher model. The MSE loss outperforms the KL divergence loss, explained by the difference in the penultimate layer representations between the two losses. Furthermore, we show that sequential distillation can improve performance and that KD, particularly when using the KL divergence loss with small tau, mitigates the label noise. The code to reproduce the experiments is publicly available online at https://github.com/jhoon-oh/kd_data/.
Motivation & Objective
- To investigate how the temperature scaling hyperparameter τ in KL divergence loss affects knowledge distillation performance.
- To address the lack of theoretical and empirical understanding of why soft labels improve generalization in knowledge distillation.
- To propose a direct logit matching method using MSE loss as an alternative to KL divergence for improved student model performance.
- To evaluate the robustness of different loss functions under noisy label settings.
- To explore sequential distillation strategies for improving performance when there is a large capacity gap between teacher and student models.
Proposed method
- Theoretical analysis shows that as τ → ∞, KL divergence loss approximates logit matching; as τ → 0, it approximates label matching.
- Proposed a direct logit matching framework using MSE loss between student and teacher logit vectors, bypassing soft probability distributions.
- Used visualization techniques (Müller et al., 2019) to compare penultimate layer representations of models trained with KL and MSE losses.
- Conducted sequential distillation by first training with KL loss (τ = 3) and then fine-tuning with MSE loss to improve performance on large capacity gaps.
- Evaluated robustness to label noise by randomly flipping labels in CIFAR-100 and measuring test accuracy under different loss functions.
- Reproduced experiments using publicly available code from GitHub to ensure reproducibility.
Experimental results
Research questions
- RQ1How does the temperature scaling hyperparameter τ in KL divergence loss affect the generalization behavior of knowledge distillation?
- RQ2Can direct logit matching via MSE loss outperform KL divergence loss in knowledge distillation?
- RQ3What is the difference in penultimate layer representation learning between models trained with KL divergence and MSE loss?
- RQ4Does sequential distillation—first using KL loss then MSE—improve performance when the capacity gap between teacher and student is large?
- RQ5How do different loss functions perform under noisy label settings, particularly in terms of mitigating overfitting to incorrect labels?
Key findings
- The MSE loss outperforms KL divergence loss across all evaluated datasets, achieving 75.78% test accuracy on CIFAR-100 compared to 75.47% with KL (τ=20).
- When using the same teacher and student architecture, the MSE loss achieves higher performance than any KL divergence configuration, including τ=20.
- KL divergence with τ=20 achieves 75.47% accuracy, while MSE achieves 75.78%, indicating that direct logit matching is more effective than soft label matching.
- Sequential distillation (KL followed by MSE) improves performance on large capacity gaps, outperforming direct distillation with either loss alone.
- In noisy label settings with 40% symmetric noise, KL loss with τ=0.5 achieves the best generalization, outperforming both MSE and high-τ KL, due to implicit label smoothing.
- The model trained with MSE loss preserves the teacher’s penultimate layer representations more faithfully than the model trained with KL loss, which distorts them by elongating the representations.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.