Improving Counterfactual Generation for Fair Hate Speech Detection (2021)

Abstract: Bias mitigation approaches reduce models’ dependence on sensitive features of data, such as social group tokens (SGTs), resulting in equal predictions across the sensitive features. In hate speech detection, however, equalizing model predictions may ignore important differences among targeted social groups, as hate speech can contain stereotypical language specific to each SGT. Here, to take the specific language about each SGT into account, we rely on counterfactual fairness and equalize predictions among counterfactuals, generated by changing the SGTs. Our method evaluates the similarity in sentence likelihoods (via pre-trained language models) among counterfactuals, to treat SGTs equally only within interchangeable contexts. By applying logit pairing to equalize outcomes on the restricted set of counterfactuals for each instance, we improve fairness metrics while preserving model performance on hate speech detection.

## introduction hate speech classifiers have high false-positive error rates in documents mentioning specific social group tokens (sgts; e.g., "asian", "jew"), due in part to the high prevalence of sgts in instances of hate speech @xcite . when propagated into social media content moderation, this unintended bias @xcite leads to unfair outcomes, e.g., mislabeling mentions of protected social groups as hate speech. for prediction tasks in which sgts do not play any special role (e.g., in sentiment analysis), unintended bias can be reduced by optimizing grouplevel fairness metrics such as equality of odds, which statistically equalizes model performance across all social groups @xcite . however, in hate speech detection, this is not the case, with sgts providing key information for the task (see fig. 1 ). instead, bias figure 1 : two input sentences and their counterfactuals ranked by likelihood. our method ensures similar outputs only for counterfactuals with higher likelihood. mitigation in hate speech detection benefits from relying on individual-level fairness metrics such as counterfactual fairness, which assess the output variation resulting from changing the sgt in individual sentences @xcite . derived from causal reasoning, a counterfactual applies the slightest change to the actual world to assess the consequences in a similar world @xcite . accordingly, existing approaches for reducing bias in hate speech detection using counterfactual fairness learn robust models whose outputs are not affected by changing the sgt in the input @xcite . however, a drawback of such approaches is the lack of semantic analysis of the input to identify whether changing the sgt leads to a small enough change that preserves the hate speech label @xcite . for instance, in a hateful statement, "mexicans should go back to their sh*thole countries", substituting "mexicans" with "women" changes the hate speech label, while using "hispanics" should preserve the output. here, we aim to create counterfactuals that maximally preserve the sentence and disregard counterfactuals that violate the requirement for be-ing the "closest possible world" (fig. 1 ). to this end, we develop a counterfactual generation method which filters candidate counterfactuals based on their difference in likelihood from the actual sentence, estimated by a pre-trained language model with known stereotypical correlations @xcite . intuitively, our method provides outputs that are robust with regard to the context and are not causally dependent on the presence of specific sgts. this use of sentence likelihood is inspired by @xcite as it captures the similarity of an sgt and its surrounding words to prevent unlikely sgt substitutions. as a result, only counterfactuals with equal or higher likelihoods compared with the original ("closest possible worlds") are used during training. to enforce robust outputs for similar counterfactuals, we apply logit pairing @xcite on outputs for sentence-counterfactual pairs, adding their average differences to the classification loss. our method (1) effectively identifies semantically similar counterfactuals and (2) improves fairness metrics while preserving classification performance, compared with other strategies for generating counterfactuals. ## related work unintended bias in classification is defined as differing model performance on subsets of datasets that contain particular sgts @xcite . to mitigate this bias, data augmentation approaches are proposed to create balanced labels for each sgt or to prevent biases from propagating to the learned model @xcite @xcite . other approaches apply regularization of post-hoc token importance @xcite , or adversarial learning for generating fair representations @xcite to minimize the importance of protected features. by altering sensitive features of the input and assessing the changes in the model prediction, counterfactual fairness @xcite seeks causal associations between sensitive features and other data attributes and outputs. similarly, counterfactual token fairness applies counterfactual fairness to tokens in textual data @xcite . counterfactual fairness presupposes that the counterfactuals are close to the original world. however, previous work has yet to quantify this similarity in textual data. key to our proposed framework is evaluating the semantic similarity between the original and the synthetically generated instances to only consider counterfactuals that convey similar sentiment. consequently, our method prevents synthetic counterfactuals unlikely to exist in real-world samples which (1) decrease classification accuracy by adding noise into the training process and (2) misdirect fairness evaluation by introducing unexpected criteria. ## method we propose a method for improving individual fairness in hate speech detection by considering the interchangeable role of sgts in each specific context. given instance @xmath0, and a set of sgts s, we seek to equalize outputs of a classifier f for x and its counterfactuals x cf generated by substituting the sgt mentioned in x. first, we provide the definition of counterfactual token fairness (ctf), which can be evaluated for a model over a dataset of sentences and their counterfactuals (sec. 3.1). next, we specify how counterfactual logit pairing (clp) regularizes ctf in a classification task (sec. 3.2). lastly, we introduce our counterfactual generation method for assessing counterfactual likelihoods (acl, sec. 3.3), which is driven by linguistic analysis of stereotype language in sentences. ## experiments here, we apply our method for generating counterfactuals (sec. 3.3) to a large corpus to explore the method's ability to identify similar counterfactuals. then, we apply clp (sec. 3.2) with different strategies for counterfactual generation and compare them to our approach, introduced in sec. 3.3. ## conclusion our method treats social groups equally only within interchangeable contexts by applying logit pairing on a restricted set of counterfactuals. we demonstrated that biased pre-trained language models could enhance counterfactual fairness by identifying stereotypical sentences. our method improved counterfactual token fairness and classification accuracy by filtering unlikely counterfactuals. future work may explore semantic-based techniques for creating counterfactuals in domains other than hate speech detection, e.g., crime prediction, to better contextualize definitions of social group equality.