Necessity and Sufficiency for Explaining Text Classifiers: A Case Study in Hate Speech Detection
Paper · 2022 · Esma Balkir, Isar Nejadgholi, Kathleen Fraser et al.
Summary
A hate speech classifier marks a sentence as hateful, and an explanation highlights the name of the group it targets. What does the highlight mean? Changing the group name might make the classifier reverse its decision. Keeping the group name might make it keep the same decision even after the rest of the sentence becomes benign. These are different kinds of dependence. In text classification, a single importance score can leave the distinction unresolved. Balkır and colleagues give each word two scores, necessity and sufficiency, to ask what happens when the word is changed and what happens when it survives changes to its surroundings.
The authors estimate the scores by editing the input and submitting the edited sentences to the same classifier. For necessity, they examine edits that replace the word of interest. For sufficiency, they preserve that word and alter other parts of the sentence. An infilling system replaces the selected stretches with text that fits their surroundings. It learns from examples labeled benign, which helps it propose alternatives that give the classifier a chance to reverse its positive decision. The resulting texts can be inspected alongside the scores, so a reader can see what kinds of changes went into the explanation.
The authors apply the method to six classifiers trained to detect either hate speech or the broader category of abusive language. They score identity terms in explicit attacks on women and Muslims in HateCheck, then compare the scores with the classifiers’ behavior on other tests. For Founta2018-hate, the mean sufficiency was 0.29 for the term referring to women and 0.81 for the term referring to Muslims. On HateCheck’s neutral and supportive identity mentions, the same classifier labeled proportions of 0.02 and 0.78 positive for those respective groups. Necessity helped diagnose a different error. Founta2018-abuse had the lowest mean necessity for both identity terms and the highest positive prediction rates on tests of abuse aimed at objects, individuals, and groups outside the protected categories.
These results show how scores calculated on correctly classified attacks can help explain mistakes on other sentences. High sufficiency can flag a classifier that treats an identity mention as evidence of hate even in benign contexts. Low necessity can flag one that reacts to abusive wording across very different kinds of targets. The paper finds examples in which SHAP and LIME assign similar average importance to identity terms for classifiers with different error patterns. The two scores make those patterns easier to distinguish, within the English-language tests and generated alternatives the authors examine.
Deep dive: Necessity and Sufficiency for Explaining Text Classifiers: A Case Study in Hate Speech Detection
Balkır and colleagues use necessity and sufficiency to explain which words drive hate speech classifications and diagnose distinct false positives. · about 32 minutes to read
The problem and its context
What a highlighted word can mean
A local explanation answers a question about a particular decision. A developer inspecting a moderation system might want to know why a post received a hate speech label. A person disputing a decision might want to know which part of their message prompted it. In either case, highlighting a word only begins the explanation. The reader needs to know what the classifier does when that word is changed, or what it does when the word still appears in a different context. The paper treats that gap between a visual highlight and a testable statement as a problem for interpretability.
The distinction matters because an identity term can play a legitimate role in identifying hate speech. In the paper’s example, an utterance expresses hatred towards women. Changing the target from women to oranges preserves the expression of dislike while changing the kind of thing it is directed at. A classifier sensitive to the paper’s distinction between abuse and identity-directed hate should be capable of changing its decision. That makes the identity term a candidate for high necessity. If the same term occurs in a friendly or factual sentence, the classifier should be capable of assigning a benign label. That makes low sufficiency desirable for the identity term under suitably varied contexts.
The reverse patterns have concrete implications. A positive label that persists when an identity term is surrounded by benign language can interfere with ordinary conversation about a group. A label that persists when a protected target has been replaced with an object can reveal reliance on expressions of hostility with little regard for their target. Both can produce false positives under a hate speech standard. They call for different explanations of what the classifier is responding to. The paper situates this concern in earlier work on unintended bias and abusive-language detection, including work on gender bias. Reducing Gender Bias in Abusive Language Detection
The narrower definition of hate speech also shapes what counts as an informative mistake. In the study, general abuse can include attacks that do not target a protected identity. Detecting a personal insult can therefore fit the intended task of an abuse classifier, even where the benchmark labels that sentence non-hateful. An explanation that reveals weak reliance on the identity term can help a reader understand a mismatch between tasks as well as an unwanted dependence within a task. The paper uses both possibilities to motivate looking at the target and its surrounding language separately. A Survey on Automatic Detection of Hate Speech in Text
From importance scores to edited examples
The paper distinguishes explanations of individual decisions from accounts of how a classifier generally works. It also distinguishes systems that produce explanations as part of prediction from explanations generated afterwards. Its method belongs to the local, post-hoc category. The classifier makes a decision first. A separate procedure probes it by submitting edited text and collecting labels. This interface lets the authors apply the same explanation procedure to classifiers trained on different data or under different labeling rules.
Feature attribution is the family of methods that gives each part of an input a score for its contribution to a prediction. The paper describes approaches tied to a particular architecture and approaches designed for a classifier treated as a black box. LIME and SHAP are examples of the latter in the related work and serve as baselines in the experiments. Their presence gives the study a concrete comparison. The question is whether the extra distinction between removing a feature and retaining it helps interpret behavior that a single average attribution leaves ambiguous. LIME, SHAP
Counterfactual explanations start from a different kind of evidence. They give the reader a variant of the input and show what the classifier does with it. A closely related sentence that receives the opposite label can make a decision boundary tangible. Some earlier methods discussed in the paper look for a particular change, such as adding negation or rearranging constituents. Such edits help isolate a linguistic phenomenon. The authors’ question requires a collection of alternatives because both scores concern how frequently an outcome occurs across a range of edits. A single compelling contrast can illustrate why a word received its score, while the other alternatives determine how representative that contrast is. Polyjuice, MiCE
The proposal combines the two approaches. It gives readers numbers that can be compared across words, examples, and classifiers, and it grounds those numbers in sentences that a reader can inspect. This matters in a domain where a small textual change can have several consequences. An edit might replace the target with another entity, introduce a denial, or make a remark describe the speaker’s feelings. The aggregate score answers a question about the classifier’s response to the collection. The sentences show which semantic changes supplied that evidence.
Why the alternatives matter
Probing a classifier by changing a feature depends on being able to produce a meaningful changed input. For a tabular system, a feature often has a named column and a set of recognizable values. A word in a sentence draws part of its meaning from the other words. Deleting it can break the sentence. Replacing it with a special mask can tell a pretrained system that a span is absent, but a classifier subsequently trained on ordinary text may respond to the mask as an unusual input. In either case, a label change can reflect the disturbance introduced by the editing technique. A Benchmark for Interpretability Methods in Deep Neural Networks
The related work also frames this as a problem of social alignment. An explanation can report the result of a well-defined operation and still conflict with what a person takes the operation to mean. A reader who hears that the explanation “removed the target” may imagine a meaningful sentence about a different target. A classifier that actually received a fragment or several masks was exposed to a different comparison. Filling the gap with readable language makes it easier to see what the operation did and to judge whether that operation speaks to the original question. Aligning Faithful Interpretations with their Social Attribution
Prior work addressed this problem by averaging predictions over plausible fills for a blank. Balkır and colleagues describe a practical drawback they encountered with BERT-based fills. In their preliminary experiments, probability concentrated on a small number of common alternatives. The paper also cites evidence that a masked predictor frequently recovers the original word. If the word is frequently restored, the set of attempted changes includes many cases that preserve it. A low measured effect can then reflect how readily the word was guessed from context. Generating stretches of varying lengths gives the procedure more ways to complete the surrounding text.
The authors draw the definitions of necessity and sufficiency from earlier work on probabilistic causal explanations. The question is about intervention: an analyst deliberately changes a value and checks what happens to the decision. Earlier work had developed related measures for structured inputs, and studies of textual rationales had used related ideas to test whether selected evidence supports a prediction. Rationale evaluation ordinarily begins with a selected portion of the text. Balkır and colleagues use the two questions to build a pair of scores for each feature value in context. Using Annotator Rationales to Improve Machine Learning for Text Categorization
The method, step by step
Start with a positive decision
The method begins with a sentence and the binary classifier’s decision about it. In the hate speech study, the authors explain positive decisions. They motivate that choice through the asymmetry of the task. Benign utterances form the assumed majority, and ordinary benign speech can be unremarkable in many different ways. A positive decision prompts a more specific question about which part of the sentence made the classifier treat it as exceptional. The paper connects that choice to Miller’s account of why people seek explanations for selected aspects of an event. Explanation in Artificial Intelligence
Suppose the word being inspected is the target in an expression of hatred. To estimate necessity, the procedure looks at versions of the sentence in which that word is among the parts selected for editing. If the label regularly changes to negative, the word receives a higher necessity score. To estimate sufficiency, the procedure uses versions in which the target word survives and some surrounding material is edited. If the result often still receives a positive label, sufficiency is higher. The alternatives can replace different spans in each trial. The comparison is between patterns of predictions across those trials.
This makes the scores local in a precise sense. The same word can have different scores in different sentences because its neighbors change what the generator can put in the blanks and what the classifier sees as evidence. It can also have different scores for the same sentence under different classifiers. The method keeps the generated inputs available, so a difference between classifiers can be traced to their responses to particular sentences. A difference between contexts can also reflect which replacements were plausible in each context.
From a positive decision to word-level attribution
The steps in order.
The conditional probabilities
The formal definitions begin with a feature vector containing the individual values that describe the input. In the text application, the value of interest is a token in its context. The arrow marks a deliberate assignment. This is the operation that lets the authors ask how the classifier responds to a changed feature.
X ← a
Here X is the variable that the analyst intervenes on, a is the value assigned to it, and ← means to set the variable to that value. Applied to a feature vector, a subscript can identify the position whose value is deliberately changed.
N(xᵢ, y) = Pc ∼ Dₙ(x) = y′ | cᵢ = a, f(c) = y)
N(xᵢ, y) is the necessity of the value xᵢ for the original prediction y. The original input is x, i identifies the feature position, and its observed value xᵢ is a. P denotes probability, and c ∼ Dₙ(x) means the neighboring input c is drawn from the necessity distribution around x. The classifier is f, and f(c) is its prediction before the specific intervention on position i. The notation cᵢ←a′ means the input c after setting that position to the alternative value a′, which differs from a. The alternate label is y′, which differs from y. The bar | introduces the conditions on the starting point, the equal signs specify equalities, and the comma after cᵢ = a requires both conditions to hold.
In ordinary language, the definition starts with neighboring inputs that share the feature value and the classifier’s original decision. It then asks how often changing that value changes the decision. The restriction on the starting label is part of the definition. It makes the question concern losing a decision the classifier was already making in those nearby contexts. The reference neighborhood matters because allowable changes to the surrounding words determine what counts as a comparable context.
S(xᵢ, y) = Pc ∼ Dₛ(x) = y | cᵢ = a′, f(c) = y′)
S(xᵢ, y) is the sufficiency of the original value xᵢ for the label y, and x is again the original input. P is probability under c ∼ Dₛ(x), meaning that c is drawn from the sufficiency neighborhood distribution. i identifies the feature, cᵢ is its value in that neighboring input, and a′ is a value different from the original a. f is the classifier, y′ is the alternate starting label, and cᵢ←a is the neighboring input after restoring the original value. The equal signs specify the label or feature value, | introduces the starting conditions, and the comma between those conditions means both must hold.
Here the neighboring input starts with a different feature value and the alternate prediction. The question is how frequently inserting the original value brings the original prediction back. In binary classification a flip away from a label has a unique destination. The two probabilities can still differ substantially, because they look at different starting situations. A word may help support the positive class where an attack is already expressed, yet have little power to produce that decision when it is added to a benign context. Conversely, a classifier may respond to a word in a benign sentence and also have other grounds for a positive decision when the word is taken out of an explicitly abusive sentence.
Generate alternatives that can change the decision
For both definitions, the paper leaves the neighborhood dependent on the kind of data and the implementation. The text procedure builds it through interventions on the original utterance. The authors sample groups of token positions. Consecutive selected positions become a single blank, allowing a whole phrase to be rewritten together. The generator sees the surrounding text and produces a replacement. Its infills range from 1 to 7 tokens, so the number of words it adds to a span can differ from the number removed.
The generator follows the infilling procedure of Donahue and colleagues, which adapts GPT-2 to complete missing stretches within text. The authors narrow its training objective to words and short sequences. That enables replacements that can fit the surrounding grammar without restricting every edit to a single substitute word. It also gives the method a space of alternatives broader than a list of target nouns or syntactic transformations. Enabling Language Models to Fill in the Blanks
The training data for the generator supply the label conditioning. The authors use only examples labeled normal or non-abusive in the source datasets. The context around a blank might contain a feature associated with hate, such as an identity term. If the generator were trained on the full mix of labels, that feature could encourage it to fill the blank with an explicit attack. A classifier could then correctly label the newly generated attack as hateful, inflating the apparent sufficiency of the identity term that stayed in place. Training on benign examples is intended to weaken this route from the preserved context through the generated words to the prediction. It gives the remaining original words a more informative test.
The combined training set draws on neutral examples from Twitter, Reddit, Wikipedia comments, and comments on news sites. Wikipedia Toxicity contributes 36,121 examples after filtering material the authors identify as specific to Wikipedia discussions. Founta2018 contributes 53,236 normal Twitter posts. Civil Comments contributes a random sample of 30,000 normal comments, limiting the influence of that larger dataset. Vidgen2021 contributes 11,073 non-abusive Reddit posts. The total used for infilling training is 130,430. The paper identifies the Reddit source as the Contextual Abuse Dataset.
The same preprocessing convention is used for URLs, user mentions, and emojis, which are replaced with special tokens. The authors then apply fine-tuning to GPT-2 with 1.5B parameters for 4 epochs. An epoch is a pass over the training data. They use the default settings associated with the infilling procedure and report roughly 2.5 hours of training on a Tesla V100-SXM2 GPU. The classifier being explained remains separate. Davidson2017, for instance, supplies classifier training data and contributes no training text to the generator. This separates the source of a classifier’s learned decisions from the source of the alternatives used to investigate them.
Reuse edits and weight the evidence
A direct implementation of the definitions would first sample a neighborhood for each word, check that each starting point met the stated conditions, then intervene on that word and obtain another prediction. The authors describe that procedure as too expensive to repeat for every word in a sentence. They instead edit subsets of the sentence and let a single perturbed input inform several token scores. An edit can contribute evidence about the necessity of the words selected for replacement and about the sufficiency of words that stayed in place.
For necessity, the practical question is whether the prediction changes on versions that include the focus token among the edited positions. Other positions may change in the same trial. When a trial changes several positions, the method shares the evidence among them. In the formal setup, the necessity neighborhood can itself contain edits to other features before the feature of interest is changed. In the practical estimator, the authors omit the explicit check that each such intermediate input still receives the original label. They use the original decision and the final edited prediction in the weighted comparison.
wₙ ∝ 1/k
wₙ is the weight for a necessity sample, ∝ means proportional to, and k counts the original token positions selected for editing in that sample. The 1 in the numerator and / specify a reciprocal. Changes involving fewer selected positions thus contribute more evidence per selected word. The explanation can give substantial weight to a reversal after a small edit, and a reversal after a broader rewrite gets shared among more words.
For sufficiency, the practical procedure considers edits in which the focus word survives. It uses the weighted predictions of the edited texts against the baseline, so higher scores correspond to the classifier more frequently preserving the original positive decision in these edits. The formal definition starts with an alternate label and changes the feature back to its original value. The implementation omits an explicit prediction check on that alternate starting input. Generating replacements from benign training data steers the samples toward the alternate class, although the classifier can respond positively to those texts.
wₛ ∝ 1/(n − k)
wₛ is the sufficiency sample weight and ∝ denotes proportionality. n is the length of the original sequence in tokens, and k counts its edited token positions. The difference n − k counts the original positions retained, and 1/ takes the reciprocal of that count. A trial with just the focus token remaining from the original sentence gives that token all of the trial’s attribution. When several original tokens remain, they share the evidence. The count concerns the original positions, so an infill can be longer or shorter without changing which positions were selected in the original input.
The authors describe both neighborhoods as interventional because they are made by editing the specific sentence under study. They characterize the sufficiency neighborhood as less concentrated close to the original than the necessity neighborhood. The weighting rules express different grounds for giving a trial more influence. A label flip after a limited change is informative about the changed words. A label that survives after much of the input has been replaced is informative about the original words that remain. Each score still depends on the sampled masks and on the language supplied to fill them.
For the HateCheck experiment, the authors choose the number of trials so that the expected coverage is roughly 100 edited instances per token for necessity and 100 per token for sufficiency. They generate text once for 120 HateCheck cases. That produces 66,120 perturbed inputs, which all classifiers share. The paper reports approximately 6 hours for generation on a 2.3 GHz Quad-Core Intel Core i7 CPU. Sharing the texts prevents a classifier from being evaluated on easier or harder generated alternatives merely because the generator happened to produce them in a separate run. The authors make their implementation publicly available.
Experiments and results
The prediction tasks and the diagnostic tests
The authors train six BERT classifiers using three datasets and two labeling schemes for each dataset. The paired design asks how a narrower definition of the positive class affects reliance on identity. In Founta2018, the hate version treats hate annotations as positive, while the abuse version adds abusive annotations to the positive class. Davidson2017 uses the same distinction, with offensive examples added for the broader task. In Vidgen2021, the hate version uses identity-directed abuse as the positive class. The abuse version uses the dataset’s broader abusive category.
The pairs share their dataset splits. Founta2018 uses 62,445 training, 7,806 development, and 7,806 test examples. Davidson2017 uses 19,826 training, 2,478 development, and 2,479 test examples. The corresponding values for Vidgen2021 are 13,585, 4,527, and 5,308, from its standard split. The authors use a stratified 80/10/10 split for Founta2018 and Davidson2017, preserving class proportions when allocating examples. Within each dataset, the same examples enter training, development, or testing for both label definitions.
Each classifier has 110M trainable parameters. The authors use the HateCheck training configuration, running 3 epochs with 16 examples per batch, a 5e-5 learning rate, and zero weight decay.01. The batch is the group of examples used in a training update, the learning rate controls the update size, and weight decay regularizes the parameters. The classifiers use weighted cross-entropy, a loss that gives different weights to classes to account for imbalance. URL, mention, and emoji preprocessing follows the same convention as for the generator.
The paper reports micro and macro F1 on the held-out test set of each training dataset. F1 combines precision and recall. Micro F1 pools the decisions, while macro F1 gives the class-level scores equal influence. On Founta2018, the hate and abuse versions both obtain micro F1 of 0.94. Their macro F1 values are 0.67 and 0.93, respectively. On Davidson2017, the hate version obtains 0.94 micro F1 and 0.70 macro F1, and the abuse version obtains 0.96 and 0.93. On Vidgen2021, the hate version obtains 0.91 micro F1 and 0.71 macro F1, and the abuse version obtains 0.85 and 0.72. These are scores against each classifier’s own label definition. The HateCheck comparisons supply a separate view by holding particular language behaviors up to a common benchmark.
HateCheck organizes its cases by functionality, a behavior that a classifier is expected to exhibit on sentences constructed for that purpose. The authors use explicit hate cases from F1, F2, and F3 as the starting points for the explanations. These test strong negative feelings towards the target, descriptions using very negative attributes, and dehumanization. The target slots are filled with the terms for women and Muslims. The authors compute necessity and sufficiency only where the classifier correctly gives the explicit case a positive label. The reported means and standard deviations are therefore summaries of attribution on successfully detected attacks, separately for each classifier and identity term.
The behavioral comparisons use other HateCheck categories. F18 and F19 test benign identity mentions in neutral or supportive statements. Positive predictions on these statements can reveal sensitivity to the identity term when hostile language is absent. F22, F23, and F24 use hostile language aimed at objects, individuals outside a protected-group role, or non-protected groups. Positive predictions on these cases indicate that the classifier is willing to assign its positive label outside the protected-target boundary. The reported metric is the proportion of cases assigned the positive label within the corresponding tests. For an abuse classifier, that label means abusive. The benchmark’s negative reference label in this comparison means non-hateful.
The study also computes average identity-term attributions with SHAP and LIME using their default settings for text. These baselines use the same criterion for including a starting case: the classifier must correctly detect the explicit attack. The authors compare the patterns in the baseline scores with the two proposed scores and with the independent behavioral tests. The scales of the attribution methods differ, so the comparison concerns which behavioral distinctions can be recovered from each pattern of results.
Does a hate label make the target more necessary?
The authors expect a classifier trained on broader abuse labels to depend less on protected identity in explicit attacks. Across the dataset pairs and identity terms, that expectation holds with one exception. On explicit HateCheck attacks against women, the Founta2018 hate and abuse classifiers have mean necessity of 0.82 ±0.18 and 0.54 ±0.17, respectively. For Muslims, the corresponding means and standard deviations are 0.89 ±0.16 and 0.65 ±0.21. The decline in both comparisons fits the broader scope of the abuse task.
Vidgen2021 gives the same direction. For women, mean necessity is 0.96 ±0.02 for hate and 0.82 ±0.14 for abuse. For Muslims, the scores are 0.97 ±0.03 and 0.82 ±0.15. In both pairs the classifiers see the same original sentences in their training splits. The positive labels differ, and the attribution results are consistent with the hate version making more use of the identity target.
The Davidson2017 comparison depends on which target is under examination. For Muslims, mean necessity is 0.91 ±0.12 in the hate version and 0.83 ±0.13 in the abuse version. For women, the ordering reverses: 0.58 ±0.09 in the hate version and 0.82 ±0.14 in the abuse version. The experiment supports a general tendency across the tested pairs, with the response to the label scheme varying by dataset and target. The reported variation describes the spread of scores over explicit cases.
Sufficiency and false positives on benign mentions
In most classifiers, the reference to Muslims receives higher mean sufficiency than the reference to women in the explicit attack cases. The contrast is visible in Founta2018-hate, where sufficiency is 0.81 ±0.08 for Muslims and 0.29 ±0.1 for women. Founta2018-abuse gives 0.82 ±0.06 and 0.34 ±0.1 for those targets. On neutral and supportive HateCheck mentions, both Founta2018 classifiers predict positive at a rate of 0.78 for Muslims and 0.02 for women. Because the attributions come from explicit attacks and the error rates come from benign mentions, the two observations connect different sets of sentences.
Davidson2017-abuse is the exception to the general contrast in sufficiency. Its mean is 0.41 ±0.14 for Muslims and 0.43 ±0.13 for women. Its positive rates on benign mentions are 0.22 for Muslims and 0.31 for women. Davidson2017-hate gives a different profile on the same benchmark: its sufficiency is 0.74 ±0.09 for Muslims and 0.21 ±0.06 for women, and the positive rates are 0.78 and 0.02. Looking within the dataset pair shows how a shift in attribution for a target can go with a shift in the classifier’s treatment of benign sentences about that target.
For women, the Vidgen2021 hate and abuse classifiers have the highest mean sufficiency among the tested classifiers, at 0.71 ±0.17 and 0.64 ±0.14. They also yield the highest positive rates on the neutral and supportive cases for women, at 0.36 and 0.42. The ordering within the pair is reversed between the two metrics. For Muslims, the Vidgen2021 classifiers each have mean sufficiency of 0.88, with standard deviations of 0.13 for hate and 0.07 for abuse. Their positive prediction rates are 0.82 and 0.96. Thus the score helps identify classifiers prone to false positives on the corresponding benign cases, while classifiers with similar scores can differ on the benchmark.
Positive predictions for benign mentions of Muslims in HateCheck F18 and F19
Davidson2017-abuse gives the fewest positive predictions for benign mentions of Muslims.
The numbers
| System or setting | proportion predicted positive |
|---|---|
| Founta2018-hate | 0.78 |
| Founta2018-abuse | 0.78 |
| Davidson2017-hate | 0.78 |
| Davidson2017-abuse (this paper) | 0.22 |
| Vidgen2021-hate | 0.82 |
| Vidgen2021-abuse | 0.96 |
The word-level visualization offers a related example with the Founta2018 hate classifier. In parallel HateCheck cases, the term for Muslims is more sufficient than the term for women. The word disgust in the sentence aimed at women is more necessary than it is in the version aimed at Muslims. That comparison shows why the method assigns scores to words in context. Even the role of a word outside the target expression can change when the identity in the sentence changes.
Necessity and abuse against other targets
The third hypothesis links low necessity for identity terms to positive decisions on abusive utterances directed at non-protected targets. The extremes support that interpretation. Founta2018-abuse has the lowest mean necessity for both women and Muslims in the explicit attack cases. It also has the highest positive prediction rates on HateCheck abuse directed at non-protected groups, individuals, and objects, with respective proportions of 0.45, 0.72, and 0.37. Its behavior on objects is particularly revealing: the classifier often responds positively even where the target of the hostility is inanimate.
Vidgen2021-hate has the highest mean necessity for both identity terms. It assigns the positive label to a proportion of 0.02 of the cases about abuse against non-protected groups and 0.00 of the cases about individuals and objects. This is the classifier whose attribution scores most strongly suggest that changing a protected identity target can remove important evidence for the positive label. Its decisions on the other target categories are consistent with that interpretation.
Positive predictions for abuse against non-protected groups in HateCheck
Vidgen2021-hate assigns the positive label least often on this test.
The numbers
| System or setting | proportion predicted positive |
|---|---|
| Founta2018-hate | 0.19 |
| Founta2018-abuse | 0.45 |
| Davidson2017-hate | 0.37 |
| Davidson2017-abuse | 0.26 |
| Vidgen2021-hate (this paper) | 0.02 |
| Vidgen2021-abuse | 0.40 |
The intermediate cases show why it helps to keep the target categories separate. Vidgen2021-abuse assigns positive labels at rates of 0.40 for non-protected groups and 0.61 for individuals, with 0.00 for objects. Davidson2017-abuse gives 0.26, 0.28, and 0.14, respectively. A sensitivity to attacks against people can coexist with a reluctance to flag attacks against things. The necessity scores summarize response to the generator’s range of alternatives, and the benchmark identifies where that response does and does not extend to specific target categories.
What the single-score baselines expose
For explicit attacks on Muslims, Founta2018-abuse and Davidson2017-abuse have similar average SHAP values for the identity term, at 0.39 ±0.25 and 0.37 ±0.2. Their proposed scores distinguish their behavior. For the same cases, Founta2018-abuse has mean sufficiency of 0.82 and necessity of 0.65, while Davidson2017-abuse has mean sufficiency of 0.41 and necessity of 0.83. The two classifiers also differ on benign mentions of Muslims, where their positive rates are 0.78 and 0.22. Here the similar SHAP averages offer little basis for anticipating that difference.
The LIME comparison gives another example. Davidson2017-hate receives an average LIME attribution of -0.002 ±0.057 for the identity term in explicit attacks on Muslims. The same classifier predicts positive for a proportion of 0.78 of the neutral and supportive mentions of Muslims. In this setting, the small negative attribution in the explicit cases does little to flag the sensitivity seen on benign examples. The sufficiency score speaks more directly to what happens when the term persists and its context changes.
For women, Founta2018-abuse and Vidgen2021-hate likewise have close mean LIME scores on explicit attacks, at 0.011 ±0.02 and 0.012 ±0.077. Their behavioral profiles differ. The Founta2018 classifier predicts positive on relatively few benign mentions of women and more often on attacks against non-protected targets. The Vidgen2021 classifier more often predicts positive on benign mentions of women and much less frequently on abuse directed elsewhere. Their necessity and sufficiency scores separate these tendencies. The evidence consists of comparisons like these across the classifiers and the selected functionalities. Each metric retains its own meaning and scale.
What the ablations show
Keeping the edits and removing the infills
The appendix supplies a controlled comparison of two perturbation procedures. The authors keep the number and locations of the selected positions from the main experiment and replace the chosen text with masks. The resulting examples go straight to the classifier. This holds the sampled editing locations fixed and changes what the classifier receives at those locations. It tests whether the attribution patterns depend on filling the blanks with generated text.
Necessity changes noticeably in several cases. For Founta2018-abuse, the mean necessity for women in explicit HateCheck attacks is 0.54 with infilling and 0.19 with masking. For Muslims, it is 0.65 with infilling and 0.36 with masking. The Vidgen2021 hate classifier has a mean necessity of 0.96 for women with infilling and 0.87 with masking. Scores depend on what counts as changing a token. A mask marks an absence, while a generated phrase gives the classifier a new value to interpret in context.
Sufficiency is much closer across procedures in the published comparison. For Muslims, the reported means match between masking and infilling for all six classifiers. For women, Vidgen2021-hate and Vidgen2021-abuse both have identical means under the two procedures, respectively 0.71 and 0.64. Several other values shift slightly. For instance, Founta2018-hate has mean sufficiency of 0.29 with infilling and 0.30 with masking. This comparison shows that many of the sufficiency patterns are already visible when the surrounding text is masked.
The broader conclusions survive the substitution in the study. Founta2018-abuse still has the lowest necessity among the evaluated classifiers for both target groups, and Vidgen2021-hate still has the highest. The strong difference in sufficiency between the terms for women and Muslims remains in most classifiers. The Davidson2017 exception for necessity on women likewise remains visible. The authors describe masked evaluation as faster. Its inputs are tied to a classifier that can accept the mask, and a reader gets less information about which natural-language alternatives preserve or change the label. The paper raises speed-sensitive screening as a possible use for masking and leaves that use for further investigation.
The control supports different conclusions about the trend and the explanation. Infill generation is unnecessary to reproduce the broad trends in this particular comparison. It yields readable evidence about what the trends amount to in actual sentences, and it changes some attribution magnitudes. The comparison also changes multiple properties of the submitted text at once. A generated phrase carries meaning and can vary in length, while a mask has a special role tied to pretraining. Their differences in necessity scores cannot be attributed to any single one of those properties.
What changes when the label definition changes
Training hate and abuse classifiers on the same partition of each dataset provides a separate controlled comparison. The classifiers share architecture and settings, and their training labels encode different definitions of a positive example. Keeping the perturbations fixed across classifiers means the inputs used to estimate necessity and sufficiency are available for both label schemes. The usual drop in necessity from the hate version to the abuse version is consistent with the broader label depending less on identity.
The Davidson2017 result for women shows the value of repeating that comparison by target. The broader label scheme can yield higher measured necessity for one identity even when it yields lower measured necessity for another. The averaging procedure also matters. Each classifier contributes original cases that it correctly labels positive, so two compared means can be based on different starting cases within the same suite. The results describe what the classifiers do in the experiment as a whole. They give only a partial basis for isolating the effect of relabeling on each individual sentence.
Another comparison concerns the data used by the infilling system. The generator’s training set includes neutral Founta2018 and Vidgen2021 examples, while Davidson2017 is held out of generator training altogether. The Davidson2017 classifiers can still be probed using the shared edited cases. For example, the tested Davidson2017-abuse classifier has both the lowest mean sufficiency for Muslims and the lowest positive rate on benign mentions of Muslims. This shows the procedure can give a coherent explanation in a case where the classifier’s training dataset is absent from the generator’s training data. The study uses English sources from related online domains throughout.
Inspecting the generated alternatives
The qualitative inspection addresses what is inside the perturbation collection. The authors report that the generator typically replaces the chosen material with non-offensive language, and they observe relatively little repetition. They also report uneven quality and declining fluency as more spans are filled. This matters because a perturbation can satisfy the mechanical rule for preserving or replacing the focus word while making the sentence hard to interpret. The authors chose diversity over fluency in this implementation and present improved generation as future work.
Some edits combine changes that a functional test would usually examine separately. A fill can redirect the speaker’s dislike toward an online forum while also changing the sentence structure. Another can produce a denial of a disparaging claim while rephrasing the sentence. These cases show that fluent infilling can change the speech act or relevant meaning as well as the words around the target. When the classifier changes its label, the generated sentence lets a human see that several aspects may have changed together.
The replacement of identity expressions also supplies cases outside HateCheck’s selected target categories. The generator can turn the target into an activity, an event, or a clause about what the speaker feels obliged to do. Such a rewrite can preserve the grammatical framework or sentiment of the original attack while creating a different kind of utterance. The benchmark’s fixed cases give clear comparisons among specified targets. The generator gives a wider collection of nearby expressions for qualitative inspection and attribution. The two sources of evidence serve complementary roles in the case study.
Limitations
Limits identified by the authors
The authors limit their empirical conclusions to binary hate speech detection in English, with training data drawn from online comments and posts. They propose studying other languages and applications. The procedure can be expressed in terms of any classifier that returns a binary decision, but implementing a new application requires a way to generate plausible alternatives for that application’s labels and input. The generator trained for this case study learned from English-language benign messages in the domains represented by the source datasets.
The authors also identify limitations of the data themselves. Public online text can reflect uneven participation across demographic groups and uneven coverage of topics. The data were gathered without explicit consent from the users who wrote the posts and comments. A system trained to produce text can reproduce material from its training data, which creates privacy concerns. The generator can also inherit biases from those examples. These considerations apply to the text used to construct explanations as well as to the classifiers being explained.
The paper describes the generation procedure as computationally expensive. It requires training an infilling system and producing many variants per input, followed by predictions on those variants. The appendix’s resource figures describe a batch study in which the edited texts could be reused across classifiers. For a fresh sentence, the generation portion still has to be performed. Masking speeds up that portion in the appendix comparison, while giving up the readable alternatives that make the proposed explanation inspectable. The authors leave further study of that tradeoff open.
Generation quality is another stated limitation. The authors find varied fluency and worse examples as the number of infills grows. They favor diversity in the implementation, and report their assessment through qualitative inspection. They also present improvements to debugging and communication with end users as directions for future work. The study shows people what evidence could accompany the attribution. It does not contain a user evaluation of whether that evidence helps readers understand or contest decisions. The paper additionally notes that greater visibility into a moderation classifier can expose weaknesses to people who would misuse that information.
Limits of the causal interpretation
The words necessity and sufficiency may suggest properties that hold universally. The definitions in the paper describe probabilities over an input neighborhood, and the reported values are estimates produced through a particular editing and weighting procedure. The strongest interpretation is local. A high necessity score describes a tendency for the prediction to change under the replacements the method samples, with higher weight for smaller edits. A high sufficiency score describes a tendency for the original prediction to survive changes to surrounding text under the tested distribution. A different generator or neighborhood could change the scores by offering other plausible contexts.
The formal conditions and the practical calculation also deserve separate attention. Formally, necessity starts with a neighboring input that contains the feature and already receives the original label. Sufficiency starts with the alternate feature value and the alternate label. The implementation omits explicit checks on those intermediate starting labels. For sufficiency, the benign training data encourage the generator to produce alternate-class material. The original words that survive an edit can still contain substantial evidence of hate, and a generated span can introduce new material relevant to the decision. The reported estimator consequently approximates the conditional probabilities by exploiting the way the perturbations are constructed.
Joint edits add another interpretive limit. Several words can determine an outcome together, while the necessity weighting shares the contribution equally among edited positions. On the sufficiency side, multiple preserved words can support the prediction, and the weighting distributes evidence among them. The rules reduce the number of separate probes required and give appropriate prominence to restricted changes. An attribution for a word can still reflect a phrase-level interaction. The input variants are especially valuable here because they show whether a strong contribution arose from several narrowly targeted edits or from sentences with more extensive changes.
Training on benign text encourages benign replacements, and the qualitative inspection supports that tendency. The procedure does not enforce the label of each full generated sentence. The surrounding words are drawn from the original attack, and a fluent completion can preserve, redirect, or change the status of the remark. Moreover, fluency establishes only that a sentence is readable. The study does not measure how often edited examples resemble the actual posts the classifiers encounter in each of their deployment domains. A high score can reflect regularities in the generator, the sampled contexts, and the classifier’s decisions together.
Limits of the empirical comparisons
The main attribution results are averages for two terms in explicit, correctly detected attacks. They can identify divergences in behavior for those terms under the selected tests. They give no estimate for the full range of protected identities, ways of referring to a group, or forms of context-dependent abuse. The starting cases also exclude false negatives. As a result, the evidence addresses why classifiers gave certain positive decisions and how those explanations relate to other positive decisions made in error under HateCheck’s labels.
The study uses deliberately constructed templates to make functional differences visible. The neutral and supportive cases isolate benign mentions, and the abuse cases hold attention on whether a target belongs to a protected identity. These categories make useful comparisons, while the resulting positive rates describe those particular tests. The paper reports a single run. The standard deviations on the attribution scores describe variation across cases in the experiment. They leave open how much the aggregate results would change with another training run or another draw of perturbations.
The match between attribution and benchmark behavior is also stronger as a diagnosis than as a numerical forecast. For instance, the Vidgen2021 classifiers have the same reported mean sufficiency for Muslims but different positive rates for benign mentions. For women, the pair has the highest values on both measures, with its internal order reversed. These are compatible with using sufficiency to flag a broad pattern of sensitivity. The experiments do not establish a conversion from a sufficiency value to a false-positive rate, and the tests on other targets do not set a universal threshold for what counts as low necessity.
Finally, the comparison with SHAP and LIME examines their default text settings and average token scores for the same class of explicit examples. This makes it possible to show concrete cases where a similar baseline score accompanies different behavior. Other configurations, the distribution of individual attributions, and evaluations in other tasks fall outside the comparison. The study’s contribution is evidence that the two kinds of dependence help explain these specific diagnostic patterns, with readable perturbations giving the reader a way to examine how the evidence was obtained.
What came after
Argument-Based Consistency in Toxicity Explanations of LLMs (2026) cites Balkır and colleagues and takes up a related question about explanations of toxicity judgments. Its title identifies argument-based consistency as its focus. Balkır and colleagues ask how a classifier’s decision responds to changes in the text, grounding its attributions in those responses. The later work’s title places the emphasis on consistency in the explanations themselves.
The citation establishes a connection between these questions. The details of that connection remain unspecified, including whether the later work uses the necessity and sufficiency scores, the benign infilling procedure, or the HateCheck comparisons.
Cite
Cite as Esma Balkir, Isar Nejadgholi, Kathleen Fraser and Svetlana Kiritchenko. 2022. Necessity and Sufficiency for Explaining Text Classifiers: A Case Study in Hate Speech Detection. Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies.
@inproceedings{balkir2022necessity,
title = {{Necessity and Sufficiency for Explaining Text Classifiers: A Case Study in Hate Speech Detection}},
author = {Esma Balkir, Isar Nejadgholi, Kathleen Fraser and Svetlana Kiritchenko},
booktitle = {Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies},
year = {2022},
doi = {10.18653/v1/2022.naacl-main.192},
url = {https://doi.org/10.18653/v1/2022.naacl-main.192}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/balkir-2022-necessity-sufficiency-explaining-text-classifiers/