Skip to content
The Daily Triptych231 / 365
The three components, and the loop that becomes a dream

Vision compresses each frame to a short code. Memory predicts the next code from the current one plus the chosen action. The controller reads both and acts. Close the loop from Memory back to itself, without a real frame, and the agent is practising inside its own model.

II · THE IDEA · ARTIFICIAL INTELLIGENCE

World Models: Planning Inside a Learned Simulator

model-based reinforcement learning · arXiv 1803.10122; arXiv 1909.12255 · CarRacing-v0, VizDoom Take Cover

▶ Listen · narrated

Model-free agents pay for every lesson with a real step in the real world. An agent that rehearses inside a learned copy of its world pays almost nothing — provided the copy tells the truth.

At a glance

Three parts
Vision, memory, controller — trained separately
Compression
Each frame reduced to a short code of 32 numbers
Memory
A recurrent network predicting the next code
Controller
Tiny: a single linear layer over code plus hidden state
Search method
CMA-ES, an evolution strategy, applied to the controller
Related finding
Value tables in many tasks are close to low-rank

A driver who has never raced a track can study it from the passenger seat, then run the lap in their head before taking the wheel. The imagined lap costs nothing, so you can run it a thousand times. The trouble is that the track in your head is not the track, and if you rehearse long enough you will eventually find a corner that only works in your imagination.

The system in this lesson does three things in order. First, it learns to squash each video frame down to a short list of 32 numbers, keeping only what matters — 32 numbers instead of a whole screen of pixels. Second, it learns to predict: given those numbers and the action taken next, what will the next list be? Chain those predictions together, each one feeding the next, and the agent has a rough, playable copy of the game running inside itself.

The part that actually chooses actions is kept deliberately tiny, so it can be trained by plain trial and error: try many settings, keep the ones that score well, repeat. And because the inner copy of the game exists, that training can happen entirely inside it. The finished player is then dropped into the real game, where it works.

The catch is the interesting bit. When the inner copy was made too confident — too smooth and certain about what came next — the agent stopped learning the game and started learning the copy's mistakes. It found moves that made the copy's dangers vanish, moves that did nothing in the real game. The fix was to make the copy admit more doubt, letting its predictions vary, so that no single mistake repeated often enough to be worth exploiting.

Look closer

  1. The dream has a temperature dial

    The memory network does not commit to one future. It predicts a spread of possible next codes with weights on each, and a temperature setting controls how widely samples are drawn from that spread. Set it low and the dream becomes confident and smooth, and the paper reports that an agent trained there learned to exploit the simulator's own flaws rather than the game's rules. Raise it and the dream becomes noisier and harder to cheat, and a policy that survives it transfers better to the real environment. The dial is a deliberate defence against a learned model's blind spots.

  2. The controller is smaller than you expect

    Almost all the parameters sit in the vision and memory networks, which learn from recorded experience without any reward signal at all. What actually chooses actions is a single linear layer reading the current compressed code together with the memory's hidden state. Because that layer holds so few parameters, it can be optimised by an evolution strategy, a method that tries many parameter settings and keeps the ones that score well, with no gradients passing back through the environment. Understanding the world and acting on it are deliberately separated.

  3. Structure hiding in the value table

    A separate line of work looks at the value function, the table that records how good each state, or each state-and-action pair, is. Arranged as a matrix, those tables in many standard tasks turn out to be approximately low-rank: most of the information is carried by a handful of underlying patterns rather than every entry standing alone. That is a claim about redundancy in the environment itself, and it hints at why a compact world model can work at all. If the structure to be learned is genuinely simple, a small model of it need not be a poor one.

The story

The appeal is easy to state. An agent that could learn how its environment behaves would not have to pay for every lesson with a real action. It could try things internally — predict what would happen, judge the result, try again — and only act in the world once it held a plan worth executing. The difficulty is just as easy to state. A learned model of the world is always partly wrong, and an optimiser set loose inside a wrong model does not politely ignore the wrong parts. It hunts for whatever scores well, and the model's mistakes are often the easiest things to score against.

The World Models paper builds a specific and unusually clean architecture around this idea, with three components trained one after another rather than all at once.

First comes vision. This is an autoencoder: a network trained to squeeze each video frame down to a short code and then rebuild the frame from that code alone. The test is the rebuild. If the reconstructed frame looks right, the code must have kept whatever mattered about the original; if it looks wrong, the code threw away too much. Here the code is 32 numbers standing in for a full screen of pixels. The training material is simply recorded play — frames collected while an arbitrary policy wanders the game — and no reward signal enters this stage at all. The network is not learning what is good. It is learning what a frame of this world tends to look like.

Second comes memory. This is a recurrent network, meaning one that keeps a running internal summary — a hidden state — of everything it has seen so far. Its job is prediction: given the current 32-number code and the action the agent is about to take, say what the next code will be. Crucially, it does not commit to one answer. It predicts a spread of possible next codes, with weights on each, because real environments branch: the same situation and the same action can lead to different outcomes. A temperature setting controls how widely samples are drawn from that spread. Set it low and the predictions come out smooth and confident, close to the single most likely outcome. Set it high and they come out noisier, ranging across the possibilities. That dial will turn out to matter more than anything else in the paper.

Third comes the controller, and it is deliberately tiny: a single linear layer that reads the current code together with the memory's hidden state and outputs an action. Almost all of the system's parameters sit in the vision and memory networks. Because the controller holds so few, it can be trained by an evolution strategy — a method that generates many candidate parameter settings, runs each, keeps the settings that score well, and repeats. The paper uses one called CMA-ES. No gradient has to travel back through the environment or through the memory network, which sidesteps a great deal of training instability.

Now the payoff. Once the vision and memory models exist, they are, together, an environment. Feed the memory an action, receive a predicted next code, feed that prediction back in, and repeat. The loop never has to touch the real game. The paper does exactly this for the VizDoom Take Cover task: the controller is trained entirely inside this imagined rollout — the authors call it a dream — and then transferred back to the actual game, where it performs.

And here the failure shows itself, plainly enough to be the most instructive result in the paper. The dream is not the world. Every learned model has systematic errors: places where it predicts something the real game would never do. When the temperature is set low, the dream's predictions are nearly deterministic, so those errors recur identically in every imagined rollout. To the optimiser, a mistake that repeats reliably is indistinguishable from a rule of the game, and often an easier rule to profit from. The paper describes the agent discovering movements that made the dream's threats stop appearing at all — a perfectly rational response to a simulator with a flaw in it, and useless outside it. The agent had stopped solving the game and started solving the simulator. Raising the temperature fixes this, and the mechanism is worth spelling out. Wider sampling means the model's quirks no longer recur consistently from one rollout to the next, so any strategy that depends on a single quirk stops scoring well. Only behaviour that holds up across many differing imagined futures survives selection, and that behaviour is likelier to reflect the game's actual structure. The value of imagined practice depends entirely on the imagination staying honest about what it does not know.

A second paper, on harnessing structures for value-based planning, reaches related territory from a different direction. Instead of learning a simulator, it examines the value function — the table recording how good each combination of situation and action is. Lay that table out as a matrix and ask how much genuinely independent information it holds. Across a range of standard tasks, the answer is: far less than its size suggests. The matrices are approximately low-rank, meaning a small number of underlying patterns explain most of the entries. That opens the door to matrix completion — observe some of the entries, then use the patterns to reconstruct the rest — which amounts to planning by inference rather than by simulation.

The two papers share no method, and neither settles when compact models can be trusted. The World Models results cover a car-racing task and the VizDoom task; whether the same decomposition holds in environments with longer horizons or sparser reward is not settled there. The low-rank finding is an empirical observation on standard benchmarks, approximate rather than exact, and its reach is open. The connection between the two is one this lesson draws, not one the authors state jointly. Read together, though, they make a narrow and useful point. Small internal models can work because the things being modelled — the dynamics, the values — carry far more redundancy than their raw size suggests. Compression is a bet on the structure of the problem. Where the bet is right, a 32-number code can stand in for a screen. Where it is wrong, the model's errors are exactly what an optimiser will find first.

Why it mattered then

When these papers appeared, the field was dominated by model-free reinforcement learning: the agent learns which actions earn reward directly from experience, with no internal model of how the world works. The approach works, but it is hungry. Every lesson costs a real interaction, which is acceptable in a simulator you can run cheaply and hopeless almost anywhere else. Learned world models had long been the obvious alternative, but practical results were thin, largely because predicting raw, high-dimensional observations — full frames of pixels — accurately enough to plan with was too hard. What the World Models architecture contributed was a way of splitting the problem so that each piece became easy with the tools then available. Learn the compression on its own, without reward. Learn to predict forward in the compressed space, again without reward. Then place a very small policy on top and search over it crudely, by evolution, because it is small enough that crude search suffices. No stage is remarkable alone. The arrangement is the argument — and the demonstration that a controller trained wholly inside the learned dream could transfer back to the real environment turned a longstanding intuition into a concrete result. The low-rank value work belongs to the same moment for a different reason. It asked whether the objects reinforcement learning manipulates are as complicated as their size implies, and found, on a range of standard benchmarks, that they are not. Both papers argue, in the end, that these problems are smaller than they look.

Why it matters now

Two things from this lesson have outlasted their original papers. The first is the layout itself: a learned encoder that compresses observations, a learned dynamics model that predicts forward in that compressed space, and a policy trained largely or entirely on those predictions. That shape, in various forms, remains standard in model-based reinforcement learning. Predicting a compact code rather than the pixels themselves is the move that makes the rest feasible. The second is the warning. A policy optimised inside a learned model will exploit that model's errors, and the demonstration here is unusually legible: lower the dream's uncertainty and the agent stops solving the game and starts solving the simulator. Anyone who builds a system that plans against a learned predictor inherits this problem. It is why model uncertainty is treated as something to preserve rather than something to eliminate, and why a confident wrong model is more dangerous than a hesitant one. The redundancy observation matters for a plainer reason. If the structures an agent must learn really are low-rank — describable by a few underlying patterns — then small models and limited data are not compromises but a fit to the problem. How far that holds beyond the tasks tested is not established by these papers, and it should not be assumed.

The surprising detail

The most instructive result in the World Models paper is a failure. Trained inside a dream with the uncertainty turned down, the agent stopped playing the game and started playing the simulator: it found movements that made the dream's threats stop appearing, movements that did nothing in the real game. Nothing here is a bug in the agent — it optimised exactly what it was given. The fix runs against instinct: make the internal model less certain on purpose, sampling its predictions more widely, so that no single exploitable quirk repeats across imagined futures. A noisier dream is a more useful one. For planning, honest uncertainty can matter more than fidelity, and a confident wrong model is more dangerous than a hesitant one.

What is disputed

Both findings are demonstrations on particular benchmarks, not general laws. The World Models result covers a car-racing task and a VizDoom task; whether the same three-stage decomposition holds up in environments with longer horizons or sparser reward is not settled by that paper. The low-rank claim about value functions is likewise an empirical observation on a set of standard tasks, described as approximate rather than exact, and how widely it extends is open. The relationship between the two papers is one this lesson draws out, not a shared conclusion the authors state jointly.

Remember this

An agent rehearsing inside a learned model of its world will find the model's mistakes before it finds the world's rules. Preserving the model's uncertainty is what makes the rehearsal transfer.

Test yourself

Why does deliberately making the learned world model less certain — sampling its predictions more widely — tend to produce a policy that works better in the real environment, when a more confident model is presumably a more accurate one?

Go deeper

Image: Original diagram, The Daily Triptych. Licence: Original work. Source.

← Back to day 231