CLIP-KD: An Empirical Study of CLIP Model Distillation

Chuanguang Yang, Zhulin An, Libo Huang, Junyu Bi, Xinqiang Yu, Han Yang, Boyu Diao, Yongjun Xu

Abstract

Contrastive Language-Image Pre-training (CLIP) has revolutionized vision-language tasks, yet the deployment of these massive models remains challenging due to computational constraints. This paper presents CLIP-KD, a comprehensive empirical study on distilling large CLIP models into smaller, efficient versions. By evaluating various distillation paradigms, we demonstrate that architecture-agnostic methods—specifically simple feature mimicry combined with interactive contrastive learning—can improve student performance by over 20% on zero-shot tasks.

Introduction

The scale of state-of-the-art CLIP models often precludes their use in real-time or mobile applications. While Knowledge Distillation (KD) is a common remedy, existing CLIP distillation techniques often rely on weight inheritance, restricting the student to the teacher's architectural family (e.g., ViT-to-ViT). CLIP-KD addresses this by exploring flexible, architecture-agnostic frameworks capable of distilling knowledge from a Vision Transformer (ViT) into diverse architectures such as MobileNet or ResNet.

Methodology

The study categorizes distillation strategies into two primary views: Mimicry and Interaction.

  1. Mimicry Learning: Focuses on aligning student outputs with the teacher. This includes Feature Distillation (FD) using Mean Squared Error (MSE) loss, Contrastive Relational Distillation (CRD) for logit matching, and Gradient Distillation (GD) for aligning output sensitivities.
  2. Interactive Learning: Introduces cross-network dynamics. Interactive Contrastive Learning (ICL) uses the student's embedding as an anchor to find matches in the teacher's encoder, maximizing mutual information. Augmented Feature Distillation (AFD) utilizes a fusion encoder to integrate features from both networks.
Overview of distillation paradigms evaluated in CLIP-KD, including Mimicry and Interaction views.

Results and Insights

The empirical results highlight that simplicity often yields the best performance. Simple Feature Distillation (FD) proved remarkably effective, and its combination with ICL provided the strongest overall results. A key insight from the study is the direct correlation between the cosine similarity of student-teacher features and the resulting task performance.

Correlation between feature similarity and zero-shot accuracy across different distillation paradigms.

Significant performance leaps were observed:

  • Massive Gains: A ViT-B/16 student distilled from a ViT-L/14 teacher reached 57.5% zero-shot accuracy on ImageNet, a 20.5% improvement over the non-distilled baseline.
  • Cross-Architecture Success: The framework successfully improved MobileViT-S accuracy by 3.4%, proving its effectiveness across disparate architectures.
  • Retrieval Performance: On MSCOCO image-to-text retrieval, CLIP-KD improved Recall@1 by 2.0% to 4.4% across various models.

Discussion and Limitations

Despite these gains, a "capacity gap" was noted where excessively large teachers occasionally hindered tiny students, suggesting a need for intermediate "bridge" models. Additionally, while final embedding alignment is robust, distilling intermediate layers across different architectures remains a complex challenge. Future work should explore scaling these strategies to massive datasets like LAION-5B.

Conclusion

CLIP-KD provides a roadmap for efficient CLIP deployment. By prioritizing final feature alignment and interactive learning, researchers can create high-performing, compact models that retain the powerful cross-modal capabilities of their larger counterparts without being tied to specific architectures.

Summary updated

BibTeX
@inproceedings{yang2024clip,
  author = {Chuanguang Yang and Zhulin An and Libo Huang and Junyu Bi and Xinqiang Yu and Han Yang and Boyu Diao and Yongjun Xu},
  title = {{CLIP-KD: An Empirical Study of CLIP Model Distillation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  doi = {10.1109/cvpr52733.2024.01510},
}
Figure