Paper commentary
Mastering Diverse Domains through World Models
Dreamer learns one configuration that works across many diverse domains
- Problem Reinforcement learning algorithms usually need retuning for each new domain. That takes expertise, experimentation and compute, which makes them costly to use on expensive tasks.
- Method Dreamer learns a world model of the environment and improves its behavior by imagining future scenarios. Robustness techniques based on normalization, balancing and transformations keep learning stable across domains with one fixed configuration.
- Results Dreamer outperforms specialized methods across over 150 tasks with a single configuration. It is the first algorithm to collect diamonds in Minecraft from scratch, after 100M environment steps.
Why retuning blocks general reinforcement learning
Specialized reinforcement learning methods are usually tuned for the domain they were built for. Moving to a new task, such as from video games to robotics, typically requires more hyperparameter work, expertise and computation, and this makes learning expensive models or tasks where tuning is costly impractical.
Dreamer aims to remove this retuning by keeping one configuration across domains. Its design rests on learning a world model that gives the agent perception and the ability to imagine the consequences of actions, with a critic scoring those imagined outcomes and an actor selecting actions that lead to the best ones. Learning such a model robustly has been an open problem, and the paper's answer is a set of techniques based on normalization, balancing and transformations.
These techniques are tested over more than 150 tasks from the domains shown in the paper's figures, and across model sizes and training budgets.
How the world model is trained
The world model is a Recurrent State-Space Model. An encoder maps each sensory input x_t to a stochastic representation z_t, and a sequence model with a recurrent state h_t predicts the sequence of representations from past actions. The recurrent update is \( h_t = f_\phi(h_{t-1}, z_{t-1}, a_{t-1}) \), and the encoder is \( z_t \sim q_\phi(z_t \mid h_t, x_t) \).
The pair h_t and z_t forms the model state, from which rewards r_t, continuation flags c_t and the reconstructed inputs are predicted.
The three world model losses are weighted by \( \beta_{pred}=1 \), \( \beta_{dyn}=1 \) and \( \beta_{rep}=0.1 \). The prediction loss trains the decoder and reward predictor with a symlog squared loss and the continue predictor with logistic regression. The dynamics loss pulls the sequence model's prediction toward the next posterior representation, with a stop-gradient on the posterior.
The representation loss has the stop-gradient on the prior instead, so it makes the representations easier to predict. The two losses differ in where the stop-gradient sits and in their scale.
Free bits prevent a trivial solution in which the dynamics are easy to predict but carry too little information about the inputs. The dynamics and representation KL terms are clipped below 1 nat, which is about 1.44 bits, so they stop contributing once they are already small and the learning focuses on the prediction loss. Earlier world models needed a different representation loss scale for each visual complexity level.
Combining free bits with a small representation loss is the paper's way of keeping one scale across domains, and symlog transforms of vector observations limit the size of inputs and reconstruction gradients. The encoder and dynamics categorical distributions are mixtures of 1% uniform and 99% network output. This keeps them from becoming deterministic and keeps the KL losses well behaved.
Critic and actor learning on imagined trajectories
The actor and critic learn only from imagined trajectories of model states s_t = {h_t, z_t}, and the agent acts by sampling from the actor without lookahead planning. Returns are discounted with \( \gamma = 0.997 \), and the critic's reward horizon for imagined trajectories is T = 16. Bootstrapped λ-returns combine predicted rewards and predicted values so the critic can see rewards beyond the imagined horizon.
They follow \( R^\lambda_t = r_t + \gamma c_t((1-\lambda)v_t + \lambda R^\lambda_{t+1}) \), with \( R^\lambda_T = v_T \), and the critic is fitted to them with a maximum likelihood loss.
The critic is a categorical distribution over exponentially spaced bins rather than a Normal, since returns can be multi-modal and differ by orders of magnitude between environments. Its value readout is the expectation of that distribution. The critic loss is applied to imagined trajectories with scale 1 and to replay trajectories with scale 0.3.
For replay, the imagined returns at the start states serve as value annotations, and λ-returns are then computed over the replayed rewards. The critic is regularized toward an exponential moving average of its own parameters, which plays the role of target networks while still letting returns use the current critic. The output weights of the reward predictor and critic start at zero, which the authors found reduces the early delay caused by large random predictions.
Dividing by the range S only scales large return magnitudes down, since returns below the threshold of 1 are left unchanged. Substracting an offset does not change the actor gradient, so only the range matters here. The range S is the 5th to 95th return percentile difference over the return batch, smoothed with an exponential moving average using the value 0.99.
The percentile range avoids letting a few outlier returns set the scale, which the minimum and maximum would do.
Symlog transforms and symexp twohot predictions
A squared loss on large targets can diverge, while absolute and Huber losses stagnate, and normalizing targets with running statistics makes the optimization non-stationary. The paper therefore predicts a transformed target and maps the output back with an inverse.
For stochastic targets such as rewards and returns, the network outputs logits for a softmax over bins that are exponentially spaced, from symexp of −20 to +20. The prediction is the probability-weighted average of the bin positions, so it can fall between bins. The target is twohot encoded: the two bins adjacent to the value get weights that sum to one, with the nearer bin weighted more.
The network is trained with categorical cross entropy on these soft targets, so the gradient depends on bin probabilities and not on the size of the target.
For critic learning, an asymmetric transformation proposed earlier was found by the authors to be less effective on average across domains. The symlog approach avoids truncating large targets and avoids non-stationarity from normalization or from adjusting network weights when new extreme values appear.
Benchmark results against tuned experts and PPO
Each Dreamer agent was trained on a single Nvidia A100 GPU. The authors report that Dreamer substantially outperforms PPO across all domains.
On Atari, which has 57 Atari 2600 games and a budget of 200M frames under the sticky action setting, Dreamer outperforms MuZero, Rainbow and IQN, and the authors note it does so with a fraction of the computational resources MuZero uses. On ProcGen, with 16 games and a 50M-frame budget, Dreamer matches the tuned expert PPG and outperforms Rainbow, and the authors' fixed-hyperparameter PPO matches the published PPO score on ProcGen.
On DMLab, with 30 tasks, Dreamer uses 100M frames and exceeds the performance of IMPALA and R2D2+ at 1B environment steps. The authors give this as a data-efficiency gain of over 1000%, and note that those baselines were not designed for data efficiency. On Proprio Control, with 18 continuous control tasks and a 500K-step budget, Dreamer sets a new state of the art over D4PG, DMPO and MPO.
On Visual Control, with 20 tasks and a 1M-step budget, it outperforms DrQ-v2 and CURL, which are specialized for visual environments and use data augmentation.
On BSuite, with 23 environments and 468 configurations, Dreamer outperforms Boot DQN and other methods, with the largest gains in the scale robustness category.
Diamond collection in Minecraft
Each episode is a random, infinite 3D world and lasts up to 36000 steps, about 30 minutes, during which the agent must obtain a sequence of 12 items from sparse rewards. The authors follow the block breaking setting of prior work because the provided action space makes it hard for stochastic policies to hold a key down.
All Dreamer agents trained on Minecraft discover diamonds within 100M environment steps. Previous approaches that used human data or adaptive curricula did not reach the diamond in the authors' comparison; Figure 5 shows strong baselines progressing up to the iron pickaxe without finding a diamond. The authors describe VPT as requiring human data for this result, so the Dreamer run differs from VPT in its data source.
VPT used behavioral cloning on contractor keyboard and mouse data, followed by reinforcement learning, with 720 GPUs for 9 days. Dreamer uses the MineRL competition action space and learns from sparse rewards with 1 GPU for 9 days and no human data. These are two different methods on different data and compute budgets, so the comparison is about resources and not a controlled experiment.
What drives performance: ablations and scaling
The ablation covers 14 tasks and removes the symlog transform of observations, return normalization, the symexp twohot regression and the KL balancing with free bits, one at a time. Removing each technique lowers average return, and the largest drop comes from removing the KL balancing and free bits. Return normalization and symexp twohot regression follow in importance.
The authors add that each technique is critical on some tasks and may not affect others, so the average result does not mean every task needs every technique.
To test the learning signals, the authors stop either the reward and value gradients or the reconstruction gradients from shaping the representations. Performance depends predominantly on the reconstruction gradients, which the authors contrast with prior algorithms that rely mainly on task-specific reward and value gradients. The authors suggest that this points to variants that use pretraining on unsupervised data, though this is their interpretation and was not tested in the paper.
For scaling, the authors train 6 model sizes from 12M to 400M parameters and vary the replay ratio on Crafter and one DMLab task. The replay ratio sets how many gradient updates the agent performs. Larger models score higher and need less environment interaction to reach the same behavior, and more gradient steps reduce the interactions needed.
The authors describe this as a way to trade more compute for better performance.
Limitations
The Atari100k comparison with EfficientZero is hard to read because EfficientZero resets levels early and relies on online tree search, while Dreamer does not. The Minecraft result uses the block breaking setting and default hyperparameters, and only the diamond task is reported for Minecraft.
The scaling study covers Crafter and one DMLab task, so the model size and replay ratio trends are not tested on the other domains. The DMLab baselines were not designed for data efficiency, so the reported gain compares a data-efficient agent with scalable baselines at a much larger step count.
Paper info
- Authors
- Danijar Hafner, Jurgis Pasukonis, Jimmy Ba, Timothy Lillicrap
- Venue
- arXiv · Preprint
- First published
- 2023-1-10
- Added
- 2026-11-12
- Updated
- 2024-4-17
- Version
- v2
- arXiv
- 2301.04104
- Category
- cs.AI · cs.LG · stat.ML
- Original paper terms
- CC BY 4.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Danijar Hafner, Jurgis Pasukonis, Jimmy Ba, Timothy Lillicrap (2023). Mastering Diverse Domains through World Models. arXiv:2301.04104v2. https://arxiv.org/abs/2301.04104v2
BibTeX
@misc{hafner2023mastering,
title = {{Mastering Diverse Domains through World Models}},
author = {Danijar Hafner and Jurgis Pasukonis and Jimmy Ba and Timothy Lillicrap},
year = {2023},
eprint = {2301.04104},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2301.04104v2}
}