Explaining Classes through Stable Word Attributions

Samuel Rönnqvist, Aki-Juhani Kyröläinen, Amanda Myntti, Filip Ginter, Veronika Laippala

Abstract

Deep learning models in Natural Language Processing (NLP) are often criticized as "black boxes," providing little insight into the global features that define specific classes. While local explanation methods like saliency maps exist, they are frequently noisy and inconsistent. This paper introduces SACX (Stable Attribution Class Explanation), a framework designed to extract robust, class-level keyword lists by aggregating attributions across multiple model instances and data splits. By filtering for stability, SACX identifies linguistically meaningful markers that define categories across an entire dataset. Our evaluation on the CORE dataset demonstrates that SACX effectively captures semantic concepts, outperforming traditional statistical baselines in identifying distinctive class features.

Introduction

As deep learning models like BERT and XLM-R become standard for text classification, the need for interpretability grows. Most current research focuses on local explanations—identifying why a model labeled a specific document as "Spam." However, these individual explanations are often unstable; a word highlighted in one document might be ignored in another, or a change in model initialization might shift the attribution entirely.

There is a significant gap in methods for global explanations that define what a model "sees" across a whole class. To address this, we propose SACX, a method to extract stable, class-level keyword lists, and a corresponding framework to evaluate the quality of these explanations through lexical measures of distinctiveness and coverage.

The SACX Methodology

The SACX framework operates on the principle that true class features should be invariant to minor changes in data distribution or model initialization. The process follows three primary stages:

  1. Train and Explain: An XLM-R model is fine-tuned on a classification task. For every correctly predicted document, Integrated Gradients (IG) are used to calculate attribution scores for every token.
  2. Aggregate across Documents: These scores are summed and normalized to identify the most predictive words for a class within that specific model instance.
  3. Select Stable Keywords: The entire training and explanation process is repeated $N$ times (e.g., 100 rounds) with different random seeds and data splits. A word is only promoted to a "stable keyword" if it consistently appears as a top-scoring feature across a high percentage of these iterations.
The SACX pipeline: aggregating attributions over N training iterations to isolate stable keywords.

This repetition acts as a powerful noise filter. The authors noted that to find the top 100 stable keywords, they often had to process an unfiltered list of over 22,000 candidate words, illustrating the high level of noise present in raw, single-run attribution scores.

Experimental Setup and Evaluation

We tested SACX using the Corpus of Online Registers of English (CORE), a dataset of nearly 50,000 web texts annotated by genre (e.g., Narrative, Opinion, How-to). Register identification is particularly challenging because class differences are often stylistic and subtle rather than purely topical.

To evaluate the resulting keyword lists, we proposed three lexical measures:

  • Intrinsic Distinctiveness: The uniqueness of keywords to a specific class.
  • Coverage: The frequency with which these keywords appear in documents of that class.
  • Extrinsic Distinctiveness: The ability of these keywords to separate one class from all others.

Key Results

The XLM-R models achieved a micro-average F1-score of 68.37% across 100 runs. Performance varied significantly by class, with "Lyrical" (82.28%) being the most predictable and "Spoken" (25.93%) the most difficult to classify.

When comparing SACX to traditional baselines like SVMs and TF-IDF, the method showed superior linguistic relevance. While SVMs achieved high distinctiveness, they often relied on statistical artifacts. In contrast, SACX favored "content" words (nouns and proper nouns). For the "Narrative" class, SACX identified specific entities like "bundesliga," whereas baselines often defaulted to generic pronouns or verbs.

Quantitative comparison of SACX against SVM and TF-IDF baselines across lexical measures.

As shown in the results, SACX achieved an intrinsic distinctiveness score of 82.57%, vastly outperforming the TF-IDF baseline (29.86%) and remaining competitive with SVMs (91.43%) while providing more interpretable features.

Conclusion and Future Work

Stability is a critical requirement for trust in model explanations. By looking for features that survive 100 different training "lives" of a model, SACX extracts highly reliable linguistic markers. Visualizations in embedding space further suggest that these keywords cluster densely, indicating that deep learning models pick up on coherent semantic concepts to define classes.

Future research will explore applying SACX to zero-shot classification and using it as a debugging tool to detect systematic biases, such as gendered keywords defining professional categories. Additionally, expanding the framework to cross-lingual settings will help determine if these stable features remain consistent across different languages.

Summary updated

BibTeX
@inproceedings{ronnqvist2022explaining,
  author = {Samuel Rönnqvist and Aki-Juhani Kyröläinen and Amanda Myntti and Filip Ginter and Veronika Laippala},
  title = {{Explaining Classes through Stable Word Attributions}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.findings-acl.85},
}
Figure