One-shot World Models Using a Transformer Trained on a Synthetic Prior

Fabio Ferreira, Moreno Schlageter, Raghu Rajan, Andre Biedenkapp, Frank Hutter · DOI

Abstract

Traditional world models in Reinforcement Learning (RL) typically require extensive training on specific target environments, limiting their generalizability and increasing data collection costs. We present the One-Shot World Model (OSWM), a Transformer-based architecture trained entirely on purely synthetic, randomly generated data. By leveraging the paradigm of in-context learning, OSWM can ingest a small sequence of interactions from a novel, unseen environment and immediately predict its dynamics and rewards. This allows RL agents to be trained entirely within a "hallucinated" simulator. Our experiments show that OSWM can effectively mimic various environments, such as CartPole and GridWorld, enabling zero-shot adaptation to new physical dynamics.

Introduction

In Reinforcement Learning, world models serve as internal simulators that allow agents to plan or "dream" without the risks and costs associated with real-world interactions. However, the standard approach requires training these models on the very environments they are meant to simulate, creating a data-dependency bottleneck. Furthermore, these models are often brittle; a model trained for one task rarely generalizes to another.

Inspired by the success of Large Language Models (LLMs) in understanding the "language of text," OSWM aims to understand the "language of dynamics." The goal is to create a foundation world model that, after seeing a brief context of 1,000 steps in a new environment, can accurately simulate future states and rewards for agent training.

Methods

The OSWM framework shifts the focus from environment-specific training to pretraining on a broad "universe of possible physics."

The Synthetic Prior

Instead of real-world datasets, the model is trained on millions of synthetic environments generated from two distinct priors:

  1. Neural Network Prior: Randomly initialized, untrained neural networks define state transitions. The inherent randomness in weights produces a vast diversity of mathematical behaviors.
  2. Momentum Prior: To ground the model in physical reality, a prior based on basic Newtonian physics (velocity, position, and gravity) is included.
Distributions of samples from the synthetic prior showing the diversity of generated data.

Model Architecture and Training

OSWM utilizes a Transformer architecture trained using the Prior-Fitted Network (PFN) paradigm. During the pretraining phase, the model is fed sequences of synthetic transitions consisting of states and actions. The model must predict masked future states and rewards based solely on the preceding context. This forces the Transformer to learn how to identify underlying dynamics from a sequence of observations.

The OSWM pipeline: sampling synthetic data, pretraining on synthetic sequences, and one-shot inference on real environments.

One-Shot Inference

At test time, the model is presented with 1,000 transitions from a previously unseen real environment (e.g., CartPole). Without any weight updates, the model uses these steps as context to predict future outcomes. An RL agent, such as one using Proximal Policy Optimization (PPO), is then trained entirely within this hallucinated environment generated by OSWM.

Evaluation and Results

We evaluated OSWM across several classic control and custom environments. The results indicate that agents trained in the OSWM-hallucinated environments can achieve performance levels near those of agents trained in real environments for simpler tasks.

Environment OSWM-PPO (Ours) Real PPO (Upper Bound) Random Baseline
GridWorld 5.2 5.2 -14.2
CartPole-v0 196.5 200.0 21.3
Reacher-v4 -10.2 -4.6 -42.8

While OSWM excelled in GridWorld and CartPole, it faced challenges with more complex physics or sparse reward structures, such as MountainCar or Pendulum, where the synthetic priors did not yet provide sufficient coverage of the required dynamics.

Discussion and Conclusion

A key insight from this work is that training on random, untrained neural networks provides a signal rich enough to learn real-world dynamics, suggesting that the space of possible physical behaviors can be effectively approximated by random functions. Additionally, OSWM often produced smoother reward functions than the real environments, which occasionally facilitated easier learning for the RL agents.

Despite its promise, OSWM is currently limited by the complexity ceiling of its synthetic priors and the context window of the Transformer architecture. Future work will focus on developing more sophisticated priors and extending the model's ability to learn termination conditions. OSWM serves as a proof-of-concept for foundation world models that can enable robots and agents to adapt to the real world almost instantaneously.

Summary updated

BibTeX
@inproceedings{ferreira2024one,
  author = {Fabio Ferreira and Moreno Schlageter and Raghu Rajan and Andre Biedenkapp and Frank Hutter},
  title = {{One-shot World Models Using a Transformer Trained on a Synthetic Prior}},
  booktitle = {OWA @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=nzTbSMbRtz},
}
Figure