Counterfactual Inference for Text Classification Debiasing

Chen Qian, Fuli Feng, Lijie Wen, Chunping Ma, Pengjun Xie

Introduction

Machine learning models for text classification often rely on "shortcuts"—unintended dataset biases—rather than learning the true semantics of the text. These shortcuts typically manifest as Label Bias, where a model over-predicts a majority class regardless of input, and Keyword Bias, where specific words are spuriously correlated with labels (e.g., a neutral word appearing predominantly in negative examples). Traditional solutions like data resampling are often costly and require retraining. This paper introduces CORSAIR, a model-agnostic framework that identifies and removes these biases during the inference stage using counterfactual reasoning.

The CORSAIR Framework

CORSAIR (COunterfactual-inference-based text-classification Removal of Spurious Associations and Inference Refinement) operates in three distinct stages to refine model predictions without requiring architectural changes to the base classifier.

  1. Biased Learning: A base model (e.g., RoBERTa or TextCNN) is trained normally on biased data, allowing it to capture both legitimate patterns and dataset flaws.
  2. Bias Distillation: During inference, CORSAIR generates two counterfactual scenarios for each input. A fully-blindfolded version (all words masked) isolates the model's internal label bias. A partially-blindfolded version (masking only main content words identified via TextRank) isolates keyword bias by forcing the model to predict based only on context words.
  3. Bias Removal: The distilled label and keyword biases are subtracted from the original factual prediction. To balance these subtractions, Elastic Scaling is used to find optimal scaling factors ($\lambda$) on a validation set.
The CORSAIR architecture: from biased learning to counterfactual distillation and final bias removal.

Experimental Setup and Results

The researchers evaluated CORSAIR across 11 diverse datasets, including English benchmarks like HyperPartisan and YelpHotel, and large-scale Chinese e-commerce datasets (TAO and SUN). The framework was tested against several base models, including TextCNN, LECO, and RoBERTa.

Performance Gains

CORSAIR consistently improved performance across all tested configurations. On average, it improved the Macro-F1 score of TextCNN by 5.20% and the specialized debiasing model WEIGHT by 7.55%. These results demonstrate that even models specifically designed for debiasing can benefit from CORSAIR's inference-time refinement.

Macro-F1 performance results across 11 datasets, showing consistent improvements when CORSAIR is applied.

Fairness and Robustness

Beyond accuracy, CORSAIR significantly improved model fairness by reducing "Imbalance Divergence." For RoBERTa, label imbalance was reduced by 9.50% and keyword imbalance by 4.41%. Ablation studies confirmed that removing either the label bias removal (LBR) or keyword bias removal (KBR) components led to a drop in performance, highlighting the necessity of addressing both types of spurious associations.

Key Insights

  • Keyword Bias Dominance: Experiments revealed that keyword bias is often more pervasive and harder to correct than label bias, as models rely heavily on specific "evil" keywords.
  • The Operational Gap: Interestingly, training a model with a counterfactual objective from the start performed worse than training a biased model and correcting it later. This "gap" allows for better isolation of biases during the distillation phase.
  • Model Agnosticism: Because CORSAIR operates on output probability distributions, it can be integrated into existing production pipelines with minimal friction.

Conclusion and Future Work

CORSAIR provides a robust, post-hoc method for debiasing text classifiers. While highly effective, the framework currently relies on external tools like TextRank to identify content words. Future research will explore joint-learning techniques to dynamically distinguish between "main content" and "confounding bias" during the distillation process, further automating the refinement of text classification.

Summary updated

BibTeX
@inproceedings{qian2021counterfactual,
  author = {Chen Qian and Fuli Feng and Lijie Wen and Chunping Ma and Pengjun Xie},
  title = {{Counterfactual Inference for Text Classification Debiasing}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.acl-long.422},
}
Figure