Skip to main content
QUICK REVIEW

[Paper Review] CLIPood: Generalizing CLIP to Out-of-Distributions

Yang Shu, Xingzhuo Guo|arXiv (Cornell University)|Feb 2, 2023
Natural Language Processing TechniquesComputer Science11 citations
TL;DR

CLIPood fine-tunes CLIP with Margin Metric Softmax and Beta Moving Average to improve OOD generalization under both domain shift and open-class scenarios.

ABSTRACT

Out-of-distribution (OOD) generalization, where the model needs to handle distribution shifts from training, is a major challenge of machine learning. Contrastive language-image pre-training (CLIP) models have shown impressive zero-shot ability, but the further adaptation of CLIP on downstream tasks undesirably degrades OOD performances. This paper aims at generalizing CLIP to out-of-distribution test data on downstream tasks. We propose CLIPood, a fine-tuning method that can adapt CLIP models to OOD situations where both domain shifts and open classes may occur on the unseen test data. To exploit the semantic relations between classes from the text modality, CLIPood introduces a new training objective, margin metric softmax (MMS), with class adaptive margins for fine-tuning. To incorporate both pre-trained zero-shot model and fine-tuned task-adaptive model, CLIPood leverages a new optimization strategy, Beta moving average (BMA), to maintain a temporal ensemble weighted by Beta distribution. Experiments on diverse datasets with different OOD scenarios show that CLIPood consistently outperforms existing generalization techniques.

Motivation & Objective

  • Investigate how to generalize CLIP models to downstream tasks with OOD data including domain shift and open classes.
  • Design a fine-tuning method that preserves cross-modal image-text alignment while enhancing OOD generalization.
  • Leverage semantic relations from the text modality to guide fine-tuning.
  • Propose an optimization strategy that retains both pre-trained zero-shot knowledge and task-specific adaptation.
  • Evaluate CLIPood on diverse OOD benchmarks to demonstrate consistent improvements over existing methods.

Proposed method

  • Fine-tune CLIP by predicting image-text similarity using class text embeddings generated from task prompts.
  • Introduce Margin Metric Softmax (MMS) which adds an adaptive margin based on inter-class text embedding distance.
  • Freeze the text encoder to preserve broad semantic relations and only fine-tune the image encoder.
  • Maintain a Beta Moving Average (BMA) of model checkpoints during fine-tuning to ensemble both pre-trained and task-specific knowledge.
  • Compute temporal ensemble weights using a Beta(β,β) distribution and update a moving-average model on the fly.
  • Use cosine similarity with temperature tau for the cross-modal predictions and follow CLIP’s training protocol.
Figure 1 : We adapt pre-trained CLIP models on downstream tasks with training data, while maintaining OOD generalization ability to overcome both domain shift and open class .
Figure 1 : We adapt pre-trained CLIP models on downstream tasks with training data, while maintaining OOD generalization ability to overcome both domain shift and open class .

Experimental results

Research questions

  • RQ1How can CLIP be fine-tuned to maintain OOD generalization when adapting to downstream tasks with domain shifts and open classes?
  • RQ2Does leveraging text-space semantic relations via MMS improve cross-modal alignment and downstream OOD performance?
  • RQ3Can a temporal ensemble like BMA balance pre-trained zero-shot knowledge with task-specific fine-tuning to boost OOD robustness?

Key findings

  • CLIPood outperforms existing generalization techniques on domain-shift benchmarks (DomainBed variants) and on ImageNet variants with distribution shifts.
  • CLIPood achieves higher open-class generalization across 11 downstream datasets compared to zero-shot CLIP and prior fine-tuning methods.
  • In scenarios with both domain shift and open classes, CLIPood consistently surpasses zero-shot and CoOp baselines across OfficeHome and DomainNet.
  • Ablation confirms MMS and BMA jointly contribute to better OOD generalization, with MMS preserving semantic relations and BMA balancing knowledge sources.
  • Compared to EMA, BMA better preserves both pre-trained and fine-tuned knowledge, yielding superior open-class and domain-shift performance.
Figure 2 : Overview of the proposed CLIPood method. CLIPood compares image embeddings with class text embeddings. Margin Metric Softmax is introduced to exploit semantic relationships between classes. Moreover, a Beta Moving Average model is maintained for prediction, which incorporates both the pre
Figure 2 : Overview of the proposed CLIPood method. CLIPood compares image embeddings with class text embeddings. Margin Metric Softmax is introduced to exploit semantic relationships between classes. Moreover, a Beta Moving Average model is maintained for prediction, which incorporates both the pre

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.