Compressing Visual-linguistic Model via Knowledge Distillation

Zhiyuan Fang, Jianfeng Wang, Xiaowei Hu, Lijuan Wang, Yezhou Yang, Zicheng Liu

Abstract

Large-scale visual-linguistic (VL) models have achieved remarkable success but remain computationally prohibitive for edge deployment. This paper presents DistillVLM, a framework that compresses VL transformer models by addressing the critical issue of input misalignment between teacher and student detectors. By adapting the teacher model to the student's visual proposals and utilizing a novel contrastive loss for hidden state distillation, DistillVLM achieves a 70% reduction in parameters while significantly outperforming non-distilled baselines in tasks such as image captioning and visual question answering.

Introduction

Large-scale Visual-Linguistic Pre-training (VLP) has revolutionized cross-modal understanding, enabling models to excel at tasks like image captioning and visual question answering (VQA). However, the massive parameter counts of these transformer-based models pose significant deployment challenges, particularly for edge devices with limited computational resources. While Knowledge Distillation (KD) is a standard technique for model compression, visual-linguistic models present a unique challenge: input misalignment.

Most VL models rely on object detectors to extract visual tokens. A disparity typically exists between the heavy, accurate detector of a "Teacher" model and the lightweight, fast detector of a "Student" model. This misalignment in region proposals prevents the student from effectively learning from the teacher's intermediate representations because they are essentially "looking" at different parts of the image.

The DistillVLM Framework

To address these challenges, the researchers introduced DistillVLM, a framework designed to bridge the gap between teacher and student models through three primary innovations.

Teacher Adaptation

The core of the misalignment problem lies in the different visual tokens processed by each model. DistillVLM employs "Teacher Adaptation," where the teacher model is fine-tuned to use the exact region proposals generated by the student’s lightweight detector. This ensures that both models are aligned in their input space, making intermediate layer distillation feasible.

Attention and Hidden State Distillation

Beyond input alignment, DistillVLM optimizes the transfer of knowledge through two specific loss functions:

  • Attention Distribution Distillation ($\mathcal{L}_{ATT}$): Using Mean Square Error (MSE), the student is trained to mimic the self-attention patterns of the teacher’s final transformer layer. This helps the student learn how the teacher relates textual tokens to specific image regions.
  • Hidden Representation Distillation via NCE ($\mathcal{L}_{HID}$): Instead of simple feature matching, the framework utilizes Noise Contrastive Estimation (NCE). By contrasting positive pairs (the same token) against a large queue of negative pairs, the student learns the relative relationships between tokens, which proves more robust than mimicking raw numerical values.
Overview of the DistillVLM framework, highlighting teacher adaptation and the distillation losses.

Experimental Results

The framework was evaluated using a 34.5M parameter student model (a 70% reduction from the 111.7M parameter OSCAR-base teacher) across benchmarks like COCO Captions and VQA 2.0.

Performance and Efficiency

DistillVLM significantly outperformed non-distilled baselines. On COCO Captions, it achieved a 120.8 CIDEr score, a 5.1-point improvement over a student trained without distillation. In VQA 2.0, accuracy reached 69.8%. Furthermore, the use of a lightweight detector (TEE) reduced inference time by approximately 90% compared to standard Faster R-CNN detectors.

Data Efficiency

One of the most striking findings was the model's robustness to limited data. As shown in the performance analysis, a distilled model trained on just 1% of the available data significantly outperformed its non-distilled counterpart. This suggests that the "dark knowledge" transferred from the teacher acts as a powerful regularizer, allowing the student to generalize better even with sparse supervision.

CIDEr scores on COCO captioning across different training epochs and data percentages, comparing DistillVLM to a non-distilled baseline.

Conclusion

DistillVLM demonstrates that effective compression of VL models requires more than just reducing parameter counts; it requires careful alignment of the input modalities. By adapting the teacher to the student's visual perspective and employing contrastive distillation for hidden states, the researchers achieved state-of-the-art performance for lightweight VL models. Future work may focus on extending these techniques to "detector-free" architectures like Vision Transformers to further enhance speed and simplicity.

Summary updated

BibTeX
@inproceedings{fang2021compressing,
  author = {Zhiyuan Fang and Jianfeng Wang and Xiaowei Hu and Lijuan Wang and Yezhou Yang and Zicheng Liu},
  title = {{Compressing Visual-linguistic Model via Knowledge Distillation}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2021},
  doi = {10.1109/iccv48922.2021.00146},
}
Figure