TL;DR
This paper introduces Counterfactual Prompt Learning (CPL), a novel method to improve the few-shot learning capabilities of vision-language models like CLIP. CPL tackles the issue of "spurious correlations" learned by existing prompt tuning methods by generating counterfactual examples and using contrastive learning to learn more robust and generalizable prompts.
What Problem Does This Paper Address?
Large pre-trained vision-language models (VLMs) like CLIP have shown impressive performance in zero-shot and few-shot learning tasks. A common way to adapt these models is through "prompt engineering," where carefully crafted text prompts guide the model. However, manually designing these prompts is tedious and often leads to suboptimal results. Prompt tuning automates this by learning a "soft" prompt, but existing methods can learn spurious correlations from limited data, leading to poor generalization to unseen concepts. This paper aims to address this by developing a prompt learning method that is more robust to spurious correlations and thus generalizes better to new classes.
Methods
The core of CPL lies in its Counterfactual Prompt Learning framework. It combines two key ideas:
- Counterfactual Generation: Instead of just using factual image-text pairs, CPL generates "counterfactual" examples. This involves identifying minimal, non-spurious changes in an image's features that would causally lead to a change in its label. This is achieved by finding semantically similar positive and negative samples and then manipulating the positive image's features to resemble the negative one, aiming to flip the predicted label.
- Contrastive Learning: CPL uses a contrastive learning objective to train the prompt. This encourages the model to align factual image-text pairs while simultaneously pushing apart factual and counterfactual pairs. This helps the model learn representations that are invariant to spurious features and focus on the essential ones that determine the concept.
Additionally, CPL employs a text-based negative sampling strategy using BERTScore to find the most semantically similar negative samples for generating counterfactuals, which is more effective than random sampling.
Datasets
The paper evaluates CPL on a variety of standard benchmarks:
- Image Classification: SUN397, Caltech101, ImageNet, OxfordPets, StanfordCars, Flowers102, and Food101. These datasets were split into seen and unseen classes to test generalization.
- Image-Text Retrieval: MSCOCO and Flickr30K.
- Visual Question Answering (VQA): VQAv2.
Key Insights and Ideas
- Spurious correlations are a major bottleneck for few-shot learning: Existing prompt tuning methods, by optimizing for empirical risk minimization, can easily latch onto superficial correlations in the training data, hindering generalization to new concepts.
- Counterfactual reasoning is key to disentangling features: By forcing the model to consider "what if" scenarios, CPL encourages it to learn which features are truly causal for a concept, rather than just correlational.
- Contrastive learning complements counterfactuals: The combination of counterfactual generation and contrastive learning allows the model to explicitly learn to distinguish between essential and spurious features.
- Text-based similarity is a good proxy for finding relevant negative samples: Using BERTScore to match text prompts helps in identifying negative image samples that are semantically close but conceptually distinct, which are crucial for generating effective counterfactuals.
Key Results
CPL demonstrates significant improvements across various tasks:
- Image Classification: Achieved a 3.55% average relative improvement on unseen classes across seven datasets compared to CLIP.
- Image-Text Retrieval: Showed up to a 4.09% relative improvement (Recall@1) on MSCOCO and Flickr30K using only 0.5% of training data.
- Visual Question Answering: Achieved a substantial 25.08% relative improvement on VQAv2.
Qualitative results also show that BERTScore-based negative sampling leads to more semantically relevant sampled images compared to random sampling.
Limitations and Future Work
The authors acknowledge several limitations:
- Fairness Issues: Like many large pre-trained models, CLIP can exhibit fairness issues. CPL, by learning prompts, doesn't directly address these inherent biases in the pre-trained model.
- Explainability: While CPL aims for better generalization, the learned soft prompts are still difficult to interpret naturally. Back-mapping techniques are suggested as a future direction.
- Generalization to other biased datasets: Careful inspection and tuning are needed when applying CPL to datasets with known biases.
Future work includes developing more sophisticated methods based on CPL and extending its application to other vision and language tasks. The authors also suggest exploring methods to address fairness issues and improve prompt interpretability.
Summary updated