Improved knowledge distillation by utilizing backward pass knowledge in neural networks

Aref Jafari, Mehdi Rezagholizadeh, Ali Ghodsi

TL;DR

This paper introduces a novel approach to knowledge distillation (KD) that uses the "backward pass" to identify where a student model fails to mimic its teacher. By generating auxiliary training samples in these high-divergence regions, the authors significantly improve the student's performance across computer vision and NLP tasks, especially in data-scarce scenarios.

What Problem Does This Paper Address?

Knowledge Distillation is a popular model compression technique where a small "student" network learns to mimic a large "teacher" network. Standard KD focuses on the forward pass: it tries to match the student’s output to the teacher’s output for a given set of training data.

However, there is a catch. Even if the student matches the teacher perfectly on the training points, it might behave wildly differently in the "gaps" between those points. This is a data insufficiency problem. If we don't have enough samples to cover the input space, the student never learns the teacher's behavior in those "dark" regions. Previous attempts to fix this, like Sobolev training, involve matching gradients (Jacobian matrices), which is computationally expensive and often impractical for large-scale models or discrete data like text.

Methods

The authors propose an iterative Minimax approach to bridge this gap:

  1. Maximization Step (Finding the Gaps): The authors define a new loss function, $L_{BKD}$, which is simply the squared difference between the teacher and student outputs. They then use gradient ascent to perturb existing training samples in the direction that maximizes this difference. This effectively "pushes" data points into regions where the student and teacher disagree the most.
  2. Minimization Step (Closing the Gaps): These newly generated "auxiliary" samples are labeled by the teacher and added to the training set. The student is then retrained using standard KD on this augmented dataset to minimize the divergence in those previously problematic areas.
The difference between standard KD (a) and the proposed backward pass knowledge approach (b).

Handling NLP

Applying this to Natural Language Processing (NLP) is tricky because text tokens are discrete—you can't simply "perturb" a word in the direction of a gradient. The authors solve this by working in the embedding space. Since teacher and student models often have different embedding dimensions, they derive a transformation matrix $Q$ (using a least-squares pseudo-inverse method) to map student embeddings to the teacher's space, allowing them to calculate gradients and generate auxiliary samples even for text.

The procedure for utilizing auxiliary samples in NLP models by mapping embedding spaces.

Datasets

The method was evaluated on:

  • Synthetic Data: A polynomial function to visualize the intuition.
  • Computer Vision: MNIST (handwritten digits) and CIFAR-10 (object classification).
  • NLP: The GLUE benchmark, including tasks like CoLA, SST-2, MRPC, STS-B, QQP, MNLI, QNLI, RTE, and WNLI.
  • Few-Sample Scenarios: Subsets of GLUE (5-10% of data) to test performance when data is extremely limited.

Key Insights and Ideas

  • Adversarial Distillation: The core idea is essentially "adversarial" in nature—finding the worst-case divergence to make the student more robust.
  • Gradient as a Proxy: Instead of matching full Jacobian matrices (which is slow), they use the gradient of a scalar loss ($L_{BKD}$) with respect to the input. This provides a computationally efficient way to capture "backward knowledge."
  • Visualizing Divergence: Figure 2 illustrates the "aha moment": standard KD might intersect the teacher at training points ($x_1, x_2, x_3$), but the proposed method finds the peaks of the error curve ($x'_1, x'_2$) to force the student to align better across the whole function.
Visualizing how auxiliary samples (purple dots) are generated in regions where the student (blue) and teacher (red) diverge.

Key Results

  • MNIST: A student network 160x smaller than the teacher achieved a 4% improvement over standard KD, reaching 91.45% accuracy.
  • CIFAR-10: Using an Inception v3 teacher and MobileNet v2 student, the method improved accuracy by ~1% over standard KD.
  • GLUE Benchmark: The method improved the distilroBERTa-base student by an average of 1.5 points across all tasks.
  • Few-Sample Success: In scenarios with only 5-10% of training data, the method showed even more significant gains (e.g., a nearly 1 point jump in the overall GLUE score compared to standard KD), proving that generated auxiliary samples can effectively substitute for missing real data.

Limitations and Future Work

The authors acknowledge a few hurdles:

  • Computational Cost: Generating auxiliary samples for every data point in a massive dataset can be expensive.
  • Sample Efficiency: Not all generated auxiliary samples contribute equally to the student's learning. Some might be redundant.
  • Future Directions: The authors suggest exploring ways to selectively perturb only the most "informative" samples to reduce the computational overhead in large-scale applications.

Summary updated

BibTeX
@misc{jafari2023improved,
  author = {Aref Jafari and Mehdi Rezagholizadeh and Ali Ghodsi},
  title = {{Improved knowledge distillation by utilizing backward pass knowledge in neural networks}},
  year = {2023},
  eprint = {2301.12006},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2301.12006},
}
Figure