Precise Knowledge Transfer via Flow Matching

Shitong Shao, Zhiqiang Shen, Linrui Gong, Huanran Chen, Xu DaiarXiv 2024 · DOI

Abstract

Knowledge Distillation (KD) is a cornerstone of model compression, yet it is often hampered by the significant distribution gap between teacher and student models. We introduce FM-KT (Knowledge Transfer with Flow Matching), a framework that utilizes Continuous Normalizing Flows (CNFs) to bridge this gap through a sequence of precise, manageable steps. By employing Rectified Flow for direct distribution mapping and a novel serial training paradigm to prevent information leakage, FM-KT achieves state-of-the-art performance across computer vision benchmarks. We also present a lightweight variant, FM-KT$^Θ$, which offers these performance gains with zero additional inference cost.

Introduction

The efficacy of Knowledge Distillation (KD) depends heavily on how well a student model can mimic the internal representations of a high-performing teacher. Traditional KD methods attempt to align these distributions in a single step, which often proves imprecise due to the complexity of the feature spaces. Recent diffusion-based methods attempt a multi-step approach but introduce inefficiencies by routing features through Gaussian noise. Furthermore, these methods are susceptible to a "cheating" effect, where the alignment network learns a trivial mapping rather than a robust feature transformation.

The FM-KT Framework

FM-KT addresses these limitations by leveraging Continuous Normalizing Flows (CNFs) and Flow Matching. Unlike diffusion models, FM-KT uses Rectified Flow to map the student's distribution directly to the teacher's along a deterministic, straight-line path. This approach avoids the information loss associated with Gaussian noise detours.

The FM-KT framework is highly flexible, supporting various encoders and distillation metrics.

The framework is designed to be "plug-and-play," supporting diverse meta-encoder architectures such as MLPs, CNNs, and Transformers. It integrates seamlessly with standard metric-based distillation losses, including vanilla KD, Decoupled Knowledge Distillation (DKD), and DIST.

Serial Training Paradigm

A core technical contribution of FM-KT is the Serial Training Paradigm. To ensure the meta-encoder learns a meaningful, progressive transformation, the authors developed a scheme that prevents the model from accessing the final teacher output prematurely. This safeguard forces the model to learn how to correct the student's features incrementally, leading to a more robust and generalizable mapping.

The serial training paradigm ensures the model learns a progressive transformation without "cheating."

Key Insights: Progressive Transformation and Ensembling

The success of FM-KT is rooted in two key insights:

  1. Ease of Learning: Breaking the alignment task into multiple steps (multi-step sampling) significantly simplifies the learning objective for the meta-encoder, allowing for higher precision.
  2. Implicit Ensembling: Mathematically, the multi-step sampling process in FM-KT acts as a form of implicit ensembling. By averaging outputs across multiple time-steps, the model achieves better generalization and higher accuracy.

Experimental Results

FM-KT was evaluated on CIFAR-100, ImageNet-1k, and MS-COCO, consistently outperforming previous state-of-the-art methods like DiffKD.

  • CIFAR-100 Classification: For a ResNet56-ResNet20 pair, FM-KT reached 74.97% accuracy, a significant improvement over the 69.06% student baseline and DiffKD's 71.92%.
  • ImageNet Classification: A ResNet18 student distilled from a ResNet34 teacher achieved 73.17% Top-1 accuracy, surpassing the previous best of 72.49%.
  • Object Detection: On MS-COCO, FM-KT improved the mAP of a Retina-Res50 student by +3.1 points when distilled from an FCOS-Res101 teacher.

Efficiency and Deployment

To address the potential latency of multi-step inference, the authors introduced FM-KT$^Θ$ (Lightweight). This variant distills the knowledge from the flow process back into the student's original classification head. During deployment, the meta-encoder is removed, resulting in zero additional inference cost while maintaining performance levels very close to the full multi-step version.

Conclusion

FM-KT provides a precise and efficient framework for knowledge transfer by utilizing the principles of flow matching. Its ability to decompose complex distribution alignment into manageable steps, combined with a robust training paradigm, sets a new standard for knowledge distillation. Future research will explore extending this framework to other domains, such as natural language processing and multi-modal learning.

Summary updated

BibTeX
@misc{shao2024precise,
  author = {Shitong Shao and Zhiqiang Shen and Linrui Gong and Huanran Chen and Xu Dai},
  title = {{Precise Knowledge Transfer via Flow Matching}},
  year = {2024},
  eprint = {2402.02012},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2402.02012},
}
Figure