Interpreting Language Models with Contrastive Explanations

Kayo Yin, Graham Neubig

Abstract

Standard saliency-based interpretability methods often struggle with large language models (LLMs) because they conflate multiple linguistic features into a single, "blunt" explanation. We present a framework for contrastive explanations—answering "Why did the model predict token A instead of token B?"—to disentangle these decisions. Our results demonstrate that contrastive methods align more closely with linguistic theory and significantly improve the ability of humans to predict and simulate model behavior.

The Interpretability Gap in Language Generation

Most saliency-based interpretability tools, such as gradient-based maps, were originally designed for classification tasks with small output spaces. When applied to autoregressive language generation, where models choose from a vocabulary of tens of thousands, these methods often become ineffective.

A common failure mode is the "preceding token trap." Standard saliency often highlights the token immediately preceding the prediction. While technically correct—the previous word often dictates the required part of speech—it fails to explain why the model chose a specific word over a plausible alternative. For example, in the prompt "Can you stop the dog from ____", a standard explanation might highlight "from" as the reason for predicting "barking." However, this does not explain why the model chose "barking" over "crying" or "walking."

Methodology: From Saliency to Contrastive Explanations

To address this, we propose extending standard saliency methods into the contrastive domain. Instead of explaining the absolute probability of a target token $y_t$, we explain the log-probability difference between $y_t$ and a "foil" token $y_f$. We adapt three standard methods:

  1. Contrastive Gradient Norm ($S_{GN}^*$): Computes the gradient of the probability difference between the target and the foil: $\nabla (q(y_t|x) - q(y_f|x))$.
  2. Contrastive Gradient $\times$ Input ($S_{GI}^*$): The dot product of the contrastive gradient with the input embedding.
  3. Contrastive Input Erasure ($S_E^*$): Measures how the probability gap $(y_t - y_f)$ changes when a specific input token is zeroed out.

By focusing on the delta between two specific choices, the explanation filters out general syntactic requirements and isolates the evidence for specific semantic or grammatical distinctions.

Quantitative Evaluation: Linguistic Alignment

We evaluated these methods using the Benchmark of Linguistic Minimal Pairs (BLiMP) to measure alignment with "ground truth" linguistic evidence across 12 phenomena (e.g., subject-verb agreement, anaphor agreement).

Linguistic alignment of contrastive vs. non-contrastive saliency methods across three metrics: (a) Dot Product, (b) Probes Needed, and (c) Mean Reciprocal Rank. Asterisks (*) denote contrastive versions.

As shown in the figure above, contrastive methods (indicated by asterisks) consistently outperform their non-contrastive counterparts across multiple metrics. Notably, in the Dot Product metric, Contrastive Input Erasure ($S_E^*$) shows a dramatic improvement over the standard version ($S_E$), which often yields negative alignment. Furthermore, contrastive methods generally require fewer "probes" and achieve higher Mean Reciprocal Rank, indicating that the most salient tokens identified are indeed the linguistically relevant ones.

Key Insights and Human Simulatability

  • Overcoming Context Bias: Contrastive explanations "look further back" than standard methods, successfully identifying long-range dependencies like antecedents for pronouns that non-contrastive methods miss.
  • Simulatability: A key test of an explanation is whether it helps a human "act like the model." In a study with graduate students, contrastive explanations led to a 65.6% simulation accuracy, compared to 61.4% with no explanation and ~64% for non-contrastive methods.
  • Revealing Model Errors: Contrastive explanations can diagnose why a model made a mistake. For instance, if a model predicts the wrong gendered pronoun, the contrastive map often reveals it was over-influenced by a different gendered noun earlier in the sentence.
  • Subjective Utility: Users reported contrastive explanations were useful significantly more often (64.8%) than non-contrastive ones (46.5%).

Conclusion and Future Work

Contrastive explanations provide a more granular and linguistically grounded view of LLM behavior. While generating these explanations is computationally resource-intensive, they offer a path toward more reliable model debugging and human-AI alignment. Future work will focus on automating the choice of informative foils and extending the framework to attention-based interpretability methods.

Summary updated

BibTeX
@inproceedings{yin2022interpreting,
  author = {Kayo Yin and Graham Neubig},
  title = {{Interpreting Language Models with Contrastive Explanations}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.emnlp-main.14},
}
Figure