A Causal World Model Underlying Next Token Prediction: Exploring GPT in a Controlled Environment

Raanan Y. Rohekar, Yaniv Gurwicz, S. Yu, Vasudev Lal, Lal, Vasudev · DOI

Abstract

Do generative pre-trained transformer (GPT) models, trained only to predict the next token, implicitly learn a world model from which a sequence is generated one token at a time? We address this question by deriving a causal interpretation of the attention mechanism in GPT, and suggesting a causal world model that arises from this interpretation. Furthermore, we propose that GPT models, at inference time, can be utilized for zero-shot causal structure learning for input sequences and present a confidence score. Empirical evaluation is conducted in a controlled environment using the setup and rules of the Othello and Chess strategy games. A GPT, pre-trained on real-world games played with the intention of winning, is tested on out-of-distribution synthetic data consisting of sequences of random legal moves. We find that the GPT model is likely to generate legal next moves for out-of-distribution sequences for which a causal structure is encoded in the attention mechanism with high confidence. In cases for which the GPT model generates illegal moves it also fails to capture any causal structure.

Introduction

The debate over whether Large Language Models (LLMs) are merely "stochastic parrots" or possess genuine internal "world models" is central to modern AI research. While previous studies have successfully "probed" models to find board states in games like Othello, they often fail to explain the architectural mechanisms that allow these representations to emerge. This paper bridges the gap between next-token prediction and causal reasoning, arguing that GPT models are naturally incentivized to learn compact causal structures rather than exhaustive statistical patterns.

Methodology

The core of this research involves mapping the Transformer architecture to Structural Causal Models (SCMs). The authors propose that the masked attention matrix ($A$) represents the transitive closure of influence between tokens in a causal graph.

Causal Discovery from Attention

To extract this structure, the researchers perform the following steps:

  1. Normalization Reversal: They calculate $D^{-1}A$ (where $D$ is a diagonal matrix of attention sums) to undo softmax effects, obtaining a form suitable for causal weight interpretation.
  2. Recursive Extraction: Using Algorithm 1, they derive a Partial Ancestral Graph (PAG) from the attention matrices, enabling "zero-shot" causal discovery.
  3. Structural Confidence Score ($R$): A metric based on the entropy of $p$-values from Conditional Independence (CI) tests is introduced to quantify how clearly the model represents internal causal dependencies.
Figure 3: An example of a causal graph (Partial Ancestral Graph) extracted from the model's internal attention mechanism, illustrating the dependencies between sequence tokens.

Experimental Setup

The hypothesis was tested using Othello and Chess, environments with rigid, discrete rules. To distinguish between memorization and rule-learning, the models were evaluated on Out-of-Distribution (OOD) sequences of random legal moves. Success in this OOD task indicates an understanding of the underlying game mechanics (causality) rather than just winning strategies learned from human games.

Figure 6: A sequence in Othello showing the state after move 2. The model must predict legal moves based on the current board configuration, even if the sequence is non-strategic.

Results and Discussion

The findings suggest that GPT models build internal causal maps to navigate complex rule-based environments.

Correlation with Legality

A strong correlation was observed between the structural confidence score ($R$) and the legality of the model's predictions. When the attention mechanism encoded a clear causal structure, the model was highly likely to generate a legal move. Conversely, low confidence scores were predictive of "hallucinations" or illegal moves.

Causal Importance of Attention Heads

The researchers found that not all attention heads are equal. Pruning heads with low structural confidence had negligible impact on performance. However, removing heads that strongly encoded causal structures led to a significant drop in the model's ability to follow game rules. This suggests that specific components of the Transformer are dedicated to maintaining the world model.

Conclusion

This work provides a mathematical framework for interpreting GPT's internal states through the lens of causality. By demonstrating that models learn the "rules of the game" even when trained on strategic data, the authors show that causal efficiency is a powerful driver in transformer optimization. Future applications include real-time hallucination detection by monitoring the stability of a model's internal causal graphs.

Summary updated

BibTeX
@inproceedings{rohekar2025causal,
  author = {Raanan Y. Rohekar and Yaniv Gurwicz and S. Yu and Vasudev Lal and Lal, Vasudev},
  title = {{A Causal World Model Underlying Next Token Prediction: Exploring GPT in a Controlled Environment}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=qA3xHJzF6B},
}
Figure