Fooling Explanations in Text Classifiers

Adam Ivankay, Ivan Girardi, Chiara Marchiori, Pascal Frossard

Introduction

While deep learning models for text classification are incredibly powerful, their "black-box" nature remains a significant liability, especially when deployed in high-stakes areas like healthcare or legal discovery. To build trust, researchers and practitioners rely on Explainable AI (XAI) techniques—such as Saliency Maps, Integrated Gradients, or Attention mechanisms—to highlight which words in a sentence triggered a specific classification.

But what if these explanations can be easily manipulated? Previous research has shown that image-based explanations can be "fooled" by adding microscopic noise. Doing the same for text is inherently more difficult because text is discrete; you cannot simply add a tiny numerical perturbation to a word. This paper introduces TextExplanationFooler (TEF), a novel attack demonstrating that text explanations are just as fragile. By swapping just a few words for synonyms, an attacker can radically change which words appear "important" to the model without altering the final prediction at all.

The TextExplanationFooler (TEF) Attack

The authors propose TEF as a black-box adversarial attack. Unlike "white-box" attacks that require internal knowledge of the model's gradients or architecture, TEF only needs access to the model's output prediction and the resulting explanation map.

The algorithm operates in two primary steps:

  1. Word Importance Ranking: TEF identifies which words in the input sentence have the most significant impact on the explanation (rather than the prediction) by masking them one by one and observing the shift in the explanation.
  2. Candidate Selection: For these highly influential words, the algorithm searches for synonyms using "counter-fitted" GloVe embeddings, ensuring the replacements are true synonyms and not just contextually related words. It then applies Part-Of-Speech (POS) filtering to guarantee the sentence remains grammatically correct and the perturbation remains "imperceptible" to a human reader.

The ultimate goal is to generate a perturbed sentence where the model's prediction remains identical, but the "importance map" (the explanation) is entirely different.

Key Results and Insights

The researchers evaluated TEF across five diverse text classification benchmarks (AG’s News, IMDB, MR, Fake News, and Yelp) and tested it against six different architectures, ranging from standard CNNs and LSTMs to state-of-the-art Transformers like BERT, RoBERTa, and XLNet.

Performance of TEF across various models, explanation methods, and datasets.
  • Explanations are Fragile: The most striking insight is how little effort it takes to break an explanation. Swapping a few words (e.g., changing "movie" to "cinematographic") can make a model appear to be focusing on totally irrelevant words, even though its internal logic for the prediction hasn't changed. TEF successfully reduced the Pearson Correlation Coefficient (PCC) between original and perturbed explanations to below 0.2 (where 1.0 is a perfect match) across almost all datasets and models.
  • High Confidence, Low Faithfulness: In many cases, the model maintained a prediction confidence of 99%, yet the explanation was successfully "flipped."
  • Attention is Not Robust: There is a common belief that "Attention" mechanisms in Transformers provide a more "natural" and robust explanation. The paper debunks this, showing that attention maps are just as susceptible to manipulation as gradient-based methods. While Transformers were slightly more robust than simpler RNNs, they still failed significantly.
Comparison of TEF against random baselines, showing significant drops in correlation (PCC).
  • The Transferability Trap: An attack designed to fool a BERT model's explanation often successfully fools an LSTM's explanation too. This means an attacker doesn't even need to know exactly what model you are using to manipulate your perception of it.
  • Semantic Preservation: Using the Universal Sentence Encoder, the authors proved that the "fooled" sentences remained semantically almost identical to the originals, meaning a human would likely not notice the attack.

Limitations and Future Work

The authors acknowledge a few areas for future exploration. While the black-box approach is impressive, a white-box attack (using model gradients) might provide an even tighter bound on how fragile these systems are. Additionally, the current method relies on fixed synonym lists; using a masked language model to generate replacement words could make the attacks even more seamless.

Ultimately, the paper serves as a warning: do not trust a model's explanation blindly. If a tiny, imperceptible synonym swap can completely change the "why" behind a prediction, the explanation might not be a faithful representation of the model's true reasoning. The next logical step for the community is to develop "explanation-stabilization" techniques that make these attribution maps robust to small input changes.

Summary updated

BibTeX
@inproceedings{ivankay2022fooling,
  author = {Adam Ivankay and Ivan Girardi and Chiara Marchiori and Pascal Frossard},
  title = {{Fooling Explanations in Text Classifiers}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=r05lPDeX4gw},
}
Figure