Transformer Is Inherently a Causal Learner
Xinyue Wang, Stephen Wang, Biwei Huang
TL;DR
This work demonstrates that decoder-only transformers trained for autoregressive forecasting inherently learn time-delayed causal structure in their representations. By introducing the score-gradient energy $H_{j,i}^{\ell}$ and aggregating gradient attributions via Layer-wise Relevance Propagation (LRP), the authors establish causal identifiability under standard assumptions and provide a practical graph-extraction pipeline that surpasses state-of-the-art causal-discovery methods across nonlinear, long-range, and non-stationary dynamics. The approach enables a data-efficient, scalable perspective on causal discovery, and situates foundation models as interpretable causal learners when viewed through the lens of gradient-based causality. Importantly, the framework supports extensions with domain indicators and latent-variable post-processing, promoting robustness and transfer across diverse environments. Overall, the paper reframes causal discovery as a by-product of scalable representation learning, with significant implications for interpretable, environment-aware foundation-model development.
Abstract
We reveal that transformers trained in an autoregressive manner naturally encode time-delayed causal structures in their learned representations. When predicting future values in multivariate time series, the gradient sensitivities of transformer outputs with respect to past inputs directly recover the underlying causal graph, without any explicit causal objectives or structural constraints. We prove this connection theoretically under standard identifiability conditions and develop a practical extraction method using aggregated gradient attributions. On challenging cases such as nonlinear dynamics, long-term dependencies, and non-stationary systems, this approach greatly surpasses the performance of state-of-the-art discovery algorithms, especially as data heterogeneity increases, exhibiting scaling potential where causal accuracy improves with data volume and heterogeneity, a property traditional methods lack. This unifying view lays the groundwork for a future paradigm where causal discovery operates through the lens of foundation models, and foundation models gain interpretability and enhancement through the lens of causality.
