Explaining NLP Models via Minimal Contrastive Editing (MiCE)

Alexis Ross, Ana Marasović, Matthew E. Peters

TL;DR

Minimal Contrastive Editing (MiCE) is a novel framework that explains NLP model predictions by generating the smallest possible fluent edits to an input that flip the model's output to a specific alternative (the "contrast case"). By answering "Why $p$ instead of $q$?", MiCE provides human-like explanations that help developers debug incorrect model behavior and uncover hidden dataset biases.

What Problem Does This Paper Address?

Most current NLP explanation methods, such as saliency maps or rationales, focus on identifying which parts of an input were "important" for a prediction. However, cognitive science suggests that human explanations are naturally contrastive: we don't just ask "Why did this happen?", but "Why did this happen instead of that?".

Existing methods often fail to provide this contrastive context. Furthermore, many current techniques for generating counterfactuals (alternative inputs) rely on manually curated rules or produce text that is either non-fluent or requires changing large portions of the input, making the explanation hard to interpret. MiCE aims to bridge this gap by automatically generating targeted, minimal, and fluent edits.

Methods

MiCE employs a two-stage approach to generate these explanations:

  1. Stage 1: Training the EDITOR. The authors fine-tune a pre-trained T5 model (the "EDITOR") to perform targeted span infilling. During training, they use gradient attribution to identify tokens most responsible for a prediction, mask them, and train the EDITOR to reconstruct them given the original label. This teaches the EDITOR to associate specific text changes with specific output labels.
  2. Stage 2: Finding the Minimal Edit. To explain a specific prediction, MiCE searches for the smallest edit that flips the output to a target contrast label. It uses binary search to find the optimal percentage of tokens to mask and beam search to generate and rank candidate edits from the EDITOR. The goal is to find an edit $e(x)$ such that the predictor's output flips to the contrast case while minimizing the Levenshtein distance from the original input.
Figure 2: An overview of MICE, our two-stage approach to generating edits. In Stage 1 (§2.3), we train the EDITOR to make edits targeting specific predictions from the PREDICTOR. In Stage 2 (§2.4), we make contrastive edits with the EDITOR model from Stage 1 such that the PREDICTOR changes its output to the contrast prediction.

Datasets

The authors evaluated MiCE across three distinct English-language tasks:

  • IMDB: Binary sentiment classification of movie reviews.
  • NEWSGROUPS: A 6-class version of the 20 Newsgroups topic classification task.
  • RACE: A complex multiple-choice question-answering dataset.

Key Insights and Ideas

  • Contrastivity is Context-Dependent: The explanation for why a model didn't pick "Choice A" should be different from why it didn't pick "Choice B." MiCE successfully generates different edits for different contrast cases.
  • Gradient Masking is Essential: Using gradient information to decide which tokens to mask (Stage 1) significantly outperforms random masking, leading to more effective and minimal edits.
  • Targeted Infilling Matters: Conditioning the EDITOR on the target label during both training and generation is crucial. Without this "signal," the model struggles to find edits that actually flip the prediction at low masking percentages.
  • Artifact Discovery: MiCE can reveal "bugs" in models. For example, it showed that an IMDB classifier relied heavily on numerical ratings (e.g., "7/10") rather than the actual text of the review.

Key Results

MiCE achieved high performance across all metrics, as shown in the table below:

Quantitative results showing high flip rates and low minimality scores across IMDB, NEWSGROUPS, and RACE.
  • Flip Rate: MiCE successfully flipped predictions in 91.5% to 100% of test instances across the three tasks.
  • Minimality: On average, MiCE only needed to change 17% to 33% of the original tokens to achieve a flip.
  • Fluency: The generated edits were highly fluent, with language modeling loss ratios near 1.0, meaning the edited text looked natural to a secondary model.
  • Human Comparison: On the IMDB dataset, MiCE edits were found to be comparable in size and fluency to edits manually created by humans.

Limitations and Future Work

  • Computational Cost: The search process in Stage 2 is expensive, requiring hundreds of forward and backward passes through the models to find the optimal minimal edit.
  • Search Efficiency: The authors note that finding truly "minimal" edits in the massive search space of natural language remains an open challenge. Future work could focus on more efficient search algorithms.
  • Strict Minimality: The current method doesn't strictly guarantee that no smaller subset of the edit would also flip the prediction; it only finds the best edit within its search parameters.
  • Adversarial Risks: Like many interpretability tools, MiCE could potentially be repurposed by malicious actors to generate minimal adversarial attacks that fool classifiers while remaining fluent.

Summary updated

Abstract

Humans have been shown to give contrastive explanations, which explain why an observed event happened rather than some other counterfactual event (the contrast case). Despite the influential role that contrastivity plays in how humans explain, this property is largely missing from current methods for explaining NLP models. We present Minimal Contrastive Editing (MiCE), a method for producing contrastive explanations of model predictions in the form of edits to inputs that change model outputs to the contrast case. Our experiments across three tasks--binary sentiment classification, topic classification, and multiple-choice question answering--show that MiCE is able to produce edits that are not only contrastive, but also minimal and fluent, consistent with human contrastive edits. We demonstrate how MiCE edits can be used for two use cases in NLP system development--debugging incorrect model outputs and uncovering dataset artifacts--and thereby illustrate that producing contrastive explanations is a promising research direction for model interpretability.
BibTeX
@inproceedings{ross2021explaining,
  author = {Alexis Ross and Ana Marasović and Matthew E. Peters},
  title = {{Explaining NLP Models via Minimal Contrastive Editing (MiCE)}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
}
Figure