TL;DR
CLIP-KD is a comprehensive framework for distilling large, powerful CLIP models into smaller, efficient ones that can run on resource-constrained devices. By combining simple feature mimicry with interactive contrastive learning, the authors achieve massive performance boosts—up to a 20% increase in zero-shot ImageNet accuracy—across diverse model architectures.
What Problem Does This Paper Address?
Contrastive Language-Image Pre-training (CLIP) has revolutionized how we think about visual representations by learning from massive amounts of image-text pairs. However, the best-performing CLIP models are enormous, making them difficult to deploy in real-world, low-latency applications.
While Knowledge Distillation (KD) is a standard technique to shrink models, applying it to CLIP isn't straightforward. Previous state-of-the-art methods like TinyCLIP relied on "weight inheritance," which requires the teacher and student to share the same basic architecture (e.g., both must be Vision Transformers). This paper seeks a more general, effective, and architecture-agnostic way to transfer knowledge from a "heavyweight" CLIP teacher to a "lightweight" student.
Methods
The authors systematically explore six different distillation paradigms, illustrated in Figure 1:
- Feature Distillation (FD): The student tries to directly match the teacher's final image and text embeddings using a Mean Squared Error (MSE) loss.
- Contrastive Relational Distillation (CRD): The student mimics the teacher's output probability distributions (the "relationships" between images and text in a batch).
- Interactive Contrastive Learning (ICL): A cross-model approach where the student's image features are contrasted against the teacher's text features (and vice versa).
- Masked Feature Distillation (MFD): Similar to FD, but the student only sees a partially masked version of the image, forcing it to reconstruct semantic meaning.
- Gradient Distillation (GD): The student aligns its gradients with the teacher's, learning not just what the output is, but how it changes with the input.
- Augmented Feature Distillation (AFD): Uses a fusion encoder to combine student and teacher features during training.
The authors found that a unified method combining FD, CRD, and ICL yielded the best overall results.
Datasets
- Training: The models were primarily pre-trained on the CC3M (Conceptual Captions 3M) and CC12M datasets. For some high-performance experiments, teachers pre-trained on the massive LAION-400M dataset were used.
- Evaluation:
- Zero-shot Classification: ImageNet-1K and its robustness variants (ImageNet-V2, Rendition, and Sketch).
- Cross-modal Retrieval: MSCOCO and Flickr30k.
- Downstream Tasks: MSCOCO object detection and instance segmentation.
Key Insights and Ideas
- Simplicity Wins: Surprisingly, direct Feature Distillation (FD) using MSE loss was the most effective individual strategy. The authors argue that if a student can perfectly align its features with a teacher's, the performance gap naturally vanishes.
- The Power of Interaction: Interactive Contrastive Learning (ICL) works because it maximizes the lower bound of mutual information between the teacher and student networks. It forces the student to learn "common knowledge" that is robust across both models.
- Architecture Agnostic: Unlike previous methods, CLIP-KD works perfectly even when the teacher is a Vision Transformer (ViT) and the student is a Convolutional Neural Network (CNN), or vice versa.
- Similarity Correlates with Success: The authors show that the performance gain is directly proportional to how much the distillation increases the feature similarity (measured by Cosine similarity and CKA) between the teacher and student.
Key Results
- Massive Gains: When distilling a ViT-L/14 (pre-trained on LAION-400M) into a ViT-B/16 student, the student's zero-shot ImageNet accuracy jumped from 37.0% to 57.5%—a staggering 20.5% margin.
- CNN Success: A ResNet-50 student saw a similar 20.1% improvement when distilled from the same teacher.
- Surpassing the Teacher: In some cases, a distilled student (like Swin-T) actually outperformed its own teacher (ViT-B/16) on zero-shot benchmarks, likely because the distillation process helped the student leverage the teacher's knowledge while maintaining its own architectural strengths.
- State-of-the-Art: CLIP-KD consistently outperformed TinyCLIP, providing better accuracy and greater flexibility in choosing model architectures.
Limitations and Future Work
- The Capacity Gap: The authors noted a "counter-intuitive" finding: sometimes a moderately sized teacher (ViT-B) is better for a tiny student (ViT-T) than a massive teacher (ViT-L). This suggests a "capacity gap" where the student simply cannot absorb the complex features of an overly advanced teacher.
- Intermediate Features: While this paper focused on final output embeddings to remain architecture-agnostic, the authors noted that distilling intermediate layers (hidden states) could provide even more gains if the architectures are similar. Exploring how to do this effectively for dissimilar architectures remains an open question.
- Training Overhead: While the resulting student is efficient, the distillation process itself requires running both the teacher and student during training, increasing the initial computational cost.
Summary updated