NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Demographics Should Not Be the Reason of Toxicity: Mitigating Discrimination in Text Classifications with Instance Weighting

Guanhua Zhang, Bing Bai, Junqi Zhang, Kun Bai, Conghui Zhu, Tiejun Zhao

Abstract

Guanhua Zhang, Bing Bai, Junqi Zhang, Kun Bai, Conghui Zhu, Tiejun Zhao. Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics.

2020.

Introduction: The Problem of Unintended Bias

Machine learning models for toxicity detection often inherit human prejudices present in their training data. When certain identity terms (e.g., "gay," "black," "muslim") appear disproportionately in toxic comments, models learn a "shortcut": they associate the demographic term itself with toxicity. This leads to unintended bias, where benign sentences like "She makes me happy to be gay" are incorrectly flagged as abusive.

Table 1: Toxicity rates for specific identity terms in the training data.

As shown in Table 1, in some datasets, comments containing the word "gay" are labeled toxic 57.4% of the time, compared to a general toxicity rate of only 9.6%. Previous mitigation strategies often relied on expensive data supplementation or "word swapping," which can produce ungrammatical or nonsensical training examples.

Methodology: Non-discrimination Learning via Instance Weighting

The authors propose a model-agnostic framework that treats demographic bias as a "selection bias." They assume an "ideal" non-discrimination distribution where identity does not predict toxicity, and our actual data is a biased sample from that world.

To correct this, they use Instance Weighting:

  1. Bias Estimation: A secondary classifier estimates $P(y|z)$, the probability of a label $y$ given identity terms $z$.
  2. Weight Calculation: Each training sample is assigned a weight $w = Q(y) / P(y|z)$, where $Q(y)$ is the prior label probability in the ideal distribution.
  3. Debiased Training: The main model (CNN, LSTM, etc.) is trained by minimizing a weighted loss function. This forces the model to ignore demographic shortcuts and focus on actual semantic indicators of toxicity.

Experimental Results

The researchers evaluated their method on three benchmarks: Sexist Tweets, Toxicity Comments, and Jigsaw Toxicity. They used Identity Phrase Templates Test Sets (IPTTS)—neutral synthetic sentences—to measure fairness.

The weighting method significantly improved fairness metrics like False Positive Equality Difference (FPED) and False Negative Equality Difference (FNED). For instance, on the Jigsaw dataset, the weighting method achieved an FPED of 0.085, a massive improvement over the baseline's 3.088.

Figure 1: Comparison of error rate disparities (ΔFPR and ΔFNR) between the Baseline and Instance Weighting models.

As visualized in Figure 1, the weighting method (right columns) makes error rates much more uniform across different identities compared to the baseline (left columns), which shows significant spikes in false positives for minority groups. While debiasing often slightly reduces overall accuracy (AUC) on the original biased test set, the weighting method maintained higher performance on the "fair" IPTTS test set compared to other debiasing techniques.

Conclusion

By framing social prejudice as a statistical selection bias, this framework allows for effective debiasing without requiring new data or compromising grammatical integrity. While it relies on pre-defined identity lists, it offers a robust, model-agnostic path toward fairer text classification.

Summary updated

BibTeX
@inproceedings{zhang2020demographics,
  author = {Guanhua Zhang and Bing Bai and Junqi Zhang and Kun Bai and Conghui Zhu and Tiejun Zhao},
  title = {{Demographics Should Not Be the Reason of Toxicity: Mitigating Discrimination in Text Classifications with Instance Weighting}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2020},
  url = {https://openreview.net/forum?id=oW-eg0zATFT},
}
Figure