Introduction
Computer vision foundation models, such as DINOv2 and CLIP, have demonstrated remarkable robustness and generalization capabilities. However, their substantial computational requirements often preclude deployment in resource-constrained environments. Knowledge distillation offers a path toward creating lightweight "student" models that mimic these "teacher" giants. Yet, traditional distillation methods frequently fail to transfer the core properties that make foundation models unique—specifically their robustness to image corruptions and their ability to detect out-of-distribution (OOD) data.
The Challenge of Faithful Distillation
Standard distillation techniques typically focus on matching final classification outputs or minimizing the Mean Squared Error (MSE) between internal feature magnitudes. While these approaches can yield high accuracy on a specific training set, they often fail to replicate the underlying structure of the teacher's latent space. Consequently, the resulting student models lack the "faithfulness" required to inherit the teacher's robustness and OOD detection performance. The authors argue that preserving the semantic relationships within the latent space is critical for successful compression.
Cosine-similarity Preserving Compression (CosPress)
To address these limitations, the authors introduce Cosine-similarity Preserving Compression (CosPress). This method is built on the insight that in high-dimensional spaces, the semantic identity of an object is primarily encoded in the direction (angle) of its feature vector rather than its absolute magnitude.
CosPress departs from prior state-of-the-art methods, such as Proteus, in three key ways:
- Teacher-Side Compression: Instead of projecting student features up to the teacher's high-dimensional space, CosPress employs a teacher head ($h_\phi$) to compress the teacher's latent space down to the student's dimensions.
- Angle Preservation: The teacher head is optimized using a loss function inspired by Stochastic Neighbor Embedding (SNE), ensuring that images with similar embeddings in the original space maintain high cosine similarity in the compressed space.
- Direct Optimization: The student network is then trained to directly match these compressed, semantically-rich features using a simple cosine distance loss.
Experimental Evaluation
The proposed method was trained on the ImageNet-1K dataset (1.2 million images) and evaluated across a diverse suite of benchmarks:
- Downstream Tasks: Nine fine-grained classification benchmarks (e.g., Oxford Pets, Flowers-102).
- Robustness: Performance on corrupted or shifted datasets like ImageNet-V2, ImageNet-Sketch, and ImageNet-Adversarial.
- OOD Detection: Evaluation using the OpenOOD benchmark, focusing on both "Near OOD" and "Far OOD" scenarios.
Results and Discussion
CosPress consistently outperforms existing distillation methods across nearly all metrics, with the most significant gains observed in OOD detection.
As shown in the results, a CosPress-distilled ViT-Ti/14 achieved a Far OOD AUROC of 91.03%, a substantial improvement over the 74.22% achieved by Proteus. Furthermore, CosPress models demonstrated superior robustness on datasets like ImageNet-Sketch, indicating a more faithful transfer of the teacher's resilient features. Visualizations of patch features further confirm that CosPress students capture fine-grained structural details more effectively than previous methods, maintaining the "semantic soul" of the foundation model.
Conclusion
CosPress represents a significant advancement in label-free knowledge distillation. By prioritizing the preservation of cosine similarities during feature compression, it produces lightweight models that are not only accurate but also faithful to the robustness and OOD detection capabilities of their foundation model teachers. While a small generalization gap remains compared to models trained on massive proprietary datasets, CosPress provides a robust framework for deploying high-performance vision models on edge devices.
Summary updated