Correct-N-Contrast: A Contrastive Approach for Improving Robustness to Spurious Correlations

Michael Zhang, Nimit S. Sohoni, Hongyang R. Zhang, Chelsea Finn, Christopher Ré
3/3/2022
cs.LG

Official code: HazyResearch/correct-n-contrast (21 stars, Python, Apache-2.0, last commit 2022-07-18).

Abstract

Spurious correlations pose a major challenge for robust machine learning. Models trained with empirical risk minimization (ERM) may learn to rely on correlations between class labels and spurious attributes, leading to poor performance on data groups without these correlations.

Show full abstract

This is particularly challenging to address when spurious attribute labels are unavailable. To improve worst-group performance on spuriously correlated data without training attribute labels, we propose Correct-N-Contrast (CNC), a contrastive approach to directly learn representations robust to spurious correlations. As ERM models can be good spurious attribute predictors, CNC works by (1) using a trained ERM model's outputs to identify samples with the same class but dissimilar spurious features, and (2) training a robust model with contrastive learning to learn similar representations for same-class samples. To support CNC, we introduce new connections between worst-group error and a representation alignment loss that CNC aims to minimize. We empirically observe that worst-group error closely tracks with alignment loss, and prove that the alignment loss over a class helps upper-bound the class's worst-group vs. average error gap. On popular benchmarks, CNC reduces alignment loss drastically, and achieves state-of-the-art worst-group accuracy by 3.6% average absolute lift. CNC is also competitive with oracle methods that require group labels.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Official code repository for Correct-N-Contrast

215PythonJul 18, 20224 years agoApache-2.0

Similar Papers

Cite this paper

@article{zhang2022correctncontrast,
  title  = {Correct-N-Contrast: A Contrastive Approach for Improving Robustness to Spurious Correlations},
  author = {Michael Zhang and Nimit S. Sohoni and Hongyang R. Zhang and Chelsea Finn and Christopher Ré},
  year   = {2022},
  eprint = {2203.01517},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2203.01517}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2203.01517.svg)](https://codeofpaper.com/paper/2203.01517)

Discussion