Causal Interpretation of Self-Attention in Pre-Trained Transformers
Raanan Y. Rohekar, Yaniv Gurwicz, Shami Nisimov
Abstract
We propose a causal interpretation of self-attention in the Transformer neural network architecture. We interpret self-attention as a mechanism that estimates a structural equation model for a given input sequence of symbols (tokens). The structural equation model can be interpreted, in turn, as a causal structure over the input symbols under the specific context of the input sequence. Importantly, this interpretation remains valid in the presence of latent confounders. Following this interpretation, we estimate conditional independence relations between input symbols by calculating partial correlations between their corresponding representations in the deepest attention layer. This enables learning the causal structure over an input sequence using existing constraint-based algorithms. In this sense, existing pre-trained Transformers can be utilized for zero-shot causal-discovery. We demonstrate this method by providing causal explanations for the outcomes of Transformers in two tasks: sentiment classification (NLP) and recommendation.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 6743fc63-d1b6-41c2-b822-39db4d503d7dCited by top-tier papers10
- Walking the Tightrope: Autonomous Disentangling Beneficial and Detrimental Drifts in Non-Stationary Custom-TuningXiaoyu Yang, Jie Lu, En YuNeurIPS 2025 · 22 citations
- Where does In-context Learning Happen in Large Language Models?Suzanna Sia, David Mueller, Kevin DuhNeurIPS 2024 · 14 citations
- Probabilistic Conceptual Explainers: Trustworthy Conceptual Explanations for Vision Foundation ModelsHengyi Wang, Shiwei Tan, Hao WangICML 2024 · 9 citations
- Boosting Resilience of Large Language Models through Causality-Driven Robust OptimizationXiaoling Zhou, Mingjie Zhang, Zhemg Lee, Yuncheng Hua et al.NeurIPS 2025 · 5 citations
- Token Activation Map to Visually Explain Multimodal LLMsYi Li, Hualiang Wang, Xinpeng Ding, Haonan Wang et al.ICCV 2025 · 3 citations
Builds on6
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- Swin Transformer: Hierarchical Vision Transformer using Shifted WindowsZe Liu, Yutong Lin, Yue Cao, Han Hu et al.ICCV 2021 · 31,683 citations
- An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
- The Causal-Neural Connection: Expressiveness, Learnability, and InferenceKevin Xia, Kai-Zhan Lee, Yoshua Bengio, Elias BareinboimNeurIPS 2021 · 158 citations
- Iterative Causal Discovery in the Possible Presence of Latent Confounders and Selection BiasRaanan Y. Rohekar, Shami Nisimov, Yaniv Gurwicz, Gal NovikNeurIPS 2021 · 43 citations
Related papers
- A Causal World Model Underlying Next Token Prediction: Exploring GPT in a Controlled EnvironmentRaanan Yehezkel Rohekar, Yaniv Gurwicz, Sungduk Yu, Estelle Aflalo et al.ICML 2025
- Causal Discovery and Inference through Next-Token PredictionEivinas Butkus, Nikolaus KriegeskorteNeurIPS 2025 · 3 citations
- How Transformers Learn Causal Structure with Gradient DescentEshaan Nichani, Alex Damian, Jason D. LeeICML 2024 · 117 citations
- Constrained Belief Updates Explain Geometric Structures in Transformer RepresentationsMateusz Piotrowski, Paul M. Riechers, Daniel Filan, Adam S. ShaiICML 2025
- Investigating Gender Bias in Language Models Using Causal Mediation AnalysisJesse Vig, Sebastian Gehrmann, Yonatan Belinkov, Sharon Qian et al.NeurIPS 2020 · 851 citations
