Learning Transformer-based World Models with Contrastive Predictive Coding

Maxime Burchi, Radu Timofte · DOI

In Reinforcement Learning (RL), "world models" serve as a critical mechanism for sample efficiency. By allowing an agent to "dream" or simulate potential futures, these models enable rapid learning without constant, costly interaction with the real environment. While Recurrent Neural Networks (RNNs), such as DreamerV3, have been the standard architecture for these models, the research community has struggled to leverage the superior scaling and training efficiency of Transformers. Until recently, Transformer-based world models failed to consistently outperform their RNN predecessors.

A new model, TWISTER (Transformer-based World model wIth contraSTivE Representations), addresses this performance gap. By replacing standard next-state reconstruction with a long-horizon, action-conditioned contrastive learning objective, TWISTER sets a new record on the Atari 100k benchmark.

The Next-State Prediction Trap

The primary hurdle for Transformer-based world models is what researchers call the "Next-State Prediction Trap." Most models are trained to predict the immediate next frame. However, in many environments, consecutive frames are nearly identical. For a high-capacity Transformer, predicting the next frame is often too simple; the model can achieve low error by focusing on low-level pixel continuity without ever grasping high-level game logic, such as object trajectories or score changes.

This "laziness" prevents the Transformer from fully exploiting its capacity to learn deep temporal representations. Consequently, agents struggle when using these world models to plan long-term strategies.

The TWISTER Framework

TWISTER introduces a novel training objective: Action-Conditioned Contrastive Predictive Coding (AC-CPC). This approach forces the model to learn more robust features through several key innovations:

  • Long-Horizon Prediction: Instead of looking only one step ahead, TWISTER predicts feature representations up to 10 steps into the future.
  • Action Conditioning: To make distant future prediction solvable, AC-CPC conditions predictions on a sequence of future actions, grounding the "imagination" in the agent's behavior.
  • Contrastive Learning (InfoNCE): Rather than reconstructing noisy pixels, the model must distinguish the "correct" future state from a batch of negative samples. This encourages the model to ignore pixel-level noise and focus on global features that define state transitions.
  • TSSM Architecture: TWISTER utilizes a Transformer State-Space Model (TSSM) with categorical latent variables to handle the discrete and stochastic nature of complex environments.
Figure 6: The TWISTER architecture. (a) World Model Learning uses AC-CPC to predict future states based on action sequences. (b) Agent Behavior Learning utilizes the learned model for policy optimization.

Experimental Results

TWISTER was evaluated on the Atari 100k benchmark, which limits agents to only 100,000 interaction steps to test sample efficiency. It was also tested on the DeepMind Control Suite for continuous movement tasks.

Atari 100k Performance

TWISTER achieved a record-breaking 162% mean human-normalized score, significantly outperforming previous state-of-the-art models like STORM (127%) and the RNN-based DreamerV3 (112%). Its median performance was equally impressive, reaching 77%, a substantial jump from DreamerV3’s 49%.

Figure 1: Mean and Median Human Normalized Scores on the Atari 100k benchmark. TWISTER (ours) significantly outperforms both RNN-based and previous Transformer-based world models.

Continuous Control

On the DeepMind Control Suite, TWISTER achieved a mean score of 801.8, surpassing both DreamerV3 and TD-MPC2. Ablation studies confirmed that the AC-CPC objective was the primary driver of success; removing it caused the mean Atari score to drop from 162% to 112%.

Conclusion

TWISTER demonstrates that the key to unlocking the potential of Transformers in world models lies in the training objective. By moving away from simple next-step reconstruction toward long-horizon contrastive tasks, TWISTER forces the model to learn the high-level logic necessary for effective planning. This research suggests that as we scale world models, the complexity of the "imagination" task is just as important as the architecture itself.

Summary updated

BibTeX
@inproceedings{burchi2025learning,
  author = {Maxime Burchi and Radu Timofte},
  title = {{Learning Transformer-based World Models with Contrastive Predictive Coding}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=YK9G4Htdew},
}
Figure