Table of Contents
Fetching ...

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.

LaCViT: A Label-aware Contrastive Fine-tuning Framework for Vision Transformers

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 . Experiments across eight datasets and three ViT variants show substantial gains, with up to 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.
Paper Structure (11 sections, 1 equation, 3 figures, 1 table)

This paper contains 11 sections, 1 equation, 3 figures, 1 table.

Figures (3)

  • Figure 1: The overview of LaCViT, which consists of two training stages: 1) label-aware contrastive training and 2) task head fine-tuning, compared to the vanilla fine-tuning, which directly fine-tunes the task head. The first contrastive training stage trains the vision transformers based on the labels of the target tasks with a contrastive loss, aiming to improve the embedding quality, and in the second stage, LaCViT is fine-tuned with a task-specific head.
  • Figure 2: Plot of cosine similarity distribution across two random classes from CIFAR-10. Blue and orange mean positive and negative similarities, respectively.
  • Figure 3: Embedding Space Visualization for MAE vs. LaCViT-MAE. Displayed over ten CIFAR-10 classes using t-SNE. Each dot represents a sample, with distinct colors indicating different label classes.