SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2205.03302 · NAACL · 2022

Necessity and Sufficiency for Explaining Text Classifiers: A Case Study in Hate Speech Detection

Isar Nejadgholi, Kathleen Fraser, Svetlana Kiritchenko, Esma Balkır

arXiv · PDF · Open in the Atlas

Code that ran

8 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 7 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2205.03302.json · badge: /api/ran/2205.03302.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
esmab/necessity-sufficiency marked official in Papers with Code
Papers with Code archive
8 ran · 3 no recorded run
FunctionStatusWhere it lives
calc_necc Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
esmab/necessity-sufficiency/perturbation_functions.py
pointer only (licence: NONE) · get_code("620616107283fcb6")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, esmab/necessity-sufficiency when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

calc_suff Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
esmab/necessity-sufficiency/perturbation_functions.py
pointer only (licence: NONE) · get_code("13080d832ed3342a")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, esmab/necessity-sufficiency when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

gen_masks Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
esmab/necessity-sufficiency/perturbation_functions.py
pointer only (licence: NONE) · get_code("08559e1386a7e411")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, esmab/necessity-sufficiency when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

gen_probs Ran
ran, honoured the contract we drafted
esmab/necessity-sufficiency/perturbation_functions.py
pointer only (licence: NONE) · get_code("7e2a727efbf70b6e")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, esmab/necessity-sufficiency when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

generate_masked_text_mask_tokn Ran
ran; our contract draft was wrong, not the code
esmab/necessity-sufficiency/perturbation_functions.py
pointer only (licence: NONE) · get_code("260f61d1b64712b1")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, esmab/necessity-sufficiency when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

get_preds Ran
ran; our contract draft was wrong, not the code
esmab/necessity-sufficiency/perturbation_functions.py
pointer only (licence: NONE) · get_code("2f6bbfafbef94618")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, esmab/necessity-sufficiency when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

infill_with_ilm Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
esmab/necessity-sufficiency/perturbation_functions.py
pointer only (licence: NONE) · get_code("abfbda1a5cb1e8fb")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, esmab/necessity-sufficiency when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

sample_from_logits Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
esmab/necessity-sufficiency/perturbation_functions.py
pointer only (licence: NONE) · get_code("5c25f8a10604e26c")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, esmab/necessity-sufficiency when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

calculate_necc_and_suff Not yet run
unverified (harvested, no recorded run)
esmab/necessity-sufficiency/perturbation_functions.py
pointer only (licence: NONE) · get_code("9ede2b7ae5f368f2")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, esmab/necessity-sufficiency when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

generate_masked_text Not yet run
unverified (harvested, no recorded run)
esmab/necessity-sufficiency/perturbation_functions.py
pointer only (licence: NONE) · get_code("3ea7391ca2929d12")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, esmab/necessity-sufficiency when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

infill_masked Not yet run
unverified (harvested, no recorded run)
esmab/necessity-sufficiency/perturbation_functions.py
pointer only (licence: NONE) · get_code("48556369a23f249b")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, esmab/necessity-sufficiency when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 0 later) and 9 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
infill_with_ilm
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2005.05339 (2020-05)
Enabling Language Models to Fill in the Blanks
sample_from_logits
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2005.05339 (2020-05)
Enabling Language Models to Fill in the Blanks

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

We present a novel feature attribution method for explaining text classifiers, and analyze it in the context of hate speech detection. Although feature attribution models usually provide a single importance score for each token, we instead provide two complementary and theoreticallygrounded scores -necessity and sufficiencyresulting in more informative explanations. We propose a transparent method that calculates these values by generating explicit perturbations of the input text, allowing the importance scores themselves to be explainable. We employ our method to explain the predictions of different hate speech detection models on the same set of curated examples from a test suite, and show that different values of necessity and sufficiency for identity terms correspond to different kinds of false positive errors, exposing sources of classifier bias against marginalized groups.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2205.03302")
get_code_for_paper("2205.03302")
have("2205.03302")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2205.03302.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2205.03302.svg)](https://syntology.ai/paper/2205.03302)

Connect an agent — have() is free.