TL;DR
Standard decoder-only transformers trained purely for autoregressive forecasting naturally encode time-delayed causal structures within their learned representations. By analyzing input-output gradient sensitivities using Layer-wise Relevance Propagation (LRP), researchers can directly extract the underlying causal graph without any explicit causal objectives or structural constraints, outperforming traditional causal discovery algorithms on complex, non-stationary, and nonlinear data.
What Problem Does This Paper Address?
Causal discovery—identifying the underlying cause-and-effect relationships within a system—is a foundational challenge in machine learning and data science. In time-series analysis, this typically involves uncovering temporal causal dynamics (i.e., determining if past values of variable $X$ cause future values of variable $Y$).
However, traditional causal discovery methods face severe practical bottlenecks:
- Poor Scalability: Constraint-based and score-based algorithms scale poorly as the number of variables (dimensions) and time lags increase.
- Brittle Assumptions: Classical approaches struggle with complex nonlinear interactions and non-stationary environments where the underlying causal mechanisms change over time.
- Lack of Generalization: Traditional estimators are not scalable representation learners; their knowledge cannot be easily transferred or fine-tuned for zero-shot or few-shot adaptation across different domains.
This paper bridges the gap between sequence modeling and causality, demonstrating that the properties making transformers exceptional forecasters also make them inherently capable of structural causal discovery.
Methods
The authors establish a theoretical and practical framework showing that a standard decoder-only transformer trained for next-step multivariate time-series forecasting inherently acts as a causal learner.
- Autoregressive Forecasting: The transformer is trained using a standard mean squared error (MSE) loss to predict future values based on a window of past lagged observations.
- Score Gradient Energy: Theoretically, the authors prove that under standard identifiability assumptions (conditional exogeneity, no instantaneous effects, lag-window coverage, and faithfulness), the score gradient energy—a measure of how sensitive the conditional probability distribution of the output is to perturbations of past inputs—uniquely identifies the true causal graph.
- Layer-wise Relevance Propagation (LRP): In deep networks, raw attention weights are notoriously unreliable for causal inference because token representations become heavily mixed across layers. To circumvent this, the authors use LRP to compute stable, input-output gradient attributions, providing a faithful measure of how much a past token actually influences a future prediction.
- Graph Binarization: The continuous relevance scores extracted via LRP are aggregated across samples and converted into a binary causal graph using a per-target top-$k$ selection rule.
Datasets
The proposed approach was rigorously evaluated against traditional baselines using both synthetic and real-world benchmarks:
- Synthetic Simulations: Generated using the CDML-NeurIPS2020 structural time-series simulator. The datasets were customized to test specific challenges: high dimensionality (up to 100 nodes), long-range dependencies (lags up to 50), complex nonlinearities (piecewise linear, monotonic, and multi-layer perceptron interactions), non-stationary regimes (shifting across 2 to 10 distinct domains), and varying noise distributions.
- Real-World Benchmark: Evaluated on the CausalTime dataset, which contains real-world time series and annotated summary graphs for three distinct domains: air quality (AQI), traffic, and medical scenarios.
Key Insights and Ideas
- Causality as a Byproduct of Prediction: Transformers do not require explicit structural constraints or specialized causal loss functions to learn causal graphs. Standard next-value prediction is sufficient to force the network to internalize the true data-generating mechanisms.
- Gradients Over Attention: A major insight for transformer interpretability is that raw attention maps are unfaithful causal indicators in deep architectures due to cross-layer token mixing. Gradient-based attributions (via LRP), however, remain theoretically anchored to causal identifiability.
- Thriving on Heterogeneity: Traditional causal discovery algorithms fall apart when data comes from non-stationary environments with shifting mechanisms. In contrast, transformers leverage input-conditioned attention matrices to adapt to different contexts, showing a unique "scaling potential" where causal accuracy actually improves with data volume and heterogeneity.
Key Results
- Superior Overall Performance: The Decoder-only Transformer (DOT) achieved an average F1 score of 0.62 across all simulation benchmarks, vastly outperforming state-of-the-art baselines like DYNOTEARS (0.37), VAR-LiNGAM (0.36), and PCMCI (0.35).
- Robustness to Complexity: DOT maintained high performance when facing extreme nonlinearities (such as MLP-mixed variables and noise) and high-dimensional settings where baseline methods either timed out or degraded significantly.
- Real-World Validation: On the CausalTime dataset, the transformer-based framework outperformed most traditional causal discovery methods, ranking in the top three for both the air quality and traffic datasets.
Limitations and Future Work
- No Instantaneous Effects: Because decoder-only transformers are fundamentally autoregressive, they cannot natively model contemporaneous or instantaneous causal relationships (edges occurring within the exact same time step).
- Susceptibility to Latent Confounders: Like most causal discovery methods, the transformer's performance degrades when unobserved latent variables introduce spurious correlations. While the authors showed that post-processing with a latent-aware method like L-PCMCI helps mitigate this, a native architectural solution is still missing.
- Data Hungriness: Vanilla transformers require large sample sizes to accurately map complex nonlinear structures from scratch, indicating a weak initial inductive bias for causal structure compared to highly constrained traditional models. Incorporating mature causal priors (like independent causal mechanisms or sparsity) directly into transformer architectures remains a promising future direction.
Summary updated