Learning to Explain: Supervised Token Attribution from Transformer Attention Patterns
George Mihaila
TL;DR
This work addresses the opacity of transformer models in high-stakes domains by reframing explanation as a learnable mapping from attention patterns to token-level rationales. ExpNet uses a frozen BERT-base as a feature extractor and trains a lightweight MLP to predict token importance from bidirectional attention signals, supervised by human rationales. It demonstrates strong cross-task generalization across SST-2, CoLA, and HateXplain, outperforming a broad suite of baselines while offering substantial computational efficiency. The results indicate that attention-based explanations can be learned to align with human reasoning and deployed in real-time, though future work is needed to scale to larger models and decoder-based architectures and to validate user impact. Overall, ExpNet provides a principled, efficient pathway to human-aligned explanations in transformer-based NLP systems.
Abstract
Explainable AI (XAI) has become critical as transformer-based models are deployed in high-stakes applications including healthcare, legal systems, and financial services, where opacity hinders trust and accountability. Transformers self-attention mechanisms have proven valuable for model interpretability, with attention weights successfully used to understand model focus and behavior (Xu et al., 2015); (Wiegreffe and Pinter, 2019). However, existing attention-based explanation methods rely on manually defined aggregation strategies and fixed attribution rules (Abnar and Zuidema, 2020a); (Chefer et al., 2021), while model-agnostic approaches (LIME, SHAP) treat the model as a black box and incur significant computational costs through input perturbation. We introduce Explanation Network (ExpNet), a lightweight neural network that learns an explicit mapping from transformer attention patterns to token-level importance scores. Unlike prior methods, ExpNet discovers optimal attention feature combinations automatically rather than relying on predetermined rules. We evaluate ExpNet in a challenging cross-task setting and benchmark it against a broad spectrum of model-agnostic methods and attention-based techniques spanning four methodological families.
