TL;DR
World Models is an agent with three parts: a vision model that compresses each frame into a small latent vector, a recurrent memory model that predicts the next latent, and a small controller that picks actions from both. The first two are trained without reward signals, so most of the agent's complexity lives in the world model. The controller is so small that an evolution strategy can train it.
Where you'll see it: model-based RL in pixel environments, where a learned latent model is used to plan or to generate practice episodes.
The problem
Model-free reinforcement learning methods of the time used small networks, with roughly to parameters according to the paper, because the credit assignment problem makes it hard to learn the millions of weights of a large model from reward alone. The authors want to train large recurrent models efficiently, and they note that backpropagation can train large networks well when the loss is differentiable.
The paper argues that the agent should learn a predictive model of its world from observations, without rewards, using ordinary gradient descent. Only a small policy should then be trained against reward, which can be done with an optimizer that does not need gradients through the whole environment.
Key idea
Divide the agent into a large world model and a small controller. The world model learns to compress what the agent sees and to predict what comes next, given the agent's action. The controller maps the compressed present and the model's memory to an action, and it is trained only on the reward.
The paper offers a human analogy. A batter hitting a fastball does not simulate the pitch step by step before swinging. Their trained prediction of the ball's path drives a fast reflex. The controller is meant to be that reflex, and the world model is the learned prediction underneath it.
The method
The agent has three components, called V (vision), M (memory) and C (controller).
V: a VAE for each frame
The vision model is a variational autoencoder (VAE). It compresses each image frame into a low-dimensional latent vector , and it is trained to reconstruct the frame from . The car-racing agent uses , and the VizDoom agent uses . The VAE uses a Gaussian latent, so its encodings carry a measure of uncertainty.
M: an MDN-RNN for the future
The memory model is a recurrent network with a mixture density output. It models the distribution of the next latent given the current latent, the action and its hidden state:
The output is a mixture of Gaussians rather than a single prediction, which lets it represent several possible futures. The paper uses a temperature parameter when sampling from the mixture. Raising makes the sampled futures more random, and it is later used to control the difficulty of the simulated environment. The model's hidden state summarizes the past, and in the car-racing experiment it carries the information the controller uses to anticipate upcoming turns.
For the VizDoom experiment the same RNN also predicts a binary flag for whether the agent dies on the next step. With this flag, the model can stand in for a full environment.
C: a linear controller
The controller is a single linear map from the latent and the hidden state to an action:
The paper keeps C deliberately small, so that most of the agent's complexity lives in V and M. The car-racing controller has 867 parameters, and the VizDoom controller has 1,088. Because C is so small, the paper optimizes it with CMA-ES, an evolution strategy, which needs only the final cumulative reward of each rollout rather than gradients through the environment. The rollouts can run in parallel on CPU cores.
Training procedure
The agent is trained in three stages.
- Collect 10,000 rollouts from a random policy.
- Train V on the frames, then use V to encode every frame and train M to predict the sequence of latents.
- Optimize C with CMA-ES to maximize the expected cumulative reward, using rollouts of the agent in the environment (for car racing) or in the model's own hallucinated environment (for VizDoom).
Worked examples
Example 1: size of the controller (from the paper's parameter tables). In the car-racing agent, the controller has 867 parameters, against 4,348,547 for the VAE and 422,368 for the MDN-RNN.
- Total parameters of V and M: .
- Controller fraction: .
Interpretation: almost all parameters are in the unsupervised world model, and the reward-trained part is tiny. This is why CMA-ES, which scales poorly to large parameter counts, is a practical choice for C.
Example 2: a hand computation of a mixture density output (illustrative). Suppose the MDN outputs two Gaussians with weights and , means and , and both standard deviations are 1. The predicted density at is
- Component 1: .
- Component 2: .
- Sum: .
Interpretation: a mixture can put probability on distinct outcomes, such as a fireball being shot or not, which a single Gaussian cannot do.
Example 3: temperature (values from the paper's Table 2). At the virtual environment score is 2086 but the actual score is 193. At the virtual score falls to 918 and the actual score rises to 1092. The paper's reading is that a sharper model, at low temperature, lets the controller exploit the model's errors, and a noisier model keeps the controller from doing so.
Results
Every number below comes from the paper's text or tables.
Car racing (CarRacing-v0). The task counts as solved at an average reward of 900 over 100 consecutive trials. The results in Table 1 are:
| Method | Average score |
|---|---|
| DQN | 343 ± 18 |
| A3C (continuous) | 591 ± 45 |
| A3C (discrete) | 652 ± 10 |
| Gym leaderboard entry | 838 ± 11 |
| V model only (controller sees only ) | 632 ± 251 |
| V model with a hidden layer | 788 ± 141 |
| Full world model (V, M and C) | 906 ± 21 |
The full agent scores 906 ± 21 over 100 random trials. The paper reports this as solving the task and as a new state of the art over the methods listed. Giving the controller the hidden state as well as makes the driving stable, and the paper argues the agent does not need to plan ahead, since already encodes the predicted future.
VizDoom "Take Cover". The agent avoids fireballs shot by monsters. The cumulative reward is the number of survival steps, with a maximum of 2100 steps, and the task counts as solved at an average of more than 750 steps over 100 rollouts. The controller learns inside the model's dream, scoring about 900 steps there. When the policy is transferred to the real environment, it scores about 1100 steps over 100 trials, which the paper reports as beyond the solved threshold.
Temperature and exploitation (Table 2). Training in the dream at several temperatures gives:
| Temperature | Virtual score | Actual score |
|---|---|---|
| 0.10 | 2086 ± 140 | 193 ± 58 |
| 0.50 | 2060 ± 277 | 196 ± 50 |
| 1.00 | 1145 ± 690 | 868 ± 511 |
| 1.15 | 918 ± 546 | 1092 ± 556 |
| 1.30 | 732 ± 269 | 753 ± 139 |
Random policy: 210 ± 108 on the actual environment. Gym leader: 820 ± 58. The paper reports that at the dream's monsters stop shooting, which lets the controller reach a near-perfect dream score that does not transfer. Higher temperature makes the dream harder and reduces this exploitation, but too much makes learning fail, so is a hyperparameter to tune.
Limitations the paper reports. The VAE reproduces unimportant detail, such as wall brick patterns in Doom, but misses task-relevant road tiles in Car Racing, because it is trained without the task. The world model has limited capacity, and an LSTM may not hold all recorded experience. The controller can exploit errors in the model, and the paper notes that a deterministic model is especially easy to exploit.
Why it mattered
The paper shows that a large unsupervised predictive model can be trained from pixels, and that a small controller trained by evolution on top of its features can solve two pixel tasks. It shows that a policy trained only inside the learned model can transfer to the real environment in the VizDoom experiment. It also describes the failure mode of exploitation and the use of temperature as a control.
The paper's discussion gives its own research directions: iterative training that gathers new data to improve the model, and curiosity-driven exploration by flipping the sign of the model's loss in the real environment.
Reading guide
Read the paper in this order and use these lessons for the sections that need them.
- Introduction (Section 1): World Model for the idea of a predictive model of an environment, and Reinforcement Learning for the agent setting. Model-Based Reinforcement Learning gives the wider context.
- Agent model (Section 2): Variational Autoencoder for the V model, Recurrent Neural Network and Long Short-Term Memory for the memory model, and Mixture Density Network for the output layer of M. Gaussian (Normal) Distribution covers the Gaussian mixture components.
- Car racing (Section 3): Generative Model for why modeling observations is useful, and Self-Supervised Learning for training V and M without rewards. Evolution Strategies explains how C is optimized.
- VizDoom and temperature (Section 4): Softmax Temperature for the temperature parameter used to sample from the mixture, and Policy Gradient for the gradient-based alternative to evolution, which the paper's motivation contrasts with its choice of CMA-ES.
- Iterative training and discussion (Sections 5 and 7): no new prerequisites beyond the above.