A fundamental challenge in explainable artificial intelligence involves confirming whether post-hoc attribution methods faithfully reflect the computational mechanics of text classifiers. Popular explanation frameworks such as SHAP and LIME assign numerical weights to individual words to indicate their respective contributions toward a model prediction. However, practitioners routinely treat these outputs as equivalent representations of the same underlying quantity, despite the algorithms relying on fundamentally distinct mathematical formulations. SHAP calculates approximations of game-theoretic Shapley values across feature subsets, whereas LIME optimizes a local linear surrogate model around the input, and simple occlusion measures the marginal shift caused by removing one word at a time. Because feature interactions within text can cause their attribution rankings to diverge sharply without either method being mathematically flawed, an empirical evaluation framework is required. On benchmark tasks distributed with the software, per-document rank correlations between SHAP and LIME range from a modest 0.27 on movie reviews to 0.75 on news topics. Despite these differences, any assertion that a specific subset of words drives a prediction remains an empirically testable claim: removing high-ranking words must alter model confidence more significantly than deleting low-ranking words.
Measuring this deletion response in natural language processing has historically encountered severe technical obstacles that do not arise in continuous input domains. Standard interpretability metrics such as infidelity and local Lipschitz robustness presuppose continuous input spaces where arithmetic perturbations can be subtracted directly from mathematical vectors, a property that discrete linguistic tokens do not possess. Alternative plausibility benchmarks like ERASER instead evaluate agreement against human-annotated rationales, which only exist across a small collection of specialized datasets and measure alignment with human subjective judgment rather than fidelity to the underlying model. Retraining approaches such as remove-and-retrain address the distribution shifts caused by text deletion, but they impose prohibitive computational overhead by requiring a full retraining cycle for every attribution algorithm, threshold, and experimental seed. Furthermore, existing evaluation frameworks remain structurally limited; for example, the ferret framework is closely coupled to Hugging Face transformers and tokenizers, while the interpretability metrics in Captum and Quantus are engineered primarily for continuous tensor inputs such as images, time series, or tabular data rather than raw text sequences.
To overcome these limitations, researchers Michał Bukowski and Jarosław Kurek introduced textfaith, an open-source Python library designed to evaluate the deletion faithfulness of text classification explanations. Formally described in SoftwareX, the package operates purely in Python 3.13 on standard CPU hardware without requiring GPU acceleration, external model access permissions, or human-labeled rationale datasets. The tool isolates deletion faithfulness as the core component of explanation quality that remains entirely automatable for text: systematically removing words and observing the corresponding shift in classifier output. Architecturally, textfaith implements a black-box model interface that accepts any standard callable mapping a list of raw text strings to an array of class probabilities. This decoupled design enables researchers and practitioners to audit arbitrary natural language processing architectures, ranging from traditional scikit-learn statistical pipelines and complex transformer classifiers to closed commercial prediction endpoints hosted behind remote network interfaces, without modifying the underlying classification models or exposing internal parameters.
The library introduces three structural design principles that distinguish it from previously published ad hoc evaluation scripts. First, textfaith guarantees that every attribution source is evaluated using the exact same text masking mechanism that was deployed during the initial computation of its attribution weights. Enforcing this masking consistency ensures that words are excised under identical semantics, satisfying the theoretical assumptions under which Shapley values are formally defined. Second, the framework strictly tracks and reports evaluation budgets rather than assuming fixed computational parity across algorithms. By recording wall-clock processing times and the exact count of model prediction calls alongside every computed attribution array, the software prevents faithfulness scores from detaching from their real computational footprint. Third, textfaith embeds a rigorous statistical protocol directly into its processing pipeline. Rather than calculating unpaired aggregate means across dissimilar documents, the software pairs metric scores per document, conducts Wilcoxon signed-rank hypothesis tests across experimental conditions, and applies family-wise Holm corrections to control false positive rates across multiple simultaneous statistical comparisons.
Structurally, textfaith organizes its codebase into five modular layers to keep the core measurement pipeline independent of any specific classification backend. The foundational faithfulness module constructs shared whitespace maskers, computes word attributions across multiple explanation algorithms, aggregates word-level weights into multi-word chunks, and records sufficiency and comprehensiveness metrics. The experiment module wraps target classifiers within tracking counters to audit prediction budgets, benchmarks execution times, and caches intermediate results using parameter-encoded file hashes that prevent stale configurations from contaminating new runs. Two supporting modules, training and checkpoint, handle the initial training, fine-tuning, and re-instantiation of reference text classifiers based on a frozen e5-small-v2 sentence representation encoder paired with task-specific multilayer perceptron heads. Finally, the rendering module generates word heat maps directly from calculated attribution arrays, applying identical token alignment rules so visual explanatory displays perfectly match the quantitative spans evaluated during deletion tests.
Across all system components, the library enforces two strict operational invariants to ensure cross-model comparability and linguistic integrity. Every attribution algorithm and deletion routine processes text through a shared shap.maskers.Text masking object configured to split inputs on whitespace characters. By operating on whitespace boundaries rather than subword token divisions, common grammatical contractions survive as unified attributable units, and every method is assessed under identical excision semantics. Additionally, all calculated faithfulness metrics are computed as relative scores expressed as a direct percentage of the classifier’s initial confidence in the predicted class. Normalizing shifts against baseline confidence guarantees that faithfulness comparisons remain statistically valid across disparate classifier heads that may exhibit varying degrees of probabilistic calibration. Supported scoring metrics include sufficiency, which measures output retention when the lowest-ranked spans are pruned, and comprehensiveness, which measures the drop in predicted confidence when the highest-ranked spans are removed.
To prevent arbitrary token scattering from generating nonsensical inputs, textfaith organizes deletions into consecutive chunks of one, four, or eight words. Aggregating contiguous spans maintains textual cohesion closer to natural phrasing, although resulting passages inevitably fall outside the training distribution. The package provides three mathematical rules for aggregating signed word attributions into chunk scores. The absolute_sum rule takes the absolute value of the sum of signed attributions within a chunk; for additive SHAP explanations, this sum directly approximates the expected deletion effect when words do not interact. The sum_absolute rule calculates the sum of the absolute values, penalizing chunks containing opposing positive and negative weights, while the max_absolute rule ranks a chunk purely by its single largest attribution weight. While these rules yield identical results for single-word chunks, they diverge over multi-word spans. For surrogate methods like LIME that lack additive theoretical guarantees, the optimal chunk scoring aggregation remains an empirical question that the evaluation framework explicitly answers.
The accompanying reference benchmark demonstrates the software across three diverse text classification datasets: IMDb movie review sentiment analysis, Yelp review sentiment classification, and AG News topic categorization. Each task was structured using 4,000 stratified documents partitioned into a 70 percent training split, a 15 percent validation split, and a 15 percent test split, yielding classifier test accuracies ranging between 0.89 and 0.96. The empirical evaluation audited 300 test documents per dataset across computational budgets of 50, 200, and 500 model queries per document. Combining three chunk sizes, three score aggregation rules, four cut thresholds, and two deletion directions produced a benchmark suite of 518,400 evaluated deletion operations. Four attribution sources were compared: the SHAP partition explainer, LIME, leave-one-word-out occlusion, and a method-independent Gaussian random attribution baseline that establishes the expected output shift caused by uninformed text deletion.
The benchmark results confirmed key behavioral characteristics of the evaluated explanation methods. As an initial sanity check, no attribution technique lost a single condition to the random baseline; SHAP and LIME each secured 54 out of 54 Holm-corrected wins, while occlusion won 52 out of 54 conditions. When comparing SHAP directly against LIME at an evaluation budget of 500 queries, SHAP won 25 conditions, lost 6 conditions, and demonstrated an average advantage of 1.89 percentage points of relative model confidence. Across conditions where SHAP achieved statistically significant separation, its median advantage reached 3.77 relative confidence points, rising to 6.51 points on IMDb sentiment and 5.51 points on Yelp reviews for four-word chunks under absolute_sum comprehensiveness cuts. Conversely, topic classification on AG News exhibited minimal separation between methods. Importantly, SHAP achieved superior faithfulness while executing substantially faster, requiring an average of 7.8 seconds per document compared to 18.7 seconds for LIME on an 8-core CPU, whereas occlusion required 3.9 seconds per document.
The empirical findings also demonstrated that explanation algorithms exhibit vastly different sensitivity to evaluation budgets. Increasing SHAP’s evaluation allowance from 200 to 500 queries per document improved faithfulness scores in only 8 of 54 test conditions, delivering a marginal average gain of 0.69 percentage points. In contrast, expanding LIME’s budget from 200 to 500 queries improved 12 conditions by an average of 1.34 points, and scaling from 50 to 500 queries improved 48 of 54 conditions by an average of 2.87 points. These divergent budget requirements illustrate why auditing tools must measure computational costs explicitly rather than assuming that equal query limits confer equivalent convergence. The authors emphasize that deletion faithfulness captures only one dimension of explanation quality and does not indicate whether explanations align with human reasoning. Because the reference benchmark evaluated a single frozen e5-small-v2 architecture under one random seed, the reported metrics reflect that specific experimental setup, providing a reproducible measurement framework that practitioners must run on their own models.
Subject of Research: Evaluation methodology and software architecture for measuring the deletion faithfulness of text classification explanations
Article Title: textfaith: measuring the deletion faithfulness of text classification explanations
Article References: Bukowski, M., & Kurek, J. (2026). textfaith: measuring the deletion faithfulness of text classification explanations. SoftwareX, 36, Article 103221. https://doi.org/10.1016/j.softx.2026.103221
Image Credits: AI Generated
DOI: 10.1016/j.softx.2026.103221
Keywords: textfaith, explainable artificial intelligence, feature attribution, deletion faithfulness, SHAP, LIME, machine learning interpretability, natural language processing, text classification, Wilcoxon signed rank test, Holm correction, comprehensiveness, sufficiency, model evaluation, computational linguistics, benchmark methodology, black box models
News Source: Blake Davidson. (November 17, 2026). Open Source Software Standardizes Deletion Faithfulness Benchmarks for Text Explanations. Scienmag.



