Learning Stable Classifiers by Transferring Unstable Features

Yujia Bao, Shiyu Chang, Regina Barzilay

Abstract

While unbiased machine learning models are essential for many applications, bias is a human-defined concept that can vary across tasks. Given only input-label pairs, algorithms may lack sufficient information to distinguish stable (causal) features from unstable (spurious) features. However, related tasks often share similar biases -- an observation we may leverage to develop stable classifiers in the transfer setting. In this work, we explicitly inform the target classifier about unstable features in the source tasks. Specifically, we derive a representation that encodes the unstable features by contrasting different data environments in the source task. We achieve robustness by clustering data of the target task according to this representation and minimizing the worst-case risk across these clusters. We evaluate our method on both text and image classifications. Empirical results demonstrate that our algorithm is able to maintain robustness on the target task for both synthetically generated environments and real-world environments.

Introduction

Standard Empirical Risk Minimization (ERM) often fails in the presence of spurious correlations. For instance, a model trained to recognize animals might rely on background features (e.g., green grass for cows) rather than the animal's actual features. When these correlations change at test time—a phenomenon known as distribution shift—the model's performance typically collapses. Identifying these "unstable" features is challenging because bias is often task-specific and human-defined.

Existing approaches to mitigate bias usually require manual annotations of the bias attributes or multiple training environments where the spurious correlations vary. However, in many practical scenarios, we only have access to a single, biased dataset for the target task. This research proposes TOFU (Transfer OF Unstable features), a framework that transfers knowledge about unstable features from a resource-rich source task to a resource-scarce target task.

Methodology: The TOFU Framework

TOFU operates on the premise that related tasks often share the same underlying biases. The algorithm consists of two primary stages:

1. Inferring Unstable Features from the Source Task

The source task is assumed to have multiple environments where the correlation between spurious features and labels differs. By training a classifier on one environment and testing it on another, the model's errors provide a signal for identifying unstable features. The authors use a triplet loss to learn a representation $f_Z$ that encodes these features, ensuring that examples with similar prediction outcomes (relative to the ground truth) are mapped closely together in the feature space.

2. Learning Stable Correlations for the Target Task

The learned representation $f_Z$ acts as a "bias detector" for the target task. Even if the target task has only one environment, $f_Z$ can be used to cluster target data. These clusters serve as proxies for different values of the hidden bias. TOFU then applies Group Distributionally Robust Optimization (Group DRO) to minimize the worst-case loss across these clusters, forcing the model to rely on stable features that generalize across all identified "bias groups."

Overview of the TOFU transfer paradigm: Source task (0 vs 1) environments provide bias information used to improve robustness in the target task (2 vs 3), significantly outperforming standard ERM and finetuning.

Experimental Evaluation

The authors evaluated TOFU across several benchmarks, including synthetic (Colored MNIST, BeerReview) and real-world (ASK2ME, Waterbird, CelebA) datasets.

Key Results

  • Performance Gains: On synthetic tasks, TOFU improved accuracy by 22.9% over the best baseline, nearly reaching the performance of an "Oracle" model with full access to bias labels.
  • Real-World Robustness: On the CelebA dataset, TOFU achieved the highest worst-group accuracy across 38 latent attributes, outperforming the best baseline by 18.06%.
  • Representation Quality: PCA visualizations confirmed that the learned representation $f_Z$ effectively separated target data based on spurious features (e.g., color), despite not seeing target labels during source training.

Conclusion and Future Work

TOFU demonstrates that transferring knowledge about unreliable features is a potent strategy for building robust models. By leveraging shared biases across tasks, it reduces the need for expensive manual annotations in new domains. Future work includes extending this framework to cross-domain settings and streamlining the multi-step training process into an end-to-end pipeline.

Summary updated

BibTeX
@inproceedings{bao2022learning,
  author = {Yujia Bao and Shiyu Chang and Regina Barzilay},
  title = {{Learning Stable Classifiers by Transferring Unstable Features}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=xs-tJn58XKv},
}
Figure