Simple and Fast Group Robustness by Automatic Feature Reweighting

Shikai Qiu, Andres Potapczynski, Pavel Izmailov, Andrew Gordon Wilson

TL;DR

Automatic Feature Reweighting (AFR) is an ultra-simple, lightning-fast method to combat spurious correlations in machine learning models without requiring group labels during training. By simply retraining the last layer of a standard Empirical Risk Minimization (ERM) model using a weighted loss that prioritizes high-loss examples, AFR automatically upweights minority groups, matching or beating state-of-the-art methods at a fraction of the computational cost.

What Problem Does This Paper Address?

Deep learning models are notorious shortcuts-seekers. If a dataset contains a "spurious feature"—a pattern that correlates with the label in the training set but isn't causally linked to it—the model will exploit it. For example, an image classifier trained to distinguish landbirds from waterbirds might simply look at the background (land vs. water) rather than the bird itself. When tested on a waterbird on land, the model fails spectacularly.

Existing solutions to this "group robustness" problem typically suffer from two major flaws:

  1. Label Dependency: They require explicit "group labels" during training (e.g., knowing exactly which images contain a waterbird on land), which are expensive and rare in practice.
  2. High Overhead: "Annotation-free" alternatives (like Just Train Twice [JTT] or Correct-N-Contrast [CNC]) are complex, notoriously difficult to tune, and require training entirely new models from scratch, leading to massive computational overhead.

The authors introduce AFR to solve both issues simultaneously: achieving group robustness without training group labels, while introducing virtually zero computational overhead compared to standard training.

Methods

AFR operates in a remarkably straightforward two-stage pipeline:

  1. Stage 1: Standard ERM Training. Train a standard model via Empirical Risk Minimization (ERM) on a subset of the training data ($D_{ERM}$, typically 80%) until convergence. No special regularization or early stopping is required.
  2. Stage 2: Last-Layer Retraining. Freeze the feature extractor of the Stage 1 model. Then, retrain only the final classification layer on the remaining held-out data ($D_{RW}$, 20%).

The secret sauce lies in the weighted loss function used in Stage 2. The per-example weights ($\mu_i$) are calculated using a softmax over the model's "incorrectness" (1 minus the predicted probability of the correct class), adjusted by a class-balancing term:

$$\mu_i \propto \beta_{y_i} \exp(-\gamma \hat{p}_i)$$

Here, $\hat{p}_i$ is the probability assigned to the correct class by the Stage 1 model, and $\gamma$ is a tunable inverse temperature parameter. This mathematical formulation ensures that examples where the base model performs poorly (the minority groups) are automatically upweighted.

An illustration of how AFR upweights minority groups and shifts the decision boundary compared to standard ERM.

Datasets

The authors evaluated AFR across several standard vision and natural language processing (NLP) benchmarks known for spurious correlations:

  • Waterbirds: Classifying landbirds vs. waterbirds (spurious feature: land/water background).
  • CelebA: Classifying blond vs. non-blond hair (spurious feature: gender).
  • MultiNLI: Textual entailment dataset (spurious feature: presence of negation words like "never").
  • CivilComments: Toxicity classification (spurious feature: mentions of protected identities).
  • Chest X-Ray (CXR): Pneumonia detection (spurious feature: hospital-specific machine artifacts).

They also tested AFR on CIFAR-10 and Camelyon17 to ensure safety on datasets without known spurious correlations.

Key Insights and Ideas

  • No Intervention Needed in Stage 1: Unlike prior methods (JTT, CNC) that intentionally under-train or heavily regularize the first model to prevent it from memorizing minority groups, AFR lets the ERM model fully converge. Even if the model achieves ~100% accuracy on its training split, it still performs poorly on minority groups within the held-out reweighting split, providing an excellent signal for upweighting.
  • The Power of the Last Layer: Caching the embeddings from the frozen feature extractor means retraining the last layer takes less than a minute. This makes hyperparameter sweeping incredibly cheap ($O(1)$ vs $O(K)$ for full-model retraining methods).
  • Implicit Group Balancing: As $\gamma$ increases, the aggregate weight automatically shifts toward minority groups, effectively creating a group-balanced dataset without ever seeing a group label.

Key Results

  • Accuracy: AFR achieves state-of-the-art or highly competitive Worst-Group Accuracy (WGA) among annotation-free methods. On Waterbirds, it hits 90.4% WGA (outperforming CNC's 88.5% and JTT's 86.7%). On MultiNLI, it achieves 73.4% WGA.
  • Speed: AFR introduces a negligible training overhead (around 6% on average). On Waterbirds, AFR takes just 19 minutes, compared to 58 minutes for JTT and 137 minutes for CNC.
Training time comparison showing AFR's massive computational advantage over JTT and CNC.
  • Label Efficiency: When validation group labels are extremely scarce, AFR significantly outperforms oracle methods like Deep Feature Reweighting (DFR). For instance, with a validation set of just 5 examples (0.5%), DFR overfits and collapses, while AFR achieves near-optimal performance.

Limitations and Future Work

While highly effective, AFR has a few limitations:

  • Hyperparameter Tuning: Like its competitors, AFR still requires a small, group-annotated validation set to tune $\gamma$ and the regularization parameter $\lambda$. As the number of groups scales up, estimating worst-group accuracy on a tiny validation set will become challenging.
  • Severe Population Imbalances: On datasets like CelebA, where one minority group is significantly larger than another, AFR struggles to perfectly balance the groups because it cannot differentiate between them using only loss and class labels. The authors proved mathematically that no method relying solely on first-stage predictions and true labels can perfectly balance CelebA.

Summary updated

BibTeX
@inproceedings{qiu2023simple,
  author = {Shikai Qiu and Andres Potapczynski and Pavel Izmailov and Andrew Gordon Wilson},
  title = {{Simple and Fast Group Robustness by Automatic Feature Reweighting}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=s5F1a6s1HS},
}
Figure