Abstract
Deep neural networks are increasingly used in natural language processing (NLP) models. However, the need to interpret and explain the results from complex algorithms limits their widespread adoption in regulated industries such as banking. While work exists on interpretability for structured data, NLP remains challenging due to high dimensionality and the necessity of maintaining textual coherence. This paper develops a methodology to compute SHAP values for local and global explainability of CNN-based text classification models, illustrated through sentiment analysis of Amazon Electronic Review data.
Introduction
Deep learning models often operate as "black boxes," a significant hurdle in sectors like finance where regulatory compliance requires transparency. Shapley Additive Explanations (SHAP) offer a robust framework for interpretability, yet applying SHAP to NLP faces two primary obstacles: the curse of dimensionality, where complexity grows exponentially with vocabulary size, and the loss of context, where word-level (unigram) explanations ignore the multi-word phrases that often drive model decisions.
Methodology: CNN SHAP
The proposed methodology, CNN SHAP, addresses these issues by treating the Convolutional Neural Network (CNN) as a dimension-reduction feature extractor.
Architecture and Feature Extraction
The approach leverages the standard 1D CNN architecture for text, where an embedding matrix is processed by multiple filters of varying sizes (e.g., unigrams, bigrams, trigrams).
Filter-Level SHAP
Instead of calculating SHAP values for every individual word or high-dimensional embedding, the authors calculate them for the outputs of the CNN's max-pooling layer. Because each filter is designed to activate upon detecting specific n-grams, the SHAP value of a filter output can be directly mapped back to a specific phrase in the original text.
Optimization and Aggregation
To make calculations feasible, the authors utilize Kernel SHAP to approximate values. Furthermore, they implement de-duplication strategies to handle redundant filters:
- Exact De-duplication: Merging identical n-grams identified by different filters.
- Merge De-duplication: Combining overlapping n-grams (e.g., "called the customer" and "customer service" into "called the customer service") by summing their additive SHAP scores.
For global interpretability, the paper introduces rank-based methods—Inverse Rank Average (IRA) and Uniform Rank Average (URA)—to aggregate local n-gram importance across the entire dataset.
Experimental Results
The methodology was evaluated using 75,000 samples from the Amazon Electronic Review dataset for sentiment analysis.
Local Explanations
CNN SHAP successfully identified key sentiment drivers. For instance, in positive reviews, phrases like "no problems" and "is the excellent" were assigned high positive SHAP values. The de-duplication process effectively cleaned redundant filter outputs into coherent, human-readable phrases.
Global Insights
Using URA ranking, the study identified the most significant global indicators of sentiment. Positive sentiment was strongly driven by n-grams such as "easy," "very pleased with," and "no problems," while negative sentiment was primarily linked to "poor" and "the problem."
Conclusion and Future Work
CNN SHAP provides a computationally feasible path toward explaining complex NLP models by focusing on the internal "summaries" created by CNN filters. While the current use of marginal expectations simplifies calculations, future work could explore more robust conditional expectation methods to handle complex feature dependencies. Additionally, the potential for using CNNs as surrogate models to explain even more complex architectures, such as Transformers, remains a promising area for investigation.
Summary updated