TL;DR
This paper introduces CLIP-KD, a comprehensive study on distilling knowledge from large CLIP models into smaller ones. They propose and evaluate various distillation strategies, finding that simple feature mimicry is surprisingly effective, and a unified approach significantly boosts student model performance on zero-shot tasks.
What Problem Does This Paper Address?
Large-scale models like CLIP have revolutionized visual representation learning by leveraging vast amounts of image-text data. However, their sheer size makes them computationally expensive and impractical for many real-world applications. This paper addresses the challenge of creating smaller, more efficient CLIP models that retain the powerful zero-shot capabilities of their larger counterparts. The authors aim to bridge this gap by systematically studying and proposing effective knowledge distillation techniques specifically for CLIP.
Methods
The core of CLIP-KD lies in exploring various knowledge distillation (KD) strategies to transfer knowledge from a large "teacher" CLIP model to a smaller "student" CLIP model. The authors categorize their proposed methods into four paradigms:
- Contrastive Relational Distillation (CRD): This method focuses on mimicking the output-oriented contrastive distributions of the teacher. It aims to preserve the structured relationships between image and text embeddings learned by the teacher.
- Feature Distillation (FD): This is a straightforward approach that uses Mean Squared Error (MSE) loss to align the visual and text embeddings of the student with those of the teacher. They find this simple method to be surprisingly effective.
- Masked Feature Distillation (MFD): An extension of FD, this method uses masked images as input to the student, leveraging the teacher's supervision to help the student recover visual semantics from corrupted inputs.
- Gradient Distillation (GD): This technique forces the student's gradients (how its output changes with respect to input embeddings) to be consistent with the teacher's gradients, aiming to make the student behave more similarly to the teacher.
- Interactive Contrastive Learning (ICL): This novel approach treats the student as an "anchor" to contrast with the teacher's embeddings, promoting interaction and implicitly transferring knowledge. The authors theoretically show this maximizes the lower bound of mutual information between teacher and student features.
The paper also proposes a unified method that combines these distillation losses, allowing for flexible selection and weighting of different strategies.
Datasets
The paper uses the following datasets:
- Training: Conceptual Captions 3M (CC3M) and Conceptual 12M (CC12M) for vision-and-language pre-training.
- Evaluation:
- Zero-shot Classification: ImageNet (IN), ImageNet-V2 (IN-V2), ImageNet-Rendition (IN-R), and ImageNet-Sketch (IN-S).
- Cross-modal Retrieval: MSCOCO and Flickr.
- Downstream Tasks (Linear Evaluation): MS-COCO object detection and instance segmentation.
Key Insights and Ideas
- Simple is Often Best: The simplest method, Feature Distillation (FD) using MSE loss to mimic teacher embeddings, surprisingly yields the best performance among individual distillation strategies.
- Interactivity Matters: Interactive Contrastive Learning (ICL) and Contrastive Relational Distillation (CRD) are also critical for performance improvement, suggesting that mimicking higher-level relationships and interactions is beneficial.
- Feature Similarity is Key: The paper posits that the success of CLIP distillation is directly correlated with how well the student's feature similarity to the teacher's is maximized. This provides a guiding principle for designing effective distillation methods.
- Architectural Agnosticism: CLIP-KD is designed to work with any teacher-student architecture pair, unlike some prior methods that require similar architectures. This significantly broadens its practical applicability.
- Unified Approach is Powerful: Combining multiple distillation losses (e.g., FD+CRD+ICL) consistently outperforms individual methods, demonstrating the synergy between different knowledge transfer mechanisms.
Key Results
- Significant Performance Gains: CLIP-KD consistently improves student CLIP models over baselines on zero-shot ImageNet classification and cross-modal retrieval tasks.
- Outperforming Teacher Baselines: When using ViT-L/14 (pretrained on Laion-400M) as a teacher, CLIP-KD achieves 57.5% and 55.4% zero-shot top-1 ImageNet accuracy for ViT-B/16 and ResNet-50 students, respectively, surpassing the original CLIP without KD by over 20%.
- Effective Across Architectures: The method shows strong performance improvements for various student architectures, including ViT and CNNs, regardless of the teacher's architecture.
- Competitive with State-of-the-Art: CLIP-KD outperforms TinyCLIP (a prior state-of-the-art distillation method) by 1.8% on ImageNet accuracy and 1.7% on average cross-modal retrieval.
- Downstream Task Improvements: CLIP-KD also leads to consistent performance improvements on downstream tasks like object detection and instance segmentation.
Limitations and Future Work
- Capacity Gaps: The authors note that when distilling from a very large teacher (e.g., ViT-L/14) to a small student, there might be capacity gaps that make alignment difficult. This is identified as an open issue for future research.
- Intermediate Feature Distillation Sensitivity: Distilling intermediate features can be sensitive to teacher-student architecture mismatches, leading to less consistent gains compared to final-output-based methods. The paper advocates for final-output-based CLIP-KD to avoid this issue.
- Further Exploration of Unified Methods: While the paper demonstrates the effectiveness of combining losses, there's potential for further research into optimal combinations and weighting strategies for various scenarios.
Summary updated