Discretized Integrated Gradients for Explaining Language Models

Soumya Sanyal, Xiang Ren

Introduction

To foster trust in Large Language Models (LLMs), it is essential to understand the rationale behind their predictions. Attribution methods aim to identify which input features—such as specific words in a movie review—most significantly influence a model's output. A prominent technique is Integrated Gradients (IG), which attributes importance by integrating the model's gradients along a path from a baseline (e.g., a <pad> token) to the actual input.

The Problem with Straight-Line Paths

In Natural Language Processing (NLP), words are represented as vectors in a high-dimensional embedding space. This space is inherently discrete; only specific coordinates correspond to actual words in the vocabulary. Standard IG assumes a continuous space and calculates gradients along a straight-line path between the baseline and the input word.

Comparison of the straight-line IG path (green) versus the discretized DIG path (blue) through actual vocabulary words.

As illustrated above, this straight-line path often traverses "nonsense" regions where no real words exist. Because the model was never trained on these "out-of-distribution" vectors, the resulting gradients can be unreliable, leading to explanations that do not faithfully reflect the model's internal logic.

Discretized Integrated Gradients (DIG)

The authors propose Discretized Integrated Gradients (DIG) to address this limitation. DIG replaces the straight-line interpolation with a non-linear path that "hops" through the embedding space, staying as close as possible to real vocabulary words (anchor words). The method consists of two primary components:

  1. MONOTONIZE: To maintain the mathematical integrity of attribution theory (specifically the Completeness axiom), the path must be monotonic. This function slightly adjusts the dimensions of a real word's embedding to ensure it satisfies this constraint.
  2. ANCHORSEARCH: This strategy selects the next anchor word in the path. Two heuristics are introduced: DIG-GREEDY, which minimizes the required monotonic adjustment, and DIG-MAXCOUNT, which selects words that naturally satisfy the most monotonicity constraints.

By grounding the interpolation path in the distribution of real language, DIG ensures that the gradients used for attribution are calculated on points the model actually understands.

Experimental Evaluation

DIG was evaluated using BERT, RoBERTa, and DistilBERT models across three sentiment classification benchmarks: SST2, IMDB, and Rotten Tomatoes (RT). The researchers measured performance using automated metrics for faithfulness—such as Log-odds, Comprehensiveness, and Sufficiency—and Word-Approximation Error (WAE), which quantifies the distance of the path from the actual vocabulary.

Key Results

DIG consistently outperformed standard baselines like IG, Grad*Input, and GradShap. On the SST2 dataset with DistilBERT, DIG-MAXCOUNT achieved a superior Log-odds score of -1.259 (compared to IG’s -0.950). Furthermore, DIG reduced WAE by 30-50%, indicating a much closer alignment with real-world data distributions.

Mean rank of different attribution methods across SST2 and RT datasets; lower rank indicates higher human preference.

Human evaluations confirmed these findings. In blind tests, participants significantly preferred DIG's explanations, finding the highlighted words to be more plausible and trustworthy justifications for the model's sentiment labels.

Conclusion and Future Work

DIG represents a significant step toward more faithful and human-interpretable AI by reconciling continuous attribution theory with the discrete nature of language. While DIG is more computationally intensive than standard IG due to its iterative search process, it provides a more grounded explanation of model behavior. Future research may focus on optimizing search heuristics to incorporate semantic meaning or developing paths that consist entirely of unmodified vocabulary words.

Summary updated

BibTeX
@inproceedings{sanyal2021discretized,
  author = {Soumya Sanyal and Xiang Ren},
  title = {{Discretized Integrated Gradients for Explaining Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.emnlp-main.805},
}
Figure