Can contrastive learning avoid shortcut solutions?

Joshua David Robinson, Li Sun, Ke Yu, kayhan Batmanghelich, Stefanie Jegelka, Suvrit Sra

TL;DR

Contrastive learning models often fail by taking "shortcuts"—focusing on easy features like color or background while ignoring complex, predictive features like shape. This paper introduces Implicit Feature Modification (IFM), a computationally efficient method that perturbs embeddings during training to suppress these shortcuts, forcing the model to learn a more diverse and robust set of representations.

The Problem: Simplicity Bias and Shortcuts

Self-supervised contrastive learning has become a cornerstone of modern AI, allowing models to learn from unlabeled data by performing "instance discrimination" (distinguishing a positive pair of images from a sea of negatives). However, these models are prone to simplicity bias.

Ideal vs. Shortcut Features

If a model can distinguish two images just by looking at a simple "shortcut" feature—like the background color or a specific texture—it will often ignore more important semantic features like the object's actual shape. This leads to poor generalization when the model encounters new data where those shortcuts no longer apply. While researchers have tried making the task "harder" by using harder negative samples, the authors find that this usually results in a zero-sum game: improving the representation of one feature often comes at the cost of sacrificing another.

Implicit Feature Modification (IFM)

The authors propose Implicit Feature Modification (IFM) to break this trade-off and encourage feature diversification.

  1. The Core Idea: Instead of just picking harder images, IFM "hides" the features the model is currently relying on. If the model is using color to tell images apart, IFM modifies the mathematical representation (the embedding) of the images to make them look more similar in "color space" but different in other ways.
  2. "Implicit" vs. Explicit: Modifying pixels in an image to change its semantics (e.g., changing a dog's breed while keeping its pose) is incredibly difficult. IFM is "implicit" because it applies these modifications directly to the high-dimensional vectors (embeddings) produced by the neural network.
  3. Adversarial Perturbation: IFM acts as a mini-adversary during training. For every batch, it calculates a small perturbation that reduces the similarity between positive pairs and increases the similarity between negatives.
  4. Efficiency: Crucially, the authors show that this perturbation can be calculated analytically. This means IFM adds zero computational overhead and can be implemented with just a few lines of code by simply adjusting the "logits" in the standard contrastive loss function.

Key Insights and Results

The researchers evaluated IFM across a wide variety of benchmarks, including synthetic datasets (Trifeature, STL-digits), standard vision benchmarks (CIFAR, STL-10, ImageNet100), and medical imaging (COPDGene).

  • The Hardness Paradox: Simply increasing the difficulty of the task (e.g., lowering the "temperature" parameter in the loss function) doesn't solve feature suppression; it just shifts the bias. You might get better at recognizing shapes, but you'll suddenly get worse at recognizing textures.
  • Balanced Learning: On the Trifeature dataset, IFM was the only method that improved the representation of color, shape, and texture simultaneously, avoiding the zero-sum trade-off seen in standard methods.
IFM improves multiple features simultaneously
  • ImageNet Performance: When added to the popular MoCo-v2 framework, IFM improved top-1 accuracy on ImageNet100 from 80.4% to 81.1%, outperforming more complex adversarial methods like AdCo.
  • Medical Breakthrough: In the medical imaging task (COPDGene), IFM showed significant gains. For example, in predicting lung function (logFEV1pp), the R-square value improved from 0.566 (baseline) to 0.615.
  • Universality: The method proved robust across different temperatures and perturbation budgets, suggesting it is easy to drop into existing contrastive learning pipelines.

Limitations and Future Work

  • Hyperparameter Tuning: While IFM is robust, it does introduce a new parameter $\epsilon$ (the perturbation budget). While the authors found $\epsilon=0.1$ worked well across most tasks, optimal performance still requires some tuning.
  • Defining "Features": The paper relies on the intuitive idea of features (color, shape). However, in complex real-world data, it is still difficult to mathematically define exactly which "shortcut" IFM is suppressing at any given moment.
  • Beyond Vision: The current work focuses on images. A promising future direction is applying IFM to other modalities like Natural Language Processing (NLP) or audio, where shortcut solutions (like keyword matching) are also a major hurdle.

Summary updated

BibTeX
@inproceedings{robinson2021can,
  author = {Joshua David Robinson and Li Sun and Ke Yu and kayhan Batmanghelich and Stefanie Jegelka and Suvrit Sra},
  title = {{Can contrastive learning avoid shortcut solutions?}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=ud-WYSo9JSL},
}
Figure