World Models and Dreamer: how to train a policy in the imagination of a learned world model
In lesson 6.6, the platforms differed in experience: Figure, Agility, AgiBot and Tesla gather it with thousands of hours of human recordings and robot work, which is expensive and slow. Ada has also paid for every skill: the walking policy of lesson 6.1 trained for half an hour on 512 copies in a simulator, and on a real robot every attempt costs minutes of a person's work nearby (lesson 5.7). If you learn from recordings what happens after an action, you can try things out in the imagination of such a model and spend real experience on training and correcting it. In 2018, Ha and Schmidhuber trained an agent to play VizDoom this way; later, PlaNet and Dreamer needed 20–200 times fewer real steps on the same tasks than the best methods that learn only from real steps, and DayDreamer taught a real four-legged robot to walk without a simulator in about an hour. But a policy that learns in imagination finds places where the model is wrong in its favor. In this lesson, Ada learns at night: while charging, she replays the day's recordings, trains a world model on them and practices a skill in its imagination, and in the morning she checks it on the real table.
Experience is expensive: learning from attempts or from a world model
Every skill Ada has in Parts 5 and 6 is paid for with experience. PPO in lesson 5.2 collected millions of steps, the walking policy of lesson 6.1 trained on 512 copies of Ada in a simulator, and in lesson 5.7 a person stood next to the robot and corrected it in every attempt. All the methods of these parts learn only from what the robot actually did: DQN, PPO and SAC don't try to predict what will happen after an action. These are called model-free methods.
Ada is the course's home humanoid; since lesson 6.1, she has legs instead of a wheeled base. More about her and her home in lesson 0.1.
Lesson 5.1 had another path too. Value iteration found the best actions for all the cells of the apartment at once, but it needed an exact model of the environment: where each action leads and what reward it gives. A robot doesn't know such a model, but the model can be learned from recordings. A world model is a learned model that, given a state or a frame and an action, predicts what will happen next. With such a model, a policy can be trained on attempts in its imagination. Step by step, the model predicts what will happen after each action, and the next step is built from its prediction rather than from a real frame; such a chain of predictions is called an imagination rollout. Real experience is then needed to train and correct the model. Reinforcement learning set up this way is called model-based RL.
A world model differs from the models people write. The physics simulator of lesson 4.5 computes the laws of mechanics that engineers put into it. The actuator model in lesson 0.2 and the delta model in lesson 6.3 were already learned from recordings, but they only corrected a simulator: the first reproduced a real actuator, the second the difference between the simulator and the robot. A world model is learned from recordings entirely, so it knows only what was in the recordings.
Ada will try to learn a new skill this way. During the day, the operator carefully moved a cup across the kitchen table with her hand, and Ada recorded how the cup moved after each push. In the evening, Ada steps onto the charging station on her own, like Digit in lessons 6.5 and 6.6, and works with the recordings while she charges.
- The day's recordings. 60 recordings of 3 seconds each. The operator pushed the cup slowly and kept it away from the table's edge, so not a single cup tipped over or fell.
- Night. Ada trains a world model on the recordings and then practices the skill “push the cup to the saucer” only in the imagination of this model.
- Morning. The skill is checked on the real table. Only here can you see where imagination misled Ada.
In 2018, Ha and Schmidhuber showed that an agent can be trained to play entirely in the imagination of a model learned from game frames. Let's start with their model: how is it built?
World Models: V compresses the frame, M predicts, C chooses the action
In CarRacing, a racing game from the Gym task set, the agent sees the track from above as a 64 × 64 pixel frame and acts with steering, gas and brake. A network that outputs an action straight from such frames learns slowly: it has many weights, and the reward tells it about the quality of driving only as a whole. Ha and Schmidhuber split the agent into three parts, gave almost all the complexity to the world model and kept the controller that chooses the action tiny.
- V compresses the frame into a vector z, in CarRacing into 32 numbers. It's a variational autoencoder (VAE): for a frame, the encoder outputs not a single point but a distribution, that is, a mean and a spread, and the decoder learns to reconstruct the frame from numbers drawn from this distribution. We met a conditional version of such a network, the CVAE, in ACT in lesson 1.7.
- M is an LSTM recurrent network with 256 neurons. From z, the action and its memory h, it predicts what z will be at the next step. It predicts not a single value but a mixture of Gaussians, as in lesson 1.3, so it can describe several possible futures. How much randomness to take from this mixture when sampling is set by the model temperature τ.
- C is a linear controller: the action is obtained by multiplying z and h by a weight matrix. It has only 867 parameters, and they're tuned by the CMA-ES evolution strategy: a population of 64 variants, each one drives the track 16 times, and the next generation is built around the best ones. This is also a population search, like ARS in lesson 6.1.
V and M learn without rewards, from 10,000 runs with random actions, and only C knows about the reward. The diagram shows how the three parts work together on the real track and in the model's imagination.
In CarRacing, the task counts as solved if the average score over 100 runs is at least 900. None of the agents on the Gym leaderboard had reached this threshold, and the authors compared their agent with them and with stripped-down versions of itself.
DQN, 343; A3C with continuous actions, 591; A3C with discrete actions, 652; the best result on the Gym leaderboard, 838. The World Models agent whose C sees only z scores 632, with an extra hidden layer in C 788, and with the memory of M 906. Source: D. Ha and J. Schmidhuber, “World Models”, Table 1, arXiv 1803.10122, March 27, 2018.
The task was solved only with the memory of M: without it, the car wobbles, because a single frame doesn't show where it's heading. In CarRacing, though, the controller learned in the real game, and M only gave it memory. In the second task, the authors went further. In VizDoom, the agent has to dodge the monsters' fireballs, and there M also predicts whether the agent will die at the next step. Then M itself becomes the environment: C learns entirely inside it, and the real game is needed only to record the runs for training V and M. The authors call this kind of training a “dream”, and we'll say “in the model's imagination”. In imagination, the agent survived about 900 steps on average, and when transferred to the real game, about 1,100, with the task considered solved at 750.
The model that the controller sees can be wrong, and a long rollout is built from its own predictions. How far ahead can you trust such a model?
Imagination next to the real table: how far ahead you can trust the model
Ada's world model learns right on the page, from the day's recordings: 60 recordings of 60 steps, that is, 3 seconds each. The operator moved Ada's hand no faster than 0.33 m/s and never brought the cup closer than 7 cm to the table's edge, so the recordings contain not a single tip-over and not a single fall. The model consists of five small networks; this is an ensemble, as in lesson 1.2: the networks learn from the same recordings but with different initial randomness. From the cup's position and velocity, the hand's position and its shift per step, each network predicts where the cup will be in 0.05 s and how fast it will be moving. The networks get these numbers, not a camera frame; the frame seen by the camera on Ada's head is shown in the inset next to the scene.
Draw a path for the hand across the table with your finger or mouse so that the hand pushes the cup, and choose the hand's speed. The same push will run side by side on the real table and in the model's imagination, and the model imagines the whole path by itself: at each step it gets its own prediction rather than the real position of the cup. Under the scene, a chart shows by how many centimeters the imagined cup has moved away from the real one by each step and how much the five networks disagree with each other.
Top view of the table; Ada stands at its near edge. Ada's hand is a white circle with graphite fingers, the gray dots are its path. The solid blue path is the cup on the real table, the thin orange dashes are the same cup in the imagination of each of the five networks, the thick orange dashed line is their mean. A red cross means the cup fell off the table, a brown stain means it tipped over.
Legend: marks on the scene
- cup on the real table, solid blue line
- cup in the model's imagination, orange dashes
- hand path, gray dots
- saucer; the green dashes show where the cup counts as on the saucer
- sugar bowl, milk jug: the cup stops against them
- coverage map: cells where the cup was moved in the recordings; red dashes mark cells without recordings
Chart: horizontally, rollout steps of 0.05 s; vertically, centimeters. The red line shows how far the imagined cup (the mean of the five networks) has moved away from the real one, the orange dashes show the spread of the five networks around their mean. The gray line marks 3 cm, the vertical dashed line marks the 10th step.
Under the hood: the table, the recordings, the networks and the imagination rollout
The table. The table is 90 × 60 cm, the cup is a disk of radius 4 cm, the hand is a disk of radius 3 cm. A step lasts 0.05 s and is computed in five substeps. The cup slides and is slowed down by the tablecloth's friction: its speed drops by per second; for the linen tablecloth , varying by ±8% from attempt to attempt. The hand pushes the cup along the line connecting their centers, and the cup gets the hand's velocity along this line with a small random deviation. If the hand hits the cup faster than 0.36 m/s, the cup tips over and the tea is spilled; if the cup's center goes past the table's edge, the cup falls. The cup stops against the sugar bowl and the milk jug. These sizes and thresholds are properties of our table model, not numbers from papers.
The recordings. In each of the 60 recordings, the cup stands at a random spot in the safe part of the table, no closer than 10 cm to the edge. The operator moves it toward random points in this part at speeds from 0.08 to 0.33 m/s, and between pushes the hand just moves near the cup; in no recording does the cup come closer than 7 cm to the table's edge. If a failure happens in a recording, the operator re-records it, so there are no failures in the data.
The networks. A network gets eight numbers as input: where the cup is, its velocity, where the hand is relative to the cup, how close the hand is and how fast the cup is moving. The network outputs and , and the cup's shift and the change in its velocity over a step are , where is the hand's shift. This is how “dynamics plus control” models are built: for a given arrangement, the response is linear in the action. Each network has two hidden layers of 32 neurons with tanh, 1,740 parameters in total; it's trained with 1,800 Adam steps on batches of 32 transitions to minimize the squared prediction error. The networks of the ensemble differ only in their initial weights and the order of transitions. A separate small failure model learns only if there are failures in the data, and the day's recordings have none, so the model considers failures impossible.
The rollout. The model doesn't predict the hand's position: Ada knows where she moves her arm, and in imagination the hand doesn't go into objects or into the cup, just as on the table. Each network runs its own rollout from the same start, getting only its own predictions as input. The divergence on the chart is the distance between the mean of the five imagined cups and the real cup; the spread is the square root of the mean squared distance of the five cups from their mean. In this comparison, the real table has no friction spread, so that the difference comes only from the model. Everything is computed with our own math and a fixed seed, so the numbers are the same in any browser.
On a single step, the model is off by less than a millimeter, but the rollout is built from its own predictions, and the model's error accumulates with the horizon. This is the same error compounding as in behavior cloning in lesson 1.1: each step of imagination starts where the previous error has led it. The error grows fastest where there are no recordings: at the table's edge, the model doesn't know the cup will fall, and with a push faster than Ada pushed during the day, it doesn't know the cup will tip over. Twice as many of the same careful recordings make the model a little more accurate where the recordings already were and change nothing where there are still none. The ensemble's spread grows when the cup moves faster than in the recordings, but at the table's edge the networks hardly disagree, even though there are no recordings there. And not one network notices the tip-over: all five are equally sure that the cup will keep going.
While the model is only being watched, its errors are visible to the eye. What happens if a policy is trained on such a model?
Loopholes in the model: what a policy that learns in imagination finds
The model is wrong where there are few recordings, and it doesn't report this itself. While the model is only used to look ahead, this is tolerable. It's worse when a policy is trained on it: the search for the best actions comes by itself to where the model is wrong in its favor. In lesson 6.1, the policy found a loophole in the reward: it lay down and pushed off the floor with its legs, because the reward counted only forward speed. In lesson 5.6, the Q-function overestimated the value of actions that weren't in the logs, and the policy chose exactly those; we called this optimism outside the data. With a world model, the mechanism is the same: the policy goes where the model is wrong in its favor, that is, it finds a loophole in the model.
Ha and Schmidhuber described this in the section “Cheating the World Model”. In VizDoom, the controller found movements under which the monsters in the model's imagination never fired a single fireball in some of the rollouts. In imagination, the controller sees the whole internal state of M, and the authors compare this to having access to the memory of the game engine. Such a policy looks good in the model but fails in the real game, because it goes into states where the model is wrong: they are far from the data the model learned from.
The defense turned out to be the model temperature. M predicts a mixture of Gaussians, and when sampling from it, τ sets how much randomness to keep: at a low τ the model is almost deterministic, and at a high τ the uncertainty is exaggerated. This is a different concept from the temperature α in SAC from lesson 5.3: there it sets the weight of the bonus for random actions, and here it sets how much randomness there is in the model's predictions. The authors trained the controller in imagination at five different values of τ and checked each one in the real game.
Averages over 100 rollouts at model temperature τ = 0.10: 2,086 steps in imagination and 193 in the real game; τ = 0.50: 2,060 and 196; τ = 1.00: 1,145 and 868; τ = 1.15: 918 and 1,092; τ = 1.30: 732 and 753. A random policy survives 210 steps in the real game, the task is solved at 750, and the best result on the Gym leaderboard is 820. The spread across rollouts is large, up to ±690 steps. Source: D. Ha and J. Schmidhuber, “World Models”, Table 2, arXiv 1803.10122, March 27, 2018.
At a low temperature, the model is sure of a single outcome, and the monsters in imagination don't shoot at all, whatever the agent does. The controller learns that there's nothing to fear, scores almost the highest possible score in imagination, and in the real game survives for less time than a random policy. With noise in the model, the loopholes close: an agent that survived a harder imagined game also plays the real one better, even though its score in imagination is lower. But the noise can't be increased forever: at the highest temperature, the imagined game becomes too hard, and the score drops again.
A year later, Janner et al. asked in their work MBPO (2019) when a model can be trusted and answered with two observations. The model's error accumulates with the rollout horizon, and a model trained on data from one policy is the more wrong, the further a new policy is from the one that collected this data. And the policy takes advantage of these errors. So MBPO trains an ensemble of seven models, takes a random one of them at each rollout step and keeps the rollouts short, starting them from real states in the replay buffer of lesson 5.3. The ensemble's spread, as in lesson 1.2, shows what the model doesn't know. The authors write that “a combination of model ensembles with short model rollouts is sufficient to prevent model exploitation.”
On the Ant task in the MuJoCo simulator, MBPO reaches in 300,000 environment steps what the model-free SAC reaches in 3 million. Long rollouts hurt, though: the authors' model was accurate enough even for rollouts of hundreds of steps, but those trained the policy worse than short ones. Let's check what a policy finds when it learns only in the imagination of the model of Ada's table.
A policy from imagination on the real table
At night, Ada learns to push the cup to the saucer as fast as possible. The policy is simple: the hand goes behind the cup and pushes it toward the saucer, and a few centimeters before the saucer it brakes. The policy has two numbers, the push speed and the distance at which to start braking, and they're found by a population search, like ARS in lesson 6.1: 16 iterations, each with 6 random directions tried both ways, and each variant goes through 8 attempts. All these attempts happen in the imagination of the model from Lab 1, not on the table. The search starts from the way Ada pushed the cup during the day: 0.2 m/s.
The trained policy is checked side by side in two worlds, on the same 50 cup positions: in the model's imagination and on the real table. In imagination, a successful attempt is one in which the cup reached the saucer and the model doesn't expect a failure. On the real table, a successful attempt is one in which the cup stands on the saucer no later than 5 seconds after the start.
Top view of the table, the same attempt in two worlds: in the model's imagination the cup's path is orange and dashed, on the real table it's blue and solid. Under each table are 50 circles, one per attempt: green means the cup is on the saucer, red means it tipped over or fell, gray means it didn't get there within 5 seconds. Click a circle to see that attempt in both worlds.
Under the hood: the policy, the search and what the model knows about failures
The policy. The hand leads the cup to the saucer in a straight line. Until the hand is right behind the cup, it goes around the cup in an arc or approaches a point behind it, covering the last 2 cm no faster than the push. Standing behind the cup, the hand pushes it at speed and shifts sideways little by little to stay behind the cup's center. At before the saucer, the speed smoothly drops to 0.06 m/s, and very close to the saucer the hand lets go of the cup, which coasts the rest of the way. The search changes only and .
The search. ARS tries for 6 random directions , takes the 4 best and shifts by , where is the spread of the scores. The score is the mean over 8 imagined attempts: if the cup got there in steps, , where is the probability that the model doesn't expect a failure; if it didn't get there, is minus the distance to the saucer in meters. The penalty for ensemble spread subtracts from the mean spread of the five networks per step in centimeters, multiplied by the penalty weight.
Imagination. At each step, a random network of the ensemble is chosen, and the next state is , where is the mean prediction of the five networks. At , the model takes the mean and has almost no doubts; at , it takes the prediction of a random network, as MBPO does; at , the disagreement between the networks is doubled. The failure model is a classifier: as soon as failures appear among the transitions in the data, it learns from all the transitions at once; among its features, it also sees how fast the hand is approaching the cup. As long as there are no failures in the data, the probability of a failure in imagination is zero.
The night. Gathering experience gives 10 real attempts: either attempts of the current policy with all their failures, or 10 new careful recordings by the operator in the safe part of the table. Then the model is trained from scratch on all the data, and the search starts from the previous policy. The 50 check attempts on the table are needed only for counting and don't go into training. Everything is computed in the browser with fixed seeds.
The policy from imagination sped the push up beyond anything in the recordings, and the model promised it success: the recordings didn't contain a single example of a fast hit tipping the cup over. This is a loophole in the model of the same kind as the one found by the controller of Ha and Schmidhuber, and the same optimism outside the data as in lesson 5.6. More of the same careful recordings don't close it. What closes it is experience where the policy goes: a dozen failed attempts show the model what failures look like, and the policy from imagination backs off to speeds at which the cup doesn't tip over. This is the very cycle Ha and Schmidhuber proposed for hard tasks: gather experience, train the model, train the policy in imagination and gather experience again.
A policy from imagination wins where the model is wrong, and a long rollout accumulates error with every step. The controller of Ha and Schmidhuber made do with 867 parameters and the memory of M, while hard tasks need a model in which a policy can learn for a long time and look far ahead.
PlaNet and Dreamer: how to build a model in which a policy can learn for a long time, and keep the policy from exploiting it
PlaNet and Dreamer: the latent state and learning in imagination
A single frame doesn't show how fast a robot's link is moving, and with a model you need to look many steps ahead. In PlaNet (2018), Hafner et al. built a model in which the state of the world is stored inside the model itself and updated with every new frame. Such a state is called a latent state: it's what a world model keeps about the world between steps.
The latent state of PlaNet has two parts. The deterministic part h is the memory of a GRU recurrent network with 200 neurons: it carries what happened across many steps. The random part s is a 30-dimensional Gaussian distribution: it describes what the model is unsure of and lets it imagine several possible futures. The authors called a model made of these two parts an RSSM (recurrent state-space model). Without the random part, the PlaNet agent didn't learn at all, and a purely deterministic model, in the authors' words, “makes it easy for the planner to exploit inaccuracies”.
An RSSM step works like the Kalman filter cycle of lesson 0.4. First, the model predicts the new state from the previous state and the action before it has seen the frame, and then it corrects the prediction using the frame that has arrived; the corrected state is the belief of lesson 0.4, a distribution over what the world might be like. The authors directly call their model a non-linear Kalman filter. The difference is that here the weight of the new frame isn't derived from sensor noise: the network itself learns how much to take from the frame. The model is trained to reconstruct the frame and the reward from the latent state and to keep the prediction made without a frame close to the corrected state. In imagination there are no frames, and the rollout runs on predictions alone.
PlaNet searches for actions with the cross-entropy method, CEM, right in the latent space, like MPC in lesson 0.3. The planner draws 1,000 action sequences 12 steps long from a Gaussian distribution, runs them in the model's imagination, keeps the 100 best by the sum of predicted rewards and builds a new distribution from them. After 10 such iterations, the robot executes the first action, and at the next step the plan is built anew. Nobody draws any pictures along the way; everything is computed in the latent space. On six DeepMind Control tasks, PlaNet needed on average 200 times fewer episodes than the model-free D4PG for a similar score. But PlaNet doesn't see rewards beyond the planning horizon.
Dreamer (2019) takes the same model and trains an actor and critic in its imagination, as in lesson 5.2. Imagined rollouts 15 steps long start from real states recorded in the buffer. The critic learns to estimate the value of states (lesson 5.1) and looks beyond the rollout's horizon through the λ-return: a weighted average of estimates, in each of which the rewards for k imagined steps are summed first and then the value output by the critic is added. The actor improves by the gradient of this value, which flows back through the learned model. The model itself doesn't change meanwhile: it's trained separately, on real data.
Dreamer alternates the three processes from the diagram: it collects new experience with the actor in the environment, trains the world model on the buffer and trains the actor and critic in imagination. This is the same cycle of “gather experience, train the model, train the policy in imagination” that closed the loophole in Ada's model in Lab 2. How much experience it saves can be seen on 20 DeepMind Control tasks.
The model-free A3C, from joint positions, and D4PG, from frames, trained for 10⁸ environment steps each, PlaNet and Dreamer, from frames, for 5 × 10⁶: A3C, 243.70; D4PG, 786.32; PlaNet, 332.97; Dreamer, 823.39. Dreamer took about 3 hours per million steps on a single V100 GPU, PlaNet with planning at every step 11 hours, and D4PG 24 hours to reach a comparable score. Source: D. Hafner, T. Lillicrap, J. Ba and M. Norouzi, “Dream to Control”, Appendix G and Section 6, arXiv 1912.01603, December 3, 2019.
Dreamer scored more than the best model-free agent while using 20 times fewer environment steps, and it also learned faster in wall-clock hours. A short imagination horizon didn't make the agent shortsighted: without the critic, the agent coped only with tasks where a quick reaction is enough, and with the critic it hardly depended on the rollout length.
DreamerV2 (2020) replaced the Gaussian distribution in the random part with 32 discrete variables of 32 values each and for the first time brought learning in imagination to human level on Atari games. Its policy had 10,000 times more imagined states than real frames, and the model relied on reconstructing frames: without this signal, the agent learned almost nothing. DreamerV3 (2023; in the journal Nature in 2025) made learning robust to the scale of rewards and observations and, with the same settings, solved more than 150 tasks in 8 different domains, from Atari to controlling robots in simulation. In the comparison from frames, the authors put it next to model-free methods.
Control from frames after a million steps: PPO, 206; SAC, 226; CURL, 525; DrQ-v2, 705; DreamerV3, 786. In Table 12 of the paper, the row labels “Task mean” and “Task median” are swapped; here are the means recomputed from the rows of the tasks. Source: D. Hafner, J. Pasukonis, J. Ba and T. Lillicrap, “Mastering Diverse Domains through World Models”, Table 12, arXiv 2301.04104, January 10, 2023 (journal version: Nature 640, April 2, 2025).
From frames, DreamerV3 beat both PPO from lesson 5.2 and SAC from lesson 5.3, and SAC, in the authors' words, “requires tuning, especially for its entropy scale, and struggles under high-dimensional inputs”. In Minecraft, DreamerV3 found diamonds from scratch, without human recordings, on a single GPU in 9 days, even though a diamond turned up in only 0.4% of episodes.
Under the hood: the RSSM formulas and the λ-return
RSSM. The deterministic part is updated by a recurrent network, and the random part is predicted without a frame and corrected using the frame :
In the second line, the model predicts the state without a frame; in the third, it corrects it using the frame. The model is trained on segments from the buffer: the decoder reconstructs the frame and the reward from , and the Kullback–Leibler divergence between the corrected and the predicted distributions keeps the prediction close to the correction. PlaNet and Dreamer don't penalize the first 3 nats of this divergence (free nats), so that the model doesn't sacrifice frame reconstruction. In imagination there's no , and is taken from .
λ-return. Let be the critic's value, the discount and the imagination horizon. The -step estimate sums the imagined rewards and the value at the end, and the λ-return mixes estimates of different lengths:
Short estimates are biased because they rely on the critic; long ones are noisy because they rely on imagined rewards; λ balances the two. In Dreamer, , , . The critic learns to approximate , and the actor maximizes the sum of along the rollout.
CEM in PlaNet.
DayDreamer: Dreamer on real robots without a simulator
All the tasks discussed so far were solved in simulators and games. Ada was also taught to walk in a simulator in lesson 6.1, and the finished policy was transferred to the robot, while the sim-to-real gap was closed with randomization and an actuator model in lesson 5.4 and with a delta model in lesson 6.3. In DayDreamer (2022), Wu, Escontrela, Hafner et al. went another way: they took Dreamer without changes to the algorithm and ran it directly on four real robots, without a simulator and without demonstrations. While the robot moves, one thread trains the world model, the actor and the critic, and another one outputs actions.
The four-legged Unitree A1 started out lying on its back and had to learn to roll over, stand up and walk forward; its motors received target angles for PD controllers 20 times a second. Once A1 had learned to walk, it was knocked with a pole, and it adapted to withstand the pushes or quickly get back on its feet. In the same time, SAC learned only to roll over. People were still nearby, though: they stepped in when the robot reached the edge of the area.
A1 rolls over from its back after 5 minutes of training, stands up 20 minutes later, walks forward after about an hour, and in 10 minutes of fine-tuning after that learns to withstand pushes with a pole; on the first chart, the minutes are counted from the start of training, and we added up 25 and 70 ourselves. The second chart shows the hours of training of the four robots: A1, about an hour; the UR5 arm, 8 hours to 2.5 balls per minute; the XArm arm, 10 hours to 3.1 soft objects per minute, which is comparable to a human; and the wheeled Sphero, 2 hours to reach a goal given by an image. Source: P. Wu, A. Escontrela, D. Hafner, K. Goldberg and P. Abbeel, “DayDreamer”, Section 3, arXiv 2206.14176, June 28, 2022.
A1 mastered walking in an hour of its own experience, while before, as the authors write, walking “required extensive training in simulation followed by transfer to the real world”. The arms took longer to learn because they rarely received a reward: the UR5 learned almost nothing in the first two hours. Rainbow and PPO on the same tasks learned only to grab a ball and immediately drop it into the same bin. On Sphero, a small wheeled robot, Dreamer didn't beat the model-free DrQv2: learning with a world model doesn't win everywhere.
The model made mistakes here too: in an imagined rollout of the UR5, a static orange ball turned into a green one. The authors also write about the cost of hours on real hardware: over many hours of training, the robot wears out and needs people and repairs. The DayDreamer cycle is the same as in Lab 2: the robot gathers experience where the current policy takes it, the model learns from this experience, and the policy learns in the model's imagination.
MuZero and TD-MPC2: a world model without reconstructing the frame
Dreamer's models learn to reconstruct every frame. This gives a lot of learning signal but makes the model spend effort on details that aren't needed for acting. Another line of work trains the model to predict only what's needed to choose an action.
MuZero (Schrittwieser et al., DeepMind, 2019) trains a model that, from a hidden state and an action, predicts the reward, the value and which action to choose, and doesn't reconstruct the frame at all: the hidden state doesn't have to match the real state of the game. MuZero builds a search tree over this model, like AlphaZero. In Go, chess and shogi, MuZero, without knowing the rules, played at the level of AlphaZero, which was given the rules, and on Atari it beat the model-free R2D2 in most games.
TD-MPC2 (Hansen, Su and Wang, 2023) carries this approach over to continuous control. A model without a decoder predicts the next latent state, the reward and the action value, and actions are chosen by a planner that looks 3 steps ahead and adds a value estimate at the end, like the MPC of lesson 0.3, only over a learned model. With a single set of settings, TD-MPC2 solved 104 tasks in four suites, from DeepMind Control to manipulation in Meta-World, and a single agent on 80 tasks got better with the model's size.
The model with 1 million parameters scores 16.0; with 5 million, 49.5; with 19 million, 57.1; with 48 million, 68.0; with 317 million, 70.6. The largest model trained for 33 days on a single RTX 3090 GPU. Source: N. Hansen, H. Su and X. Wang, “TD-MPC2: Scalable, Robust World Models for Continuous Control”, Table 1, arXiv 2310.16828, October 25, 2023.
The authors saw no saturation: the score grew with the model's size up to the largest one. They also note that DreamerV3 struggles with tasks of fine manipulation: lifting, picking up, stacking. But Dreamer can't do without reconstructing the frame either: without the gradients from reconstruction, DreamerV2 learns almost nothing, and DreamerV3, in the authors' words, “rests predominantly on the unsupervised objective of its world model”. Whether to reconstruct the frame or not is one of the main choices in designing a world model. What are Dreamer and its successors doing in 2025–2026?
Today: Dreamer 4, a theory of learning in imagination and what remains open
The journal version of DreamerV3 came out in Nature on April 2, 2025. The next step was taken by Dreamer 4 (Hafner, Yan and Lillicrap, Google DeepMind, September 2025): the agent learns only from recordings, without a single attempt in the game, like the offline RL of lesson 5.6. The world model is a transformer trained on 2,541 hours of recordings of people playing Minecraft. On a single GPU, it responds faster than the game runs, but it remembers only the last 9.6 seconds. First, the agent is trained on the recordings to imitate the players and predict the reward, and then it's improved with reinforcement learning entirely in the model's imagination.
Before learning in imagination (the agent imitates the players using the world model) and after it: stone pickaxe, 89.4 and 90.1%; iron ore, 62.9 and 66.7%; furnace, 51.1 and 58.1%; iron ingot, 27.8 and 39.5%; iron pickaxe, 16.9 and 29.0%; diamond, 0 and 0.7%. 1,000 episodes an hour long each, starting with an empty inventory. Source: D. Hafner, W. Yan and T. Lillicrap, “Training Agents Inside of Scalable World Models”, Table 7, arXiv 2509.24527, September 29, 2025.
Learning in imagination adds more the harder the milestone, and for the first time it yields diamonds without interacting with the game, though in a very small share of episodes. The authors also show a robot: in a model trained on robot video with actions, an operator steers the imagined robot, picks up objects and flips a bowl. No agent was trained for the robot in this work.
In 2026, a theory appeared of how the model's errors turn into the policy's errors. Timor, Shwartz-Ziv, Goldblum, LeCun and Harel (Weizmann Institute, NYU, Columbia and AMI Labs, May 2026) bounded how much the expected return of a policy in imagination can differ from the real one. The error of the dynamics model enters this difference with a factor that grows with the horizon and with how much the model and the policy stretch small deviations. A systematic bias of the learned reward doesn't disappear, however many imagined rollouts you average. The bounds themselves turned out to be conservative: in a numerical check, at the median they were 65 times larger than the actual difference.
The survey “Quo Vadis, World Modeling?” (Shanghai AI Laboratory, Zhejiang University and NUS, August 2026) names the same thing as the main missing piece: errors compound over long rollouts, and what's needed is “calibrated uncertainty, not just sharper pixels”. An agent has to understand when to trust the model and when to return to the real world, or it fails silently. In the labs of this lesson, you could see this on Ada's table: the ensemble noticed unfamiliar speeds, hardly disagreed at the table's edge and didn't predict the tip-over that no network had ever seen.
The models in this lesson work with a state or with small frames. The 1X world model from lesson 6.6 is a video model with 14 billion parameters trained on hundreds of hours of human video. How a world model can avoid spending effort on every pixel, learn from video without actions and output actions itself is what lessons 7.2–7.4 are about.
Eight common misconceptions
Lesson takeaways
- Model-free methods learn only from real attempts. A world model learned from recordings lets you train a policy on rollouts in imagination and spend real experience on the model itself: PlaNet, Dreamer and MBPO made do with 10–200 times fewer real steps.
- In World Models, V compresses the frame into a vector, M predicts the next one, and the tiny controller C learns to act; in VizDoom, the controller learned entirely in the model's imagination.
- The model's error accumulates with the rollout horizon, and fastest where there are no recordings. More of the same recordings make the model more accurate where it was already accurate.
- A policy in imagination finds loopholes in the model, places where the model is wrong in its favor, like Ada with the fast push in Lab 2. The defenses are noise in the model, an ensemble and a penalty for its spread, short rollouts from real states, and above all experience where the policy goes.
- An RSSM keeps a latent state made of memory and a random part and takes the step “prediction without a frame, correction using the frame”, like a Kalman filter; Dreamer trains the actor and critic entirely in imagination and looks beyond the horizon through the λ-return, and DayDreamer taught A1 to walk in about an hour without a simulator.
- MuZero and TD-MPC2 do without reconstructing the frame, and Dreamer 4 learns only from recordings. What remains open is how a model can know where it's wrong: it needs calibrated uncertainty, not sharper frames.
Open questions
How can a model tell what it doesn't know?
Ada's ensemble noticed unfamiliar speeds, but not the table's edge and not the tip-over, which wasn't in a single recording. How can a world model estimate the probability of an event it has never seen, and should a robot fail on purpose for this when a failure is expensive: a broken cup, a fallen robot?
How much real experience is needed before a model can be trusted?
In Lab 2, a dozen real attempts closed one loophole, and then the policy crept up again to the edge of what the model had seen. How do you tell that enough experience has been gathered and that a new policy hasn't found a loophole that isn't in the data yet?
Paper guide
- Read closelyThe section on how behavior is learned in imagination: where the imagined rollouts start and how the actor, the critic and the λ-return work (equations 4–8). Figure 4, which compares imagination horizons, and the table in Appendix G.
- Safe to skipThe comparison of three ways to learn the representation, if you're interested in the algorithm itself: frame reconstruction turned out best in the experiments. The details of discrete actions for Atari.
- Question to keep in mindDreamer passes the value gradient through the learned model, while DreamerV2 on Atari switched to the policy gradient, as in lesson 5.2. Why might a gradient through the model work worse for discrete actions?
Other works in this lesson: World Models (Ha and Schmidhuber, 2018), with V, M and C and the section on loopholes in the model; PlaNet (Hafner et al., 2018), with the RSSM and CEM; MBPO (Janner et al., 2019), on when to trust a model; DreamerV2 (2020) and DreamerV3 in Nature (2025); DayDreamer (Wu, Escontrela, Hafner et al., 2022), with robots without a simulator; MuZero (2019) and TD-MPC2 (2023), without reconstructing the frame; Dreamer 4 (2025), with learning only from recordings.
Resources
- World Models in the browserAn interactive version of Ha and Schmidhuber's paper with demos
- DayDreamerVideos of A1, UR5, XArm and Sphero learning without a simulator
- On Training in ImaginationA 2026 theory of how errors of the model and the reward turn into the policy's error
- Quo Vadis, World Modeling?A 2026 survey of what world models are missing
The models in this lesson learn by reconstructing every frame. The VAE in World Models drew the brick pattern on the walls in Doom but lost the road markings in CarRacing, and in Video Pinball the ball takes up a single pixel, and on this game DreamerV2 loses to model-free methods. The model spends effort on details that don't help it act and misses what matters.
Lesson 7.2 · JEPA and V-JEPA 2: how to predict representations instead of pixels and plan with them