Abstract
This paper proposes a method to disentangle and quantify interactions among words that are encoded inside a DNN for natural language processing. We construct a tree to encode salient interactions extracted by the DNN. Six metrics are proposed to analyze properties of interactions between constituents in a sentence. The interaction is defined based on Shapley values of words, which are considered as an unbiased estimation of word contributions to the network prediction. Our method is used to quantify word interactions encoded inside the BERT, ELMo, LSTM, CNN, and Transformer networks. Experimental results have provided a new perspective to understand these DNNs, and have demonstrated the effectiveness of our method.
Introduction
Deep Neural Networks (DNNs) have achieved state-of-the-art performance in Natural Language Processing (NLP), yet they remain largely "black boxes." While existing attribution methods can identify which individual words are important for a prediction, they fail to capture how words interact hierarchically to form meaning. For instance, in the phrase "green hand" (meaning a novice), the interaction between the two words creates a semantic shift that individual word importance cannot explain.
This research introduces a post-hoc method to extract interaction trees from pre-trained models. Unlike previous approaches that constrain a model's architecture to a tree structure during training—often at the cost of accuracy—this method reveals the latent hierarchical logic already learned by high-performing models like BERT and ELMo.
Methodology: Quantifying Word Cooperation
The core of this approach treats a DNN's prediction as a cooperative game where words are players. To quantify their "cooperation," the authors utilize Shapley values from game theory.
Interaction Benefit ($B$)
The interaction of a group of words is defined as the difference between their joint contribution to the model's output and the sum of their individual contributions. A positive interaction benefit ($B > 0$) indicates synergy or cooperation, while a negative value ($B < 0$) suggests conflict or adversarial relationships between words.
Tree Construction
The algorithm constructs a binary tree using a greedy bottom-up approach. Starting with individual words as leaves, it iteratively merges adjacent words or phrases that exhibit the highest "interaction density."
Experimental Evaluation
The researchers evaluated the method across several architectures—BERT, ELMo, LSTM, CNN, and standard Transformers—using the following datasets:
- SST-2 (Stanford Sentiment Treebank): Binary sentiment classification.
- CoLA (Corpus of Linguistic Acceptability): Grammaticality prediction.
- Synthetic AND-OR Dataset: A custom dataset with ground-truth logical interactions used to verify the algorithm's accuracy in recovering known structures.
Key Insights: DNN Logic vs. Human Syntax
The study reveals that the internal logic of DNNs often diverges significantly from human linguistic rules.
- Non-Syntactic Merging: Interaction trees learned by models like BERT frequently do not align with formal grammar trees. For example, sentiment models may prioritize merging "not" with "good" immediately, bypassing traditional syntactic hierarchies.
- Architectural Personalities: Different models exhibit unique structural preferences. CNNs often mirror subject-verb-object patterns, whereas LSTMs and ELMo focus on smaller constituents like prepositional phrases.
- Complexity and Stability: More complex models like BERT are inherently more "unstable." Because they encode intricate interactions, they require a higher number of samples (typically over 1,000) to produce reliable estimates of their internal logic.
Results
The proposed method demonstrates significant improvements in model interpretability:
- Superior Cohesion: On the SST-2 dataset, the interaction trees achieved higher cohesion scores than existing baselines like HEDGE, indicating that the identified constituents are more central to the model's decision-making process.
- Ground Truth Recovery: The method achieved a 97.77% average Recall on the synthetic AND-OR dataset, confirming its ability to accurately reconstruct underlying logical structures.
- Quantifying the Gap: "Fitness" tests showed low F1 scores (e.g., 17.67 for BERT on SST-2) when comparing extracted trees to human syntactic trees, providing quantitative evidence that DNNs process language using a logic distinct from human grammar.
Conclusion
This method provides a powerful tool for "cracking open" black-box NLP models without sacrificing performance. While the computational cost of calculating Shapley values remains a challenge for long sequences, the ability to visualize and quantify latent interactions offers a new frontier for understanding and debugging deep learning models.
Summary updated