TL;DR
Standard gradient attribution tools (and popular methods like LIME and SHAP) often highlight irrelevant tokens in text classification because high-dimensional gradients point into meaningless, "off-manifold" adversarial directions. By filtering out large gradient norms and retaining tokens whose gradient directions agree across independently initialized surrogate models, this paper introduces a straightforward, post-training method to extract faithful "on-manifold" explanations for text and code.
What Problem Does This Paper Address?
Deep neural networks operating on high-dimensional text embeddings present an interpretability challenge. Standard gradient-based attribution, as well as perturbation-based methods like LIME and SHAP, frequently attribute high importance to neutral or irrelevant tokens (e.g., syntax, punctuation, or generic filler words).
The authors connect this failure mode to the geometry of high-dimensional data and adversarial examples: while the natural data distribution lies on an implicit, lower-dimensional manifold, gradient calculations frequently point perpendicular to this manifold (into off-manifold directions). Because text space is discrete, one cannot simply step back onto the manifold via continuous vector projection. This paper tackles how to identify and retain only on-manifold gradient signals for discrete text inputs without retraining models with expensive regularizers or complex generative architectures.
Methods
The paper derives an ensemble-based filtering approach grounded in theoretical properties of two-layer ReLU networks:
- Gradient Norm Filtering: Gradients orthogonal to the data manifold have unexpectedly large norms ($\Omega(1)$ lower bound), whereas true on-manifold gradients along data paths are small ($O(1/\sqrt{d})$). The method filters out words whose gradient norm exceeds a threshold $T$ (empirically chosen around $0.1$ after $L_\infty$ normalization).
- Surrogate Ensemble Cosine Similarity: Off-manifold gradients deviate minimally from initialization. Consequently, for two networks $N_1, N_2$ trained on the same data with different random initializations, off-manifold gradient vectors are nearly orthogonal ($\text{cosine similarity} \le O(1/\sqrt{\ell})$). On-manifold gradients, however, reflect actual task-relevant features and correlate across models.
- Algorithm:
- Train an ensemble of surrogate classifiers $\{N_i\}_{i=1}^t$ with identical architectures but different weight initializations.
- For an input, compute token-level gradients for the primary classifier and surrogates.
- Discard tokens with large gradient norms ($\|g_C^j\| \ge T$).
- Rank the remaining tokens by their average pairwise cosine similarity $\alpha_{g_C^j}$ across the ensemble; pick the top-$k$ tokens as the explanation.
Datasets
- IMDB Movie Reviews Dataset: Classical binary sentiment analysis benchmark. Reviews are truncated/padded to $n = 500$ words with an embedding dimension $p = 64$ (total input dimension $d = 32,000$).
- Industry PowerShell Scripts Dataset: An industry security dataset of benign and malicious PowerShell scripts used for malware detection.
Key Insights and Ideas
- Adversarial Noise Disguised as Explanations: Gradient attributions with the highest magnitude are often off-manifold noise rather than genuine semantic signals. Relying purely on gradient max-norm fundamentally selects for directions most susceptible to adversarial quirks.
- Initialization Decouples the Noise: Because off-manifold gradients are dominated by random initialization, ensembling independently seeded models acts as an effective bandpass filter: noise cancels out (near-zero cosine similarity), while genuine semantic features survive across seeds.
- Zero Additional Training Overhead for Production: Unlike previous on-manifold explainers that require generative decoders, autoencoders, or adversarial training losses, this approach works purely post-hoc with identical model architectures.
Key Results
- IMDB Sentiment:
- Standard gradient max-norm, LIME, and SHAP highlighted non-sentiment tokens such as
"acting","plot","gets", and"getting". - The proposed method cleanly surfaced actual sentiment-bearing rationales:
"poor story","impossible plot", and"worse movie". - PowerShell Malware Detection:
- Gradient norm, LIME, and SHAP focused on benign networking setup headers (
[Net.ServicePointManager],Tls12) or generic canonical tokens (.txt, hyphens). - The proposed method correctly identified execution-critical malware behaviors: remote fetching (
"URI"), base64 decoding and payload parsing ("Convert","FromBase64String","UTF8"), and dynamic execution ("Invoke-Expression").
(Note: The paper reports qualitative comparisons and visual attributions; task classification performance numbers are referenced from baseline implementations without new quantitative benchmark tables.)
Limitations and Future Work
- Surrogate Overhead: Generating explanations requires training and evaluating an ensemble of surrogate models on the same training distribution, which incurs additional compute.
- Empirical Threshold Selection: The norm threshold $T$ relies on inspecting the dataset's gradient norm distribution histogram (e.g., finding the elbow at $\approx 0.1$).
- Theoretical Assumptions: The formal proof assumes a simplified two-layer ReLU network on a linear subspace, though the empirical experiments extend successfully to LSTMs on real-world text.
- Future Directions: Extending theoretical guarantees to modern transformer architectures, leveraging manifold geometry to improve adversarial robustness directly, and automating manifold threshold tuning.
Summary updated