Model-free reinforcement learning learns values or policies directly from experience. Model-based reinforcement learning also learns, or is given, a model of what happens next:
pϕ(s′,r,d∣s,a),
where d indicates termination. The model can answer counterfactual questions without another real interaction:
What would happen if we took a in s?
This separates expensive data collection from reusable computation. One real transition can train the model once, then support many imagined action sequences, policy updates, or value targets.
A model need not reproduce every detail of the world. For control, it only needs to preserve the consequences that affect rewards and decisions. It may predict observations,
pϕ(ot+1∣ot,at),
physical states,
pϕ(st+1∣st,at),
or compact latent states,
pϕ(zt+1∣zt,at).
A visually realistic simulator can therefore be less useful than a small, smooth model that retains task-relevant dynamics.
Let a behavior policy πβ collect
D={(si,ai,ri,di,si′)}i=1N.
Model-based learning alternates between
collect real data⟶fit a model⟶improve behavior in the model⟶collect new data.
The model can improve decisions in several ways:
optimize an action sequence at decision time;
train a policy on imagined trajectories;
generate synthetic replay transitions;
extend a value target for a few steps;
learn a representation in which control is easier.
The tempting idea is to fit a simulator and then treat it as the real environment. The central difficulty is that the policy is optimized specifically to find trajectories the model predicts are good—including trajectories that look good only because the model is wrong.
Learning a One-Step Dynamics Model
For deterministic dynamics, predict the next state with
s^t+1=fϕ(st,at).
The usual regression objective is
Ldyn(ϕ)=N1i=1∑N∥si′−fϕ(si,ai)∥22.
When adjacent states are similar, predicting the change can be easier:
Δst=gϕ(st,at),s^t+1=st+gϕ(st,at).
The residual form builds persistence into the parameterization instead of asking the network to relearn it.
Squared error is a likelihood objective
Suppose the model has fixed isotropic Gaussian noise:
pϕ(s′∣s,a)=N(s′;μϕ(s,a),σ2I).
Then maximum likelihood produces exactly the squared-error estimator:
A deterministic model averages all possible futures. When the transition is multimodal, that average may be a state the environment can never produce. We instead learn
Neutral dynamics produce linear error growth. Locally expansive dynamics, with Lf>1, can amplify errors exponentially.
Return error can grow quadratically
Suppose every relevant transition satisfies
DTV(p(⋅∣s,a),pϕ(⋅∣s,a))≤ϵ,
and ∣r(s,a)∣≤Rmax. For a fixed policy and horizon H,
∣Jp(π)−Jϕ(π)∣=O(RmaxϵH2).›See derivation
Let dtp and dtϕ be the real and model state distributions. Each transition adds at most ϵ total variation, while applying the same Markov kernel cannot increase it. Hence
DTV(dtp,dtϕ)≤(t−1)ϵ.
The expected reward mismatch at time t is bounded by
Edtp,π[r]−Edtϕ,π[r]≤2Rmax(t−1)ϵ.
The factor 2 follows from the convention DTV(p,q)=21∥p−q∥1.
which scales as γ/(1−γ)2 in the infinite-horizon limit.
The same local model error affects the next reward and every later state distribution. Long imagined rollouts are therefore expensive in bias, even when they are cheap in computation.
Optimization finds model errors
The fit controls prediction error under the data occupancy:
E(s,a)∼dπβ[ℓϕ(s,a)].
The optimized policy cares about another occupancy:
E(s,a)∼dπϕ[ℓϕ(s,a)].
In general,
dπϕ=dπβ.
Low data density causes inaccurate extrapolation; the planner discovers an optimistic error; the new policy moves toward it; and the model is queried still farther outside its support. Unlike ordinary covariate shift, the optimizer actively searches for the mistake.
A conservative policy update can limit one source of shift:
Es∼dπβDKL(πϕ(⋅∣s)∥πβ(⋅∣s))≤δ.
This does not guarantee similar state occupancies—small action changes can have large effects—but it reduces how far one model-learning iteration tries to move.
Uncertainty Separates Noise from Ignorance
Aleatoric uncertainty is irreducible randomness in the transition:
s′∼p(⋅∣s,a).
It remains even with infinite data. The covariance emitted by a probabilistic model primarily represents this conditional noise.
Epistemic uncertainty comes from insufficient knowledge of the dynamics. It should be large in poorly covered regions and shrink when relevant data is collected. A single neural network can extrapolate confidently, so its output variance is not a reliable measure of epistemic uncertainty.
If θ denotes uncertain model parameters, the Bayesian predictive distribution is
Ensembles are only a coarse posterior approximation, but disagreement often identifies unsupported state-action pairs well enough to improve control.
Uncertainty needs a decision rule
Estimating expected return is risk neutral:
Jmean(A)=E[J(A)].
It is not automatically conservative. A planner must decide how uncertainty changes the objective:
JLCB(A)=E[J(A)]−λVar(J(A)),
or, for directed exploration,
JUCB(A)=E[J(A)]+λVar(J(A)).
A stepwise pessimistic reward can use
r~(s,a)=r(s,a)−λu(s,a),
where u(s,a) is ensemble disagreement. The penalty should target epistemic uncertainty: penalizing irreducible noise indiscriminately makes the controller risk averse rather than merely cautious about model error.
Rolling out only the ensemble mean is also unsafe. When members predict distinct modes, their average may be physically impossible. Better choices sample complete model trajectories, propagate particles, evaluate lower return quantiles, or optimize a worst-case ensemble return.
Planning with a Learned Model
Given deterministic dynamics and initial state s1, open-loop planning solves
A fixed sequence cannot respond to the realized future state. Model predictive control turns it into feedback:
observe⟶plan H steps⟶execute the first action⟶replan.
Frequent replanning corrects stochastic outcomes, disturbances, and model mismatch before they compound across the entire episode.
Random shooting
The simplest black-box planner samples candidate sequences
A(i)∼q0(A),i=1,…,N,
rolls each one through the model, and selects
A∗=argimaxJ(A(i)).
It requires no gradients and parallelizes easily. But an H-step plan with da-dimensional actions is an Hda-dimensional search problem, so uniform sampling deteriorates quickly.
Cross-entropy method
The cross-entropy method, or CEM, adapts the proposal distribution toward high-return sequences. Start with
qη0(A)=N(A;μ0,Σ0).
At each iteration, sample candidates, score them in the model, retain an elite set E, and fit the next proposal:
The CEM update is maximum likelihood on the elite samples. For a Gaussian, differentiating
i∈E∑logN(A(i);μ,Σ)
with respect to μ and setting the result to zero gives the elite sample mean. Substituting that mean and optimizing Σ gives the elite sample covariance.
Practical planners often use diagonal covariance and smooth new estimates with the previous proposal.
CEM Model Predictive ControlObserve the current state st.Initialize qη(at:t+H−1).Repeat for J CEM iterations:sample N action sequences from qη,roll them out through one or more learned models,score expected or pessimistic return,refit qη to the top M sequences.Execute the first action of the best sequence.Observe the next state and replan.
Sampling-based planning works with non-smooth rewards, discrete events, and black-box models. Its price is repeated model evaluation, poor scaling with long action sequences, and continued exposure to model bias.
Learning a Policy Through the Model
Planning spends computation at deployment. An alternative amortizes that computation into a policy
The products of closed-loop Jacobians explain the curse of chaos. Singular values below one make long-horizon gradients vanish; values above one make them explode. Contact events and chaotic dynamics can make tiny early action changes produce discontinuous later outcomes.
Stochastic dynamics can be reparameterized as
st+1=gϕ(st,at,ξt),ξt∼p(ξ),
and a stochastic policy as
at=hθ(st,ϵt),ϵt∼p(ϵ).
Backpropagation then treats sampled noise as an external input. This pathwise estimator can have low variance for short, smooth rollouts, but it retains the long-Jacobian problem and depends strongly on the accuracy of model derivatives.
Policy gradients need only model samples
We can instead sample imagined trajectories and apply the score-function estimator from policy gradients:
This estimator does not differentiate through transition Jacobians and naturally supports discrete actions. It trades that stability for higher sampling variance. Both estimators remain biased when the learned model is wrong.
Short Rollouts Spend Less Model Accuracy
Full imagined episodes demand global model accuracy. Short rollouts initialized from real replay states demand only local accuracy.
If a k-step rollout begins at s0∼Breal, the previous error argument suggests bias of order
O(ϵk2)
rather than O(ϵH2). Sampling many real start states also covers different points in the episode without predicting the path needed to reach each one.
Dyna
Dyna uses the model as an additional source of transitions. A real transition and a synthetic transition can drive the same Q-learning update:
Q(s,a)←Q(s,a)+α[r+γa′maxQ(s′,a′)−Q(s,a)].
The distinction is only where (r,s′) came from.
Deep Dyna with Short Model RolloutsInitialize model pϕ, off-policy learner, and real buffer B.Repeat:collect real transitions and append them to B,fit pϕ on B,sample real start states s0∼B,roll the current policy through pϕ for k steps,store synthetic transitions in Bmodel,update the learner from B∪Bmodel,refresh stale synthetic data after refitting the model.
Old imagined transitions were produced by an older model and policy. Keeping them indefinitely mixes incompatible synthetic environments, so model buffers are usually short lived.
Model-based value expansion
Instead of storing an entire synthetic rollout, use it to extend a target for k steps:
short k⇒more bootstrap error,long k⇒more model error.
Model-Based Policy Optimization, or MBPO, applies the same principle to off-policy actor-critic learning. It trains on a mixture
LQ=λrealEBreal[ℓQ]+λmodelEBmodel[ℓQ],
with short synthetic rollouts rooted at real states. The model need not be globally correct; it only needs to improve local targets enough to justify its bias.
Latent World Models
A state-space model predicts directly in a compact physical state. When the agent receives images, audio, or partial observations, that state may be unavailable. A latent world model jointly learns an internal state and its dynamics:
zt∼qψ(zt∣o≤t,a<t),zt+1∼pϕ(zt+1∣zt,at).
The representation should discard unpredictable or irrelevant detail while retaining what is needed for rewards, termination, future prediction, values, and actions. The control problem is unchanged, but the state through which the agent predicts and plans must now be learned.
In addition to latent dynamics, a useful world model predicts task-relevant outcomes:
pϕ(zt+1∣zt,at),pϕ(rt∣zt,at).
Pixel-perfect reconstruction is neither necessary nor sufficient. The latent state must preserve the information needed to choose well.
Variational representation learning
For a single observation x, introduce an encoder qψ(z∣x) for the latent model
Each transition term trains the predictive prior to match the posterior state inferred after seeing the next observation.
A filtering posterior,
qψ(zt∣o1:t,a1:t−1),
uses all information available online. A single-frame encoder qψ(zt∣ot) is simpler but cannot resolve perceptual ambiguity with history. A deterministic encoder cannot represent belief uncertainty and may collapse unless reconstruction, reward, contrastive, or variance objectives preserve useful structure.
Control in imagination
Once trained, the agent can imagine entirely in latent space:
z~t+1∼pϕ(⋅∣z~t,a~t),r~t∼pϕ(⋅∣z~t,a~t).
Latent MPC optimizes short action sequences, executes one action, observes the real next frame, updates the posterior state, and replans. A latent actor-critic instead learns
πθ(a∣z),Qω(z,a),
from encoded real transitions and short imagined rollouts. Both avoid decoding pixels during every imagined step.
The failure mode is representation bias: a latent model can predict observations well while discarding a small feature crucial for future reward. Control-related losses must therefore shape the state alongside reconstruction and dynamics consistency.
Latent models replace high-dimensional observation rollouts with compact imagined trajectories:
o≤tqψztpϕ,πzt+1:t+Hrϕ,Vdecision.
Reconstruction preserves observable information, transition KL terms align posterior and predictive states, and reward or value losses emphasize task-relevant structure. None is sufficient alone.
A latent model can reconstruct images while discarding a small feature crucial for control, or predict rewards while learning brittle dynamics outside the policy distribution. Its quality must therefore be judged by multi-step prediction, uncertainty calibration, and the performance of planning or actor-critic learning in the latent space.
The best world model is not the one that renders the most realistic future. It is the smallest belief state that preserves the consequences needed to choose well.
Choosing How to Use the Model
Model-based methods exchange environment interactions for modeling and planning compute.
Use direct planning or MPC when the action dimension and horizon are moderate, the model is fast, and frequent replanning is possible. Use pathwise optimization when dynamics and rewards are smooth and differentiable. Use policy gradients on model samples when derivatives are unavailable. Use Dyna, value expansion, or MBPO when the model is locally useful but unreliable over full episodes.
Across these choices, the same safeguards recur:
evaluate multi-step rollout and control error, not only one-step validation loss;
distinguish environmental noise from lack of data;
limit policy movement into unsupported regions;
prefer short rollouts and frequent replanning as uncertainty grows;
refresh synthetic transitions when the model changes.
The central tradeoff is
longer imagination⇒more synthetic signal+ more accumulated model bias.
Model-based RL is not the act of replacing the environment with a flawless simulator. It is the discipline of using an imperfect model only where its counterfactual predictions are worth more than their error.