Controlling Learned Effects to Reduce Spurious Correlations in Text Classifiers

Parikshit Bansal, Amit Sharma

Abstract

To address the problem of NLP classifiers learning spurious correlations between training features and target labels, a common approach is to make the model’s predictions invariant to these features. However, this can be counter-productive when the features have a non-zero causal effect on the target label and thus are important for prediction. Therefore, using methods from the causal inference literature, we propose an algorithm to regularize the learnt effect of the features on the model’s prediction to the estimated effect of feature on label. This results in an automated augmentation method that leverages the estimated effect of a feature to appropriately change the labels for new augmented inputs. On toxicity and IMDB review datasets, the proposed algorithm minimises spurious correlations and improves the minority group (i.e., samples breaking spurious correlations) accuracy, while also improving the total accuracy compared to standard training.

Introduction

Standard NLP classifiers are notorious for over-relying on "shortcuts"—spurious correlations where a specific feature is highly correlated with a label in the training set, leading the model to ignore broader context. For example, a sentiment classifier might decide a review is positive simply because it contains the string "8/10," even if the surrounding text describes a "skin peeling bad movie."

Visualizing spurious correlations: features like "8/10" can mislead models when they contradict the overall sentiment.

The traditional solution is to enforce invariance, forcing the model to ignore the feature entirely. However, this "sledgehammer" approach is often counter-productive. Many features are "partially spurious"—they carry useful signal in some contexts but are misleading in others. Completely removing them degrades overall accuracy. The challenge lies in "tuning" the model's sensitivity to a feature rather than simply disabling it.

Methodology: Feature Effect Augmentation (FEAG)

Presented at ACL 2023, this research proposes Feature Effect Augmentation (FEAG). Instead of ignoring features, FEAG uses causal inference to estimate the true effect of a feature on a label and then uses automated data augmentation to teach the model to weigh that feature appropriately.

The approach relies on a causal framework where the writer's intent ($C$) influences both the treatment feature ($T$) and the rest of the text ($X$), which together determine the outcome label ($Y$).

Causal graph representing the relationship between writer intent (C), text features (T, X), and outcome labels (Y).

The FEAG algorithm consists of two phases:

  1. Estimation via the Riesz Representer: To determine how much a feature should matter, the authors estimate its Average Treatment Effect (ATE). While standard causal tools like propensity scores often fail on high-dimensional, sparse text data (leading to high variance), the authors utilize a Riesz-based causal estimator. This method estimates weights for samples directly, providing a much more stable path for causal text analysis.
  2. Control via Augmentation: Once the true effect ($\tau$) is estimated, the system generates counterfactual examples. If an original text contains the feature ($T=1$), a version is created without it ($T=0$). The label for this new version is adjusted based on the estimated effect $\tau$. The final classifier is then trained on a combination of original and corrected counterfactual data.

Experimental Results

The researchers evaluated FEAG on two primary domains: CivilComments (Toxicity) and IMDB Reviews. In the IMDB dataset, numeric ratings (e.g., "9/10") served as the spurious feature.

Key Insights

  • Estimation Accuracy: The Riesz estimator proved significantly more accurate than standard "Direct" or "Propensity" methods. In low-overlap scenarios—where a word is extremely highly correlated with a class—Riesz reduced effect estimation error by orders of magnitude.
  • Performance Trade-offs: On the IMDB dataset, FEAG achieved the highest average group accuracy (~63-68%). Unlike baselines like GroupDRO or IRM, which often improve minority group performance at the expense of total accuracy, FEAG maintained high overall performance while reducing reliance on shortcuts.
  • Detecting Bias: The tool also revealed human annotator bias. By estimating the effect of identity terms (e.g., "gay," "black") on toxicity labels, the authors found these words had a high "causal" effect on labels, suggesting that the training data itself contained biased associations that should ideally be zero.

Conclusion and Future Work

FEAG demonstrates that treating feature importance as a continuous value to be regularized—rather than a binary choice of inclusion or exclusion—allows models to remain robust without a performance "tax."

Future work remains in extending this framework beyond discrete tokens to more abstract concepts like "writing style" or "politeness," which are harder to "flip" for counterfactual generation. Additionally, while the Riesz model adds a computational step, its stability makes it a compelling choice for engineers working with causal inference in NLP.

Summary updated

Abstract

To address the problem of NLP classifiers learning spurious correlations between training features and target labels, a common approach is to make the model’s predictions invariant to these features. However, this can be counter-productive when the features have a non-zero causal effect on the target label and thus are important for prediction. Therefore, using methods from the causal inference literature, we propose an algorithm to regularize the learnt effect of the features on the model’s prediction to the estimated effect of feature on label. This results in an automated augmentation method that leverages the estimated effect of a feature to appropriately change the labels for new augmented inputs. On toxicity and IMDB review datasets, the proposed algorithm minimises spurious correlations and improves the minority group (i.e., samples breaking spurious correlations) accuracy, while also improving the total accuracy compared to standard training.
BibTeX
@inproceedings{bansal2023controlling,
  author = {Parikshit Bansal and Amit Sharma},
  title = {{Controlling Learned Effects to Reduce Spurious Correlations in Text Classifiers}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  url = {https://openreview.net/forum?id=Pj0nzC9JCg},
}
Figure