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?"
The ATE Calculation Process
- 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.
- Treatment Effect (TE): The difference in toxicity score between the original sentence and the perturbed sentence is calculated.
- ATE Score: These differences are averaged across multiple contexts to derive an ATE score for individual words.
- 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."
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