NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Finetune like you pretrain: Improved finetuning of zero-shot vision models

Sachin Goyal, Ananya Kumar, Sankalp Garg, Zico Kolter, Aditi RaghunathanCVPR 2022

Abstract

Finetuning image-text models such as CLIP achieves state-of-the-art accuracies on a variety of benchmarks. However, recent works have shown that even subtle differences in the finetuning process can lead to surprisingly large differences in the final performance, both for in-distribution (ID) and out-of-distribution (OOD) data. In this work, we show that a natural and simple approach of mimicking contrastive pretraining consistently outperforms alternative finetuning approaches. Specifically, we cast downstream class labels as text prompts and continue optimizing the contrastive loss between image embeddings and class-descriptive prompt embeddings (contrastive finetuning). Our method, FLYP, consistently outperforms baselines across 7 distribution shift, 6 transfer learning, and 3 few-shot learning benchmarks. On WILDS-iWILDCam, FLYP outperforms the top of the leaderboard by 2.3% ID and 2.7% OOD, giving the highest reported accuracy. Averaged across 7 OOD datasets, FLYP gives gains of 4.2% OOD over standard finetuning and outperforms current state-of-the-art (LP-FT) by more than 1% both ID and OOD. Similarly, on 3 few-shot learning benchmarks, FLYP gives gains up to 4.6% over standard finetuning and 4.4% over the state-of-the-art. Thus we establish our proposed method of contrastive finetuning as a simple and intuitive state-of-the-art for supervised finetuning of image-text models like CLIP.

Introduction: The Robustness Trade-off in Finetuning

Large-scale models like CLIP are pretrained on massive datasets of image-text pairs using a contrastive loss, which aligns images with their textual descriptions. While these models excel in zero-shot settings, finetuning them on specific labeled datasets is common practice to maximize performance.

The standard approach involves discarding the text encoder, adding a linear classification "head" on top of the image encoder, and minimizing cross-entropy loss. However, this often leads to a significant drop in out-of-distribution (OOD) robustness, even as in-distribution (ID) accuracy improves. Previous attempts to mitigate this, such as Linear Probing then Finetuning (LP-FT) or weight ensembling (Wise-FT), add complexity without fully addressing the underlying mismatch between pretraining and finetuning objectives.

Standard finetuning architecture using a linear head and cross-entropy loss.

Methods: Finetune Like You Pretrain (FLYP)

The authors propose FLYP, a method that maintains the pretraining objective during finetuning. Instead of a fixed classification head, FLYP converts class labels into text prompts (e.g., "a photo of a {label}") and continues to optimize the contrastive loss.

Key components of FLYP include:

  1. Contrastive Finetuning: The model pulls the embedding of an image closer to its corresponding class prompt while pushing it away from other class prompts in the minibatch.
  2. Dual-Encoder Updates: Unlike standard methods that only update the image encoder, FLYP updates both the image and text encoders simultaneously. This allows the model to leverage semantic relationships between class names.
The FLYP method (left) and its performance on ImageNet benchmarks (right), showing a superior Pareto frontier for ID vs OOD accuracy.

Key Results and Insights

The authors evaluated FLYP across a wide range of benchmarks, including ImageNet with five OOD shifts, real-world distribution shifts in WILDS, and several transfer and few-shot learning datasets.

Performance Highlights

  • New SOTA on WILDS: On the iWILDCam benchmark, FLYP achieved the highest reported accuracy, outperforming the previous leader by 2.3% ID and 2.7% OOD.
  • ImageNet Robustness: Averaged across 7 OOD datasets, FLYP provided a 4.2% gain over standard finetuning and outperformed LP-FT by over 1% in both ID and OOD settings.
  • Few-Shot Learning: In 16-shot settings, FLYP showed significant gains, such as a 4.7% improvement on PatchCamelyon over standard finetuning.

Why Simplicity Wins

A key insight is the "Loss Match" Hypothesis: matching the finetuning loss to the pretraining loss is more critical than the specific architecture. Interestingly, the authors found that "class collisions" in the contrastive setup (multiple images of the same class in a batch) act as a beneficial regularizer; attempting to mask them out actually decreased performance. The noise inherent in the contrastive loss seems to act as a beneficial regularizer.

Conclusion

FLYP establishes contrastive finetuning as a simple, intuitive, and highly effective state-of-the-art for supervised finetuning of image-text models. By aligning the finetuning objective with the pretraining phase, FLYP preserves and enhances the inherent robustness of models like CLIP while achieving superior accuracy across diverse benchmarks. Future work may explore the applicability of this "finetune like you pretrain" philosophy to other architectures like masked autoencoders or generative models.

Summary updated

BibTeX
@inproceedings{goyal2022finetune,
  author = {Sachin Goyal and Ananya Kumar and Sankalp Garg and Zico Kolter and Aditi Raghunathan},
  title = {{Finetune like you pretrain: Improved finetuning of zero-shot vision models}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
  url = {https://openreview.net/forum?id=glCNEarJtn},
}
Figure