Causal ATE Mitigates Unintended Bias in Controlled Text Generation

Rahul Madhavan, Kahini WadhawanarXiv 2023

Abstract

We study attribute control in language models through the method of Causal Average Treatment Effect (Causal ATE). Existing methods for the attribute control task in Language Models (LMs) check for the co-occurrence of words in a sentence with the attribute of interest, and control for them. However, spurious correlation of the words with the attribute in the training dataset can cause models to hallucinate the presence of the attribute when presented with the spurious correlate during inference. We show that the simple perturbation-based method of Causal ATE removes this unintended effect. Specifically, we ground it in the problem of toxicity mitigation, where a significant challenge lies in the inadvertent bias that often emerges towards protected groups post detoxification. We show that this unintended bias can be solved by the use of the Causal ATE metric and rigorously prove our claim.

Introduction

In the effort to "detoxify" language models, researchers typically train classifiers to identify and penalize toxic text. However, these models frequently fall victim to unintended bias. Because training datasets often contain hateful speech directed at specific demographics, words such as "gay," "Muslim," or "female" frequently co-occur with toxic content. Standard models learn these correlations and begin to "hallucinate" toxicity whenever these identity terms appear, even in neutral contexts. This leads to a "silencing" effect where models avoid discussing protected groups to remain within safety parameters. This research proposes moving from correlation-based detection to a causal framework to break this link.

Methodology

The proposed method utilizes the Causal Average Treatment Effect (ATE) as a metric for attribute control. Rather than measuring how often a word appears in toxic sentences (correlation), the ATE asks: "If I swap this specific word for a different one, how much does the toxicity of the sentence change?"

Causal framework for attribute control using ATE scores and memory context.

The ATE Calculation Process

  1. Counterfactual Perturbation: For a given word in a sentence, a Masked Language Model (MLM) suggests a "counterfactual" replacement—a word that fits the context but is likely neutral.
  2. Treatment Effect (TE): The difference in toxicity score between the original sentence and the perturbed sentence is calculated.
  3. ATE Score: These differences are averaged across multiple contexts to derive an ATE score for individual words.
  4. Sentence Scoring: Word-level ATE scores are aggregated using an $L_p$-norm to determine the overall attribute score for a full sentence.

A key theoretical contribution of this work is Theorem 1, which proves that for "spurious correlates" (words that do not cause the attribute), the ATE score is theoretically upper-bounded by 0.25. This provides a rigorous mathematical threshold for filtering out bias.

Experimental Setup

The approach was evaluated on two toxicity classification benchmarks:

  • Zampieri et al. (2019): The OffensEval dataset, containing social media posts categorized by offensive language.
  • Gao and Huang (2017): A dataset focused on online hate speech detection.

The study specifically monitored performance across protected categories, including African, Black, Female, Gay, and Hispanic identifiers.

Results

Experimental results across various model architectures (Logistic Regression, SVM, Naive Bayes, and Neural Networks) demonstrated that the ATE method effectively acts as a "causal filter."

Comparison of raw classifier predictions vs. Causal ATE scores across the Zampieri et al. and Gao et al. datasets.

As shown in the figures above, the ATE scores for protected groups were significantly lower than the raw classifier predictions. For instance, in the Gao et al. dataset using a Naive Bayes model, the "Gay" category had a raw toxicity prediction of 0.657, which the ATE method reduced to 0.107. This reduction indicates that the model is much less likely to incorrectly flag neutral sentences containing identity terms as toxic, thereby lowering false positives and improving fairness.

Discussion and Conclusion

The primary insight of this work is that words causing toxicity (e.g., slurs) maintain high ATE scores because their removal drastically changes the sentence's impact. Conversely, identity terms—which are spurious correlates—yield low ATE scores because the surrounding context remains toxic-leaning regardless of the specific identity term used.

While the method shows great promise, it remains dependent on the quality of the base attribute detector and involves higher computational costs due to the need for counterfactual generation. Future work will focus on scaling this approach to more diverse languages and integrating it directly into the training loops of Large Language Models (LLMs) to prevent bias from forming during the initial learning phase.

Summary updated

Abstract

We study attribute control in language models through the method of Causal Average Treatment Effect (Causal ATE). Existing methods for the attribute control task in Language Models (LMs) check for the co-occurrence of words in a sentence with the attribute of interest, and control for them. However, spurious correlation of the words with the attribute in the training dataset, can cause models to hallucinate the presence of the attribute when presented with the spurious correlate during inference. We show that the simple perturbation-based method of Causal ATE removes this unintended effect. Specifically, we ground it in the problem of toxicity mitigation, where a significant challenge lies in the inadvertent bias that often emerges towards protected groups post detoxification. We show that this unintended bias can be solved by the use of the Causal ATE metric and rigorously prove our claim. We provide experimental validations for our claims and release our code (anonymously) here: https://github.com/causalate-mitigates-bias/causal-ate-mitigates-bias.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
Gao et al. datasetCausal ATE with LRATE0.099classifier=LR · protected-category=African
Source quote
L309: LR │ 0.201 │ 0.099 │ \textcolor{darkcyan}{0.102} │ 0.300 │ 0.108 │ \textcolor{darkcyan}{0.192} │ 0.270 │ 0.167 │ \textcolor{darkcyan}{0.103} │ 0.470 │ 0.167 │ \textcolor{darkcyan}{0.303} │ 0.166 │ 0.011 │ \textcolor{darkcyan}{0.155}
Gao et al. datasetCausal ATE with LRATE0.167classifier=LR · protected-category=Female
Source quote
L309: LR │ 0.201 │ 0.099 │ \textcolor{darkcyan}{0.102} │ 0.300 │ 0.108 │ \textcolor{darkcyan}{0.192} │ 0.270 │ 0.167 │ \textcolor{darkcyan}{0.103} │ 0.470 │ 0.167 │ \textcolor{darkcyan}{0.303} │ 0.166 │ 0.011 │ \textcolor{darkcyan}{0.155}
Zampieri et al. datasetCausal ATE with LRATE0.020classifier=LR · protected-category=African
Source quote
L325: LR │ 0.174 │ 0.020 │ \textcolor{darkcyan}{0.154} │ 0.236 │ 0.049 │ \textcolor{darkcyan}{0.187} │ 0.297 │ 0.075 │ \textcolor{darkcyan}{0.223} │ 0.260 │ 0.098 │ \textcolor{darkcyan}{0.162} │ 0.161 │ 0.143 │ \textcolor{darkcyan}{0.018}
Reported baseline / comparator measurements (3)
BenchmarkMethodMetricScoreProtocol / Evidence
Gao et al. datasetLR (Pred) baselinePred0.201classifier=LR · protected-category=African
Source quote
L309: LR │ 0.201 │ 0.099 │ \textcolor{darkcyan}{0.102} │ 0.300 │ 0.108 │ \textcolor{darkcyan}{0.192} │ 0.270 │ 0.167 │ \textcolor{darkcyan}{0.103} │ 0.470 │ 0.167 │ \textcolor{darkcyan}{0.303} │ 0.166 │ 0.011 │ \textcolor{darkcyan}{0.155}
Gao et al. datasetLR (Pred) baselinePred0.270classifier=LR · protected-category=Female
Source quote
L309: LR │ 0.201 │ 0.099 │ \textcolor{darkcyan}{0.102} │ 0.300 │ 0.108 │ \textcolor{darkcyan}{0.192} │ 0.270 │ 0.167 │ \textcolor{darkcyan}{0.103} │ 0.470 │ 0.167 │ \textcolor{darkcyan}{0.303} │ 0.166 │ 0.011 │ \textcolor{darkcyan}{0.155}
Zampieri et al. datasetLR (Pred) baselinePred0.174classifier=LR · protected-category=African
Source quote
L325: LR │ 0.174 │ 0.020 │ \textcolor{darkcyan}{0.154} │ 0.236 │ 0.049 │ \textcolor{darkcyan}{0.187} │ 0.297 │ 0.075 │ \textcolor{darkcyan}{0.223} │ 0.260 │ 0.098 │ \textcolor{darkcyan}{0.162} │ 0.161 │ 0.143 │ \textcolor{darkcyan}{0.018}
BibTeX
@misc{madhavan2023causal,
  author = {Rahul Madhavan and Kahini Wadhawan},
  title = {{Causal ATE Mitigates Unintended Bias in Controlled Text Generation}},
  year = {2023},
  eprint = {2311.11229},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2311.11229},
}
Figure