LaCViT: A Label-aware Contrastive Fine-tuning Framework for Vision Transformers
Zijun Long, Zaiqiao Meng, Gerardo Aragon Camarasa, Richard McCreadie
TL;DR
LaCViT addresses the limited transferability of Vision Transformers by introducing a label-aware contrastive fine-tuning framework. It replaces or augments standard cross-entropy fine-tuning with a two-stage process: Stage 1 performs label-aware contrastive training to reshape embeddings, and Stage 2 fine-tunes a task-specific head using conventional cross-entropy. The method leverages data augmentation, patch encoding, and a nonlinear projection, with a label-aware loss defined as $\mathcal{L}(\mathcal{D}^{*}) = \sum\limits_{z_{i}\in \mathcal{D}^{*}} \frac{-1}{|\mathcal{D}^{+}_{-z_i}|} \sum\limits_{z_{p}\in \mathcal{D}^{+}_{-z_i}} \log\frac{\exp(z_{i}\cdot z_{p}/\tau)}{\sum\limits_{z_{a}\in \mathcal{D}^{*}_{-z_i}} \exp(z_{i}\cdot z_{a}/\tau)}$. Experiments across eight datasets and three ViT variants show substantial gains, with up to $10.78\%$ Top-1 accuracy improvement on CUB-200-2011 and consistent benefits on other benchmarks, illustrating improved embedding discriminability and transfer performance. The results indicate that label-aware contrastive fine-tuning can outperform cross-entropy alone while preserving Transformer efficiency, offering a practical alternative for ViT deployment in diverse tasks.
Abstract
Vision Transformers (ViTs) have emerged as popular models in computer vision, demonstrating state-of-the-art performance across various tasks. This success typically follows a two-stage strategy involving pre-training on large-scale datasets using self-supervised signals, such as masked random patches, followed by fine-tuning on task-specific labeled datasets with cross-entropy loss. However, this reliance on cross-entropy loss has been identified as a limiting factor in ViTs, affecting their generalization and transferability to downstream tasks. Addressing this critical challenge, we introduce a novel Label-aware Contrastive Training framework, LaCViT, which significantly enhances the quality of embeddings in ViTs. LaCViT not only addresses the limitations of cross-entropy loss but also facilitates more effective transfer learning across diverse image classification tasks. Our comprehensive experiments on eight standard image classification datasets reveal that LaCViT statistically significantly enhances the performance of three evaluated ViTs by up-to 10.78% under Top-1 Accuracy.
