6.5.6Research Frontiers & Practice

World models and embodied AI

3,242 words15 min readdifficulty · medium

What Are World Models?

Why do we need this?

  • Sample efficiency: Real-world interactions are expensive (robot might break, medical trial costs lives). Simulate rollouts in your head (model) instead.
  • Planning: With a model, you can "think ahead" by simulating future trajectories before acting (like chess players visualizing moves).
  • Transfer: A good world model captures environment dynamics that transfer across tasks (same physics, different goals).

How is this different from model-free RL?

  • Model-free (DQN, PPO): Learns Q(s,a)Q(s,a) or π(as)\pi(a|s) directly from trial-and-error. No explicit understanding of consequences.
  • Model-based: Learns p(st+1st,at)p(s_{t+1}|s_t, a_t) first, then uses it to plan or train a policy. Understands "if I push this, it will fall."

Derivation: How World Models Enable Planning

Step 1: The Forward Model

Start with the Markov Decision Process (MDP) dynamics: st+1P(st+1st,at)s_{t+1} \sim P(s_{t+1} | s_t, a_t)

In model-free RL, we never learn PP explicitly. We only learn the value function V(s)V(s) or policy π(as)\pi(a|s) from samples.

World model approach: Learn an approximation P^θ(st+1st,at)\hat{P}_\theta(s_{t+1} | s_t, a_t) (the forward model).

Why learn this explicitly? Because once we have it, we can:

  1. Rollout hypothetical trajectories without real environment interaction
  2. Backpropagate through the model to optimize actions
  3. Data augmentation by simulating synthetic experience

Step 2: Planning with the Model

Given P^θ\hat{P}_\theta, we want to find the best action sequence. Use Model Predictive Control (MPC):

a0:H1=argmaxa0:H1EP^θ[t=0H1r(st,at)]a^*_{0:H-1} = \arg\max_{a_{0:H-1}} \mathbb{E}_{\hat{P}_\theta} \left[ \sum_{t=0}^{H-1} r(s_t, a_t) \right]

Derivation from first principles:

Start with the trajectory return: J(τ)=t=0H1r(st,at)J(\tau) = \sum_{t=0}^{H-1} r(s_t, a_t)

We want to maximize expected return under our learned dynamics: J(a0:H1)=Es1P^(s0,a0)Es2P^(s1,a1)[t=0H1r(st,at)]J(a_{0:H-1}) = \mathbb{E}_{s_1 \sim \hat{P}(\cdot|s_0, a_0)} \mathbb{E}_{s_2 \sim \hat{P}(\cdot|s_1, a_1)} \cdots \left[ \sum_{t=0}^{H-1} r(s_t, a_t) \right]

Why this step? Each future state sts_t is random because the model is stochastic. We integrate over all possible futures weighted by their probability.

Expanding the nested expectation: J=P^(s1s0,a0)[r(s0,a0)+P^(s2s1,a1)[r(s1,a1)+]ds2]ds1J = \int \hat{P}(s_1|s_0, a_0) \left[ r(s_0, a_0) + \int \hat{P}(s_2|s_1, a_1) \left[ r(s_1, a_1) + \cdots \right] ds_2 \right] ds_1

Why recursive? The return is additive over time, and each state depends only on the previous (Markov property).

In practice, we approximate this integral by:

  • Sampling KK trajectories from P^θ\hat{P}_\theta
  • Averaging their returns
  • Optimizing a0:H1a_{0:H-1} via gradient descent or shooting methods (CEM, CMA-ES)

J1Kk=1Kt=0H1r(st(k),at)where st(k)P^θ(st1(k),at1)J \approx \frac{1}{K} \sum_{k=1}^K \sum_{t=0}^{H-1} r(s_t^{(k)}, a_t) \quad \text{where } s_t^{(k)} \sim \hat{P}_\theta(\cdot | s_{t-1}^{(k)}, a_{t-1})

Key insight: The model lets us evaluate action sequences in simulation before committing in reality.

Step 3: Dyna Architecture (Learning + Planning)

The Dyna framework unifies model-learning and model-free RL:

  1. Real experience: (s,a,r,s)(s, a, r, s') \rightarrow update policy π\pi (model-free) AND model P^θ\hat{P}_\theta
  2. Simulated experience: Sample (s,a)(s, a) \sim replay buffer, generate sP^θ(ss,a)s' \sim \hat{P}_\theta(s'|s,a) → update policy

Why does this work?

  • Real data is scarce → use model to generate synthetic data
  • Model errors compound over long rollouts → use short kk-step rollouts
  • Policy improves faster because it gets Nreal+NsimN_{\text{real}} + N_{\text{sim}} updates per real sample

The Dyna update rule: θπθπ+α[θJreal+λθJsim]\theta_\pi \leftarrow \theta_\pi + \alpha \left[ \nabla_\theta J_{\text{real}} + \lambda \nabla_\theta J_{\text{sim}} \right] where λ\lambda trades off model trust.

Why the λ\lambda weight? If the model is poor, simulated gradients are biased → reduce their influence.

What Is Embodied AI?

Why embodiment matters:

  • Grounding: Abstract concepts (e.g., "heavy") are learned through physical interaction, not definitions
  • Affordances: What you can do depends on your body (a quadruped can't open doors the way a humanoid can)
  • Exploration: Embodied agents naturally explore by moving, manipulating, trying—this generates diverse data
  • Partial observability: Real bodies have limited sensors → agent must actively gather information

Historical context: Classical AI (GOFAI) tried to build intelligence via logic and symbols. The embodied cognition movement argued this ignores how biological intelligence is inseparable from the body.

Architecture: World Models (Ha & Schmidhuber, 2018)

The seminal World Models paper proposed a three-component architecture:

  1. V (Vision): Variational autoencoder learns latent representation ztz_t of observation oto_t zt=Encoder(ot),otDecoder(zt)z_t = \text{Encoder}(o_t), \quad o_t \approx \text{Decoder}(z_t)

  2. M (Memory): Mixture Density Network RNN predicts next latent state P(zt+1zt,at,ht)=i=1KπiN(μi,σi2)P(z_{t+1} | z_t, a_t, h_t) = \sum_{i=1}^K \pi_i \mathcal{N}(\mu_i, \sigma_i^2) where hth_t is RNN hidden state.

  3. C (Controller): Small linear policy at=Wzt+Whht+ba_t = W z_t + Wh h_t + b

Why this architecture?

  • V compresses high-dim observations (pixels) → low-dim ztz_t (like "there's a car ahead")
  • M learns temporal dynamics → predicts future zt+1z_{t+1} (like "if I steer left, the car will move right in my view")
  • C is tiny because it operates on abstract ztz_t, not raw pixels → easy to optimize

Key innovation: Train M on real trajectories, then train C entirely inside M's dream (simulated rollouts). No real environment needed after collecting initial data.

Derivation of M's loss:

We want P(zt+1zt,at)P(z_{t+1} | z_t, a_t). Use maximum likelihood: LM=logPM(zt+1zt,at,ht)\mathcal{L}_M = -\log P_M(z_{t+1} | z_t, a_t, h_t)

For the Mixture Density Network: PM(zt+1)=i=1Kπi(zt,at,ht)N(zt+1;μi,σi2)P_M(z_{t+1}) = \sum_{i=1}^K \pi_i(z_t, a_t, h_t) \cdot \mathcal{N}(z_{t+1}; \mu_i, \sigma_i^2)

Why mixture of Gaussians? Because the future is stochastic and multimodal (e.g., a car might turn left OR right). A single Gaussian would predict the average (going straight), which is wrong.

The negative log-likelihood: LM=log(i=1Kπiexp((zt+1μi)22σi2))\mathcal{L}_M = -\log \left( \sum_{i=1}^K \pi_i \exp\left( -\frac{(z_{t+1} - \mu_i)^2}{2\sigma_i^2} \right) \right)

Why this loss? It's the cross-entropy between the true next state distribution and our model's prediction. Minimizing it makes the model match reality.

Common Mistakes

Connections to Other Concepts

  • Model-FreeRL: World models are the complement—model-based methods need sample efficiency but are complex to train
  • Variational-Autoencoders: VAEs provide the V (Vision) component for latent state representation
  • Recurrent-Neural-Networks: RNNs (LSTMs, GRUs) are the standard M (Memory) for temporal dynamics
  • Reinforcement-Learning-Basics: World models fit into the MDP framework, learn the transition function P(ss,a)P(s'|s,a)
  • Imitation-Learning: Behavioral cloning ignores world models; inverse RL can learn reward, then use model to plan
  • Sim-to-Real-Transfer: Embodied AI must bridge the "reality gap" between simulated world models and real physics
  • Vision-Transformers: Modern V components might useViT encoders instead of CNs/VAEs for better representation
  • Diffusion-Models: Emerging approach for generative world models (predict future frames as denoising process)
Recall Explain to a12-Year-Old

Imagine you're learning to ride a bike. At first, you fall a lot because you don't know what happens when you turn the handlebars or pedal faster. But your brain is building a mental model: "If I turn left, the bike goes left. If I pedal hard going uphill, I slow down less."

After enough practice, you can imagine what will happen before you do it. You see a turn coming and think "If I lean and turn now, I'll make it smoothly." You're planning in your head using your model of bike physics.

That's a world model! It's your brain's simulator. World models in AI are the same: the robot learns how its body and the environment work, then "thinks ahead" by simulating actions in its mind before doing them in real life.

Embodied AI means the robot has a body (not just a brain in a computer). It learns by doing—pushing things, moving around, touching objects—just like you learned by actually riding the bike, not by reading a book about it. The body and experience are essential to being smart.


#flashcards/ai-ml

What is a world model in reinforcement learning? :: A learned probabilistic model p(st+1,rtst,at)p(s_{t+1}, r_t | s_t, a_t) that predicts next state and reward given current state and action—an internal simulation of environment dynamics.

Why do world models improve sample efficiency?
They allow agents to simulate rollouts internally instead of requiring real environment interactions, which are often expensive or dangerous in real-world settings.
What are the three components of the World Models architecture?
V (Vision/VAE encoder), M (Memory/RNN dynamics model), C (Controller/policy)—V compresses observations, M predicts future latents, C outputs actions.
What is embodied AI?
AI systems that have a physical or simulated body and learn through sensorimotor interaction with rich environments, not just abstract symbolic reasoning or text processing.
Why do world model errors compound over long rollouts?
Each prediction depends on the previous, so error ϵM\epsilon_M at step tt affects all future steps—total error grows as ϵMH\epsilon_M \cdot H where HH is horizon length.
What is the Dyna architecture?
A framework that combines model-free RL updates from real experience with model-based updates from simulated experience generated by the world model.
What is the distributional shift problem in world models?
When a model is trained on expert data but used by a learner policy that visits different states, the model has no data in the learner's distribution and makes poor predictions.
How does a Mixture Density Network handle stochasticity?
It predicts multiple Gaussian components iπiN(μi,σi2)\sum_i \pi_i \mathcal{N}(\mu_i, \sigma_i^2) to represent multimodal futures instead of averaging to a single incorrect prediction.
Why use short rollouts instead of long ones in model-based RL?
Model errors compound exponentially—short kk-step rollouts keep predictions accurate, then fall back to model-free value estimates for long-term planning.
What is the difference between model-free and model-based RL?
Model-free learns policy/value directly from trial-and-error; model-based explicitly learns environment dynamics P(ss,a)P(s'|s,a) first, then plans or trains policy using the model.

Concept Map

predicts

enables

contrasts with

learns directly

learns via

needs

core is

allows

feeds

optimizes

improves

supports

World Model p of s_t+1 r_t

Environment Dynamics

Planning Ahead

Model-Free RL

Q or policy

Embodied AI

Sensorimotor Interaction

Forward Model P_theta

Hypothetical Rollouts

Model Predictive Control

Action Sequence a*

Sample Efficiency

Task Transfer

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, yaha pe sabse important cheez ye samajhna hai ki world model kya karta hai. Normal reflex jaisa AI hota hai jo bas "agar X dikhe to Y karo" seekh leta hai — bina samjhe ki actually ho kya raha hai. Par world model iske ulta kaam karta hai: ye apne andar ek chhota sa "physics engine" ya mental simulation banata hai, jisse wo predict kar sakta hai ki "agar main Y action karunga, to next state kya hoga aur kitna reward milega." Formally isko hum p(st+1,rtst,at)p(s_{t+1}, r_t | s_t, a_t) likhte hai — matlab current state aur action dekh kar agla state aur reward guess karna. Embodied AI ka matlab hai ki agent ke paas ek body hoti hai (real ya simulated), aur usse seekhne ke liye actually kuch karna padta hai, sirf text padhna kaafi nahi.

Ab ye matter kyu karta hai? Do bade reasons hai. Pehla — sample efficiency. Real world me interaction mehenga hota hai; robot toot sakta hai, ya medical trial me zindagi ka risk hota hai. Agar agent apne andar hi rollouts simulate kar le (apne model me), to wo bina real damage ke practice kar sakta hai. Dusra — planning. Jaise chess player pehle mind me chaal socha karta hai, waise hi model hone se agent future trajectories ko simulate karke best action choose kar sakta hai commit karne se pehle. Isi ko Model Predictive Control (MPC) kehte hai, jaha hum aisa action sequence dhoondte hai jo simulated future me maximum total reward de.

Technically, kyunki model stochastic hota hai, har future state random hota hai, isliye hum saare possible futures pe unki probability ke hisaab se average lete hai (expectation). Practically hum KK trajectories sample karte hai, unke returns ka average nikalte hai, aur actions ko optimize karte hai — ya to gradient descent se (agar model differentiable ho) ya shooting methods jaise CEM se. Bottom line ye samajh lo: world model se hum reality me galti karne se pehle "dimag me" hi try karke dekh lete hai kaunsa action best hai. Yahi cheez ise plain model-free RL (jaise DQN, PPO) se zyada powerful aur transferable banati hai, kyunki ek achha world model environment ki physics capture kar leta hai jo alag-alag tasks me kaam aati hai.

Go deeper — visual, from zero

Test yourself — Research Frontiers & Practice

Connections