World Models 101
Contents
05

What Is a Dynamics Model?

By Nilushanan Kulasingham

PDF

In training, the model is handed the truth at every step. The moment you deploy it, it gets its own last answer instead. What carries the past forward, and why the headline accuracy number measures a job the model will never be asked to do.

If you have read the last chapter, you have a state: a short list of numbers that stands in for what the camera saw. The next step is the one where that state moves. A dynamics model, also called a transition model, does one job. Take what you know, take what you did, and produce what you know next.

The awkward word there is know, because it covers more than the last picture. It is everything that has happened and still matters, folded into something small enough to carry. A ball behind a wall is still moving. A door you opened four rooms ago is still open.

A dynamics paper leads with its one-step error, and it is the easiest number to be impressed by. I was impressed by it for a good while, until I looked at what it measures. Let's start with the job itself.

what you knowsposition1.0 mspeed1.2 m/stepwhat you didacoastwhat you know nexts'positionspeed024681012m1.2 m

You have the state and the action. Say where it goes next.

step

1 of 5

miss this step

-

average miss

-

Fig. 5.1This is the one job, and for a moment you are the model. You are handed the state and the action, so drag your answer to where the ball will be after one step and press Check. Do that a few times and watch the average miss build up underneath, because that average is the number a dynamics paper leads with. Every one of those steps starts from the truth, which is the part to remember. The units are illustrative.

Now the number. Show the model where things are and ask what happens next. Compare its answer to what happened, then do that ten thousand times and read off the average. The result will be small, and it measures something real.

It also measures a job the model will never be asked to do. You were going to ask it for a hundred steps. From step two it stops being handed the truth and starts being handed its own last answer.

I call that the second-step problem. The field put a name to it in 2015, tried two rival cures within a year, and has not solved it since. Let's look at what it does to one small model.

what actually happenscorrected every step, as in trainingleft to run on its own answers

Off by, corrected

0.016

Off by, on its own

0.648

Worse by

39×

Fig. 5.2One model, one bias, two ways of running it. The grey line is corrected at every step, the way it was during training, and mostly disappears underneath the truth. The vermilion (orange-red) line is the same model left to eat its own output, the way it will be run. Push the bias up and watch which line notices. The distances are illustrative.

Judging from the readouts, at four per cent error per step the corrected line is still hugging the truth after thirty steps. The free-running line, same model, same bias, ends up thirty-nine times further away. Keep that picture in mind.

The inherited habit

The habit came with the first networks trained on sequences, decades before world models. During training a sequence model is shown the true previous value at every step. That is what the recording contains, and it keeps training stable. The field calls this teacher forcing.

The cost is that nobody teacher-forces you in production. At the moment of use the model gets its own last answer, which is slightly wrong. It has never once been asked to recover from being slightly wrong.

recorded truththe model'soutputt=0t=1t=2t=3t=4t=5
0/5

Every input is the recorded truth.

miss at t=5

3.2

where each input comes from

the recording

Fig. 5.3The same five steps, drawn with the arrows that feed each one. Leave the switch on training and every step is handed the recorded truth, so a mistake goes nowhere. Flip it to in use and each step is handed the one before it, so the first small mistake rides along into every later step. Press Step and watch where the vermilion comes from.

Samy Bengio and his co-authors named that gap in 2015, in Scheduled Sampling for Sequence Prediction with Recurrent Neural Networks. Bengio was at Google, working on networks that caption a photo one word at a time, each word fed back as the next input. That is a rollout, and the captions drifted the way the vermilion line drifts. A paper that leads with the grey line is describing the wrong run.

The memory wars, 1997 to 2023

Let's go back to the word know, because the question underneath it is how the past gets carried. Since 1997 it has had two answers, which take turns being fashionable.

Carry a summary. Keep one fixed block of numbers. Every time something new arrives, fold it in and throw the old block away. The work per step never changes however long the sequence gets.

Keep a window. Store the steps that fit in the context. When a new one arrives, look back over them to decide what matters. This is attention (for each new step, score the earlier steps for how much they matter, then read mostly from the ones that scored highest).

Carry a summaryKeep a context windowNumbers carried forwardWhat the model is holding when the next step arrives.25632,768Work for one more stepMultiply-adds to fold in one new observation.65,53632,768Can it still see the first step?Whatever a fixed summary dropped is not recoverable later.Only if the summary kept itYes, while it remains in context

Past the crossover. Keeping everything now costs more per step than updating a summary.

Both columns use a state 256 numbers wide, so the only thing changing is the length.

Fig. 5.4Both columns use a state of the same width, so the only thing that changes is the sequence length. Drag the length up and watch the second row. Neither column wins: looking at everything is cheaper for short sequences and dearer for long ones.

The summary is what recurrent networks do (a network with a loop in it, so each step's output feeds back into the next step's input). The summary camp's founding paper is Long Short-Term Memory, from Sepp Hochreiter and Jürgen Schmidhuber in 1997. Their LSTM was a loop built to hold a fact longer than training pressure wanted. It ended up running speech recognition and translation until transformers arrived.

The window is what transformers do, and they are the architecture under today's language models. They have done it since 2017, when Ashish Vaswani and colleagues at Google published Attention Is All You Need. The title meant what it said: the loop went out. Within a few years the window had replaced the summary almost everywhere.

Then the summary came back. The state-space models keep the fixed summary and add better machinery. S4 came from Albert Gu and colleagues at Stanford in 2021, as Efficiently Modeling Long Sequences with Structured State Spaces. Mamba came from Gu and Tri Dao in 2023, as Mamba: Linear-Time Sequence Modeling with Selective State Spaces.

Speed is the half of the trade that gets benchmarked, and it is the duller half. A fixed summary has to decide at every step what is worth keeping, without knowing what will be needed later. Mamba gave a little ground: its summary decides what to keep based on what it is looking at. Attention puts off the decision until the read, and pays by keeping a finite bank of earlier states.

facts, in order of arrivalquestion, at the endsummary, room for threerule: drop the oldest
question

Pick a question, then press Play.

kept

3 of 6

work per step

the same every step

Fig. 5.5Six facts arrive one at a time, and a summary with room for three has to keep or drop each one as it comes. A question arrives at the end. Pick the question, press Play, and watch the summary: it cannot see the question coming, so sometimes it dropped the one fact that was needed. Switch to the window and the same question is answered by looking back, at the cost of keeping all six. Illustrative.

This is the squeeze between a camera and a decision from chapter 4, one level up. Something has to be thrown away, and whatever is doing the throwing does not know the future. That is why twenty-six years of rivalry have no winner.

Splitting the difference

The systems that work share one trick. It arrived in 2018 with PlaNet, from Danijar Hafner and colleagues, in Learning Latent Dynamics for Planning from Pixels. PlaNet learned a model from raw pixels and planned inside it instead of in the pixels.

The trick is to carry two things forward rather than one. One part is deterministic: computed the same way every time, it holds whatever reliably follows from the last state. The other is stochastic: sampled, so it holds whatever could still go either way.

A ball's motion goes in the first. Whether the door opens goes in the second. Keep only the deterministic part and the model has no way to say it is unsure, so it confidently invents one future. Keep only the stochastic part and it struggles to remember anything for long, because noise gets added at every step.

behind the wall0123456789mstopped at the kerb, 8rolled on, 12

This is the answer with the smallest typical miss, and the ball is never there. A squared loss puts the model right here.

typical miss

2.1 m

worlds you got right

0 of 20

within half a metre

Fig. 5.6The ball went behind the wall, and it either stopped at the kerb or rolled straight on. Drag the single answer along the ground and watch the two readouts pull apart: the smallest typical miss sits between the two clumps, in a spot where the ball never actually is. Then switch to handing back the spread and see what the second half of the state buys. Twenty worlds, illustrative.

PlaNet ran the comparison and argued for carrying both, because each one fails alone in a different direction. Dreamer followed a year later, when the same group published Dream to Control and let an agent learn to behave inside the model's imagined rollouts.

The split state went into it, and into every Dreamer since, up to the Nature paper of 2025.

Four truces with the second step

Nobody has removed the second-step problem, and I do not expect anyone to. Instead the field has four ways of not being destroyed by it, so let's take them in turn.

Train it on its own output. If the complaint is that the model never practised recovering from its own mistakes, let it make some during training. Feed it its own predictions part of the time, and raise that share as it improves. This is Bengio's scheduled sampling, the most direct of the four.

inputsfrom the recorded truththe model's own last answer12345678910the model's outputtruth

This is teacher forcing. The model has never once been handed its own mistake.

Inputs from the truth

10 of 10

Inputs from the model

0 of 10

What the model has practised

never recovering

Fig. 5.7Ten training steps in a row. The slider is how often the model is handed its own last answer instead of the recorded truth. At zero this is teacher forcing, and every input is the truth. Drag it up and the vermilion inputs appear, which is the model practising on its own mistakes. Press Run the schedule to raise the share over a run the way Bengio did, and read the verdict underneath. Illustrative.

Train the rollout, not the step. Instead of scoring one-step accuracy, score a whole imagined stretch against a whole real one, so that what gets optimised is what you will run. Marc'Aurelio Ranzato and colleagues at Facebook made that case in 2015 too, in Sequence Level Training with Recurrent Neural Networks. The two 2015 papers read as a pair: one fixes the input and the other the loss.

Do not go far. Keep the rollouts short and start them from real states. It is cheap and it works, and it gives up the long imagined futures that were the appeal. Michael Janner and colleagues made it a method in 2019, under a title that is also the question: When to Trust Your Model.

twice as goodten times as goodhow wrong you are willing to be6 stepsthe stretch you can trust0204060010203040steps you ask forhow far off the model is

At this tolerance the model is worth trusting for 6 steps. That is the number Janner's truce is made of.

tolerance

10 units

steps you get

6

steps you get at ten times the model

22

Fig. 5.8How far you can go is a number you measure, so measure it here. Drag how wrong you are willing to be, and read off how many steps you get before the model's error crosses that line. Then swap in a model ten times better and watch the horizon move by a handful of steps rather than by a factor of ten. The error curve is illustrative.

Look again. Predict a few steps, act on one, take a fresh observation and start over. This is most of robotics, and the oldest idea here. A measurement corrects the part of the state you can see, but error in the part you cannot see, and the model's bias, do not reset to zero.

The oldest form of it is Rudolf Kalman's filter from the 1960s, the maths inside every GPS receiver. That filter is this loop, and the blend inside it is the cleanest picture of predict-then-correct there is, so let's take a short detour through it. Picture a radar tracking a plane. At each moment you have two stories about where the plane is.

One comes from physics: take the last position and the last speed, and predict where the plane should be now. The other comes from the radar, which hands you a blip. Both stories are uncertain, and each is really a bell curve, a Gaussian, with the most likely spot in the middle and the less likely ones fading out either side.

Multiply the two curves together and you get a third bell curve, which sits between the two and is narrower than either. That is the new belief, and the figure below lets you watch it form.

050100position, mphysicsradarnew belief

The two stories are about equally trustworthy, and the new belief sits between them. The product is narrower than either parent.

Kalman gain K

0.50

new mean

50.0 m

new width

σ 5.7 m

Fig. 5.9Here are the two stories about where the plane is, drawn as bell curves on one axis. Slide how sure physics is and how noisy the radar is, and watch the new belief lean toward the sharper story while staying narrower than either. The gain readout is the number that says how far it leaned. Now press Correct to make the new belief the next physics prediction, and watch it widen again as the plane moves on. The positions are illustrative.

How far the new belief leans from physics toward the radar is set by one number between zero and one. The field calls it the Kalman gain. As you can see from the figure, a noisy radar pulls the gain toward zero, so the filter sticks with physics. A sharp radar pulls it toward one, so the filter trusts the reading.

Then it repeats: predict, correct, predict, correct. Every new blip, however wrong on its own, tightens what the filter knows. The estimate hugs the truth even though every reading it ever got was off, and it does that one tick at a time without ever waiting for the future. That is the look-again truce in its original form. It only works because fresh readings keep arriving, and even then it only pulls back the part of the state a reading can see.

the part you can seethe part you cannot see0.003690481216correctionshow far off

Press Look again. Each press is one prediction and one blip.

corrections

0

error you can see

0.0 units

error you cannot see

0.0 units

Fig. 5.10The same blend, repeated, with the two halves of the state kept apart. Press Look again and watch the sawtooth: every prediction pushes both errors up, and every blip pulls the measured half straight back down. Now add a wind the filter was never told about and keep pressing. The measured half still comes back, and the half you cannot see settles on a floor it never leaves. Distances are illustrative.

None of these is a fix, and a paper that sells one as a fix is overclaiming. Each admits that a learned transition model can be trusted over a limited horizon. Part of the engineering is measuring how long that horizon is.

Recovery is a separate skill

Two models can tie on the usual one-step test and behave in opposite ways when run. The test never asked what separates them. If both have only seen the demonstrated path, nothing in their scores says which way they move after a small mistake.

Training on perturbed or self-generated states does ask it, and the answer is a separate skill. Have a go with the figure below.

trained only on the demonstrated pathtrained to recover from nearby statesdemonstrated pathfirst predictionten steps later

On the demonstrated path

both predict perfectly

Truth-only error at step 10

1.22

Recovery-trained error at step 10

0.003

Fig. 5.11Both toy models are exact on the demonstrated path. Drag the offset to start them off it. One has only learned what comes next on the line, and drifts away. The other has practised nearby states and bends back. The arithmetic is made up, but the distinction is real, and it is the finding behind Professor Forcing, which we come to next.

Scheduled sampling shows a learner its own states and guarantees nothing, because those states keep changing as the model learns.

Professor Forcing came a year later, as Professor Forcing: A New Algorithm for Training Recurrent Networks. It was the work of Alex Lamb and colleagues in Yoshua Bengio's lab in Montreal. The two Bengios are brothers, and two of the best-known attacks on the gap came one from each.

It attacks the gap from the other side and leaves the input alone. Instead it trains the model until its internal states look the same whether it is teacher-forced or running free. The judge is a second network trained to tell the two kinds of run apart. The model has to fool it, which is the trick behind generative adversarial networks: one network forges, another spots forgeries.

teacher-forced runfree runinputs: untouchedjudgecertainguessingcertain

The judge can tell the free run from the forced run at a glance.

rounds trained

0

gap between the trails

3.8

Fig. 5.12Two runs of the same model, one teacher-forced and one free, each leaving a trail of hidden states. The judge on the right is trained to say which trail is which. Press Train a round a few times and watch the free trail pulled over toward the forced one until the judge is guessing. Nothing here touched the inputs. The trails are illustrative.

I think it is the more under-read of the two, perhaps because transformers arrived the next year and took the field's attention. The problem moved into world models, where every rollout is a free run.

What the two papers share is that recovery has to be put into the training objective, because the model does not learn it on its own.

Everything in this chapter stayed tied to recorded experience: the model was trained on it, checked against it and corrected by it. The next chapter asks what happens when an agent learns inside the model instead.

Hopefully this one helped. There is a short quiz below if you want to check the ideas stuck. If I have got something wrong, or you know a better source than the ones I used, the About page has a corrections section. I would be glad to hear from you.

Try it

1 / 8Score 0

A transition model reports a very low average one-step error. Why does that number not tell you what you want to know?

Pick one

Fig. 5.13Eight questions on the step and the second-step problem. The first three change how you read a paper's headline number, so try those even if you skip the rest.

Sources

  1. Professor Forcing: A New Algorithm for Training Recurrent NetworksLamb et al., 2016Aligns hidden-state trajectories under teacher forcing with those produced during free running. A direct attempt to train the recovery behaviour a one-step test never asks for.
  2. Scheduled Sampling for Sequence Prediction with Recurrent Neural NetworksBengio et al., 2015The mismatch named and attacked head on: let the model eat its own predictions during training, and raise the dose as it improves.
  3. Sequence Level Training with Recurrent Neural NetworksRanzato et al., 2015Score the whole rollout rather than the single step, so the thing being optimised is the thing you will actually run.
  4. Learning Latent Dynamics for Planning from Pixels (PlaNet)Hafner et al., 2018The argument for carrying a deterministic part and a stochastic part together, because each one fails alone in a different direction.
  5. Dream to Control (Dreamer)Hafner et al., 2019What a latent transition model is for once it works: long imagined rollouts that behaviour can be learned from.
  6. Long Short-Term MemoryHochreiter & Schmidhuber, 1997The fixed summary, made to hold on to things for longer than the gradient wanted it to. Paywalled.
  7. Attention Is All You NeedVaswani et al., 2017The other answer: retain the available context and choose what to read at each step, paying a cost that grows with sequence length.
  8. Efficiently Modeling Long Sequences with Structured State Spaces (S4)Gu et al., 2021The summary approach returning with better machinery, and the reason state-space models are back in the conversation.
  9. Mamba: Linear-Time Sequence Modeling with Selective State SpacesGu & Dao, 2023A summary that decides what to keep based on what it is looking at, which is the concession the fixed version could not make.
Fig. 5.14I've ordered these for someone building on this rather than for historical completeness, and preferred first-party material throughout.

This chapter is free and open source. A star helps the next person find it.

Star on GitHub21
Star on GitHub21