Introduction
Neural networks have demonstrated remarkable proficiency in capturing compositional semantics—the way individual words combine to form complex, nuanced meanings. For instance, a model can correctly identify that the phrase "not bad" conveys a positive sentiment, even though the word "bad" is inherently negative. However, explaining how these models arrive at such conclusions remains a significant challenge. This paper introduces two novel algorithms, Sampling and Contextual Decomposition (SCD) and Sampling and Occlusion (SOC), designed to provide hierarchical explanations of model predictions by quantifying the importance of phrases independently of their specific context.
The Limitation of Additive Attribution
Most existing interpretability tools for Natural Language Processing (NLP) are additive. They assign importance scores to individual words, operating under the assumption that the final prediction is simply the sum of these parts. This approach fails to capture the non-linear interactions and "compositional surplus" that define human language.
While hierarchical methods like Contextual Decomposition (CD) exist, they often suffer from context dependence. In these methods, the importance score of a phrase is heavily influenced by the specific words surrounding it in a single sentence. This inconsistency prevents researchers from isolating the "pure" contribution of a phrase. The authors argue that a truly useful explanation must be both non-additive (recognizing phrases as cohesive units) and context-independent.
Hierarchical Importance via Marginalization
To address context dependence, the authors propose a framework for N-context independent importance. Instead of evaluating a phrase within a single fixed sentence, the proposed methods use a pre-trained language model to sample a wide variety of possible surrounding contexts. By marginalizing (averaging) the model's response across these samples, the inherent contribution of the phrase is isolated from the noise of its specific environment.
Proposed Algorithms
- Sampling and Contextual Decomposition (SCD): This is a layer-wise approach that modifies the original CD algorithm. It decomposes the neural network's activation functions by calculating the expected difference in output when a phrase's contribution is present versus absent, marginalized over sampled contexts.
- Sampling and Occlusion (SOC): This is a model-agnostic approach that is particularly useful for complex architectures like BERT. It works by replacing a phrase with padding tokens and measuring the resulting change in prediction across various sampled contexts. Because it treats the model as a "black box," it is highly versatile.
Key Insights and Results
One of the most striking findings is the methods' ability to handle adversarial conjunctions. In sentences containing contrastive words like "but," SCD and SOC correctly identify shifts in model focus. For example, in the sentence "It delivers some chills... but flounders in its quest for deeper meaning," these algorithms correctly identify that the model prioritizes the negative sentiment following the conjunction, whereas traditional methods like GradSHAP often remain "distracted" by the initial positive words.
Quantitative and Qualitative Performance
- Human Correlation: On the SST-2 (Stanford Sentiment Treebank) dataset, SOC and SCD achieved significantly higher Pearson correlation with human-annotated phrase importance than baselines. For BERT, SOC achieved a correlation of 0.6628, more than doubling the 0.3068 achieved by standard CD.
- Trust and Rule Extraction: User studies confirmed that explanations from SOC and SCD are perceived as more trustworthy. Furthermore, the methods can extract "classification rules" from models. In the TACRED dataset, for instance, the model was shown to have learned that the pattern
[PERSON], [NUMBER], wasis a primary indicator for the "person:age" relationship.
Conclusion
By moving beyond additive, context-dependent explanations, SCD and SOC provide a more faithful representation of how neural sequence models process language. While the sampling-based approach introduces a computational trade-off, the resulting increase in explanation quality and human trust represents a significant step forward in the interpretability of deep learning for NLP. Future work may focus on optimizing the marginalization process to reduce the need for exhaustive sampling.
Summary updated