Towards Hierarchical Importance Attribution: Explaining Compositional Semantics for Neural Sequence Models

Xisen Jin, Zhongyu Wei, Junyi Du, Xiangyang Xue, Xiang Ren

TL;DR

Deep learning models for text are often treated as "black boxes" that excel at understanding how words combine into complex phrases. However, explaining this "compositional logic" is notoriously difficult. This paper introduces two new algorithms, SCD (Sampling and Contextual Decomposition) and SOC (Sampling and Occlusion), which provide hierarchical explanations of model predictions by measuring the "context-independent" importance of phrases. These methods significantly outperform previous approaches in explaining complex models like LSTMs and BERT.

The Challenge of Compositional Semantics

While neural networks have revolutionized Natural Language Processing (NLP), their decision-making processes remain opaque. Most existing explanation methods are additive: they assign an importance score to each individual word. However, language is inherently hierarchical and compositional. For instance, the phrase "not bad" isn't just the sum of the negative word "not" and the negative word "bad"; its positive meaning emerges from their interaction.

Comparison of attribution methods showing how hierarchical attribution captures compositional semantics like "not interesting" better than additive or occlusion methods.

Previous attempts at hierarchical explanation, such as Contextual Decomposition (CD), tried to address this but suffered from a major flaw: context dependence. In these methods, the importance of a phrase was tied too closely to the specific sentence it appeared in. This led to inconsistent explanations where the same phrase might be labeled "important" in one sentence but "irrelevant" in another, simply because of the surrounding words. The authors aim to create a more robust, "context-independent" way to quantify phrase importance.

Proposed Methods: SCD and SOC

The authors propose a formal framework for $N$-context independent importance. The core idea is that to truly understand the intrinsic contribution of a phrase, one must measure its impact on the model's output across a variety of possible surrounding "neighborhoods" (contexts).

They introduce two primary algorithms to achieve this:

  1. Sampling and Contextual Decomposition (SCD): This is a layer-wise modification of the original CD algorithm. When the model processes a non-linear activation (like a sigmoid or ReLU), SCD uses a pre-trained language model to sample many possible contexts for a phrase. It then calculates the "expected" contribution of that phrase, making the explanation much more stable.
  2. Sampling and Occlusion (SOC): A simpler, model-agnostic approach. It works by "masking" a phrase and replacing the surrounding words with samples from a language model. By comparing the model's prediction on these sampled sentences with and without the phrase, it determines the phrase's average impact.
Comparison of Contextual Decomposition (CD) and the proposed Sampling and Contextual Decomposition (SCD), highlighting the shift from padding to language-model sampling.

Crucially, both methods move away from simple "padding" (replacing words with a null or <pad> token). Neural networks are trained on real language; feeding them a string of <pad> tokens can cause their internal logic to break in ways that don't reflect their actual decision-making. By using sampling, the inputs remain natural, preventing the model from behaving erratically on out-of-distribution data.

Experimental Setup & Key Insights

The researchers evaluated their methods across three diverse NLP benchmarks: SST-2 (binary sentiment analysis), Yelp Sentiment Polarity, and TACRED (relation extraction). They tested these on both standard LSTM architectures and complex BERT Transformers.

  • The "Aha" Moment on Context: The authors realized that prior methods failed because they were too "local." By marginalizing over possible contexts via the sampling step, they effectively "distill" the intrinsic importance of a phrase.
  • Hierarchical Visualization: Their method allows for the creation of "explanation trees." This lets researchers see exactly where a model switches its prediction (e.g., identifying the exact "but" clause that flips a sentence's sentiment from negative to positive).

Key Results

  • Human Trust: In human evaluation studies, users consistently ranked SOC and SCD visualizations as more helpful and trustworthy than baselines like GradSHAP or ACD.
  • Quantitative Accuracy: The authors measured the correlation between their importance scores and human-annotated sentiment labels. SOC and SCD achieved significantly higher Pearson correlation coefficients ($\rho$) than prior methods, especially on the complex BERT model.
  • Rule Extraction: The methods proved highly effective at "extracting" the logic the model learned. For example, in the TACRED dataset, the algorithms successfully identified that the model was looking for specific compositional patterns like [PERSON], [NUMBER], was to identify a "person:age" relationship.

Limitations and Future Work

While powerful, these methods come with trade-offs:

  • Computational Cost: Because these methods involve sampling $K$ contexts (the authors used $K=20$) for every phrase being explained, they are significantly more computationally expensive than a single gradient-based explanation.
  • Language Model Dependency: The quality of the explanation relies on the quality of the language model used for sampling. If the sampler doesn't represent the data distribution well, the "context-independent" measure might be biased.

Looking forward, the authors suggest that these hierarchical explanations could be used not just to explain models, but to improve them—perhaps by regularizing models to follow more human-like hierarchical logic during the training phase.

Summary updated

BibTeX
@inproceedings{jin2020towards,
  author = {Xisen Jin and Zhongyu Wei and Junyi Du and Xiangyang Xue and Xiang Ren},
  title = {{Towards Hierarchical Importance Attribution: Explaining Compositional Semantics for Neural Sequence Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2020},
  url = {https://openreview.net/forum?id=XQbX96BuoC},
}
Figure