Part X: Sensor Fusion, World Models, and Spatial AI
Chapter 53: World Models and Predictive Sensing

Generative interactive world models (Genie)

"Nobody handed me a controller. I watched a million hands press buttons I could not see, and the buttons taught themselves to me."

A Self-Taught AI Agent

The big picture

The previous two sections gave you world models that predict compactly. DreamerV3 in Section 53.2 rolls a small latent state forward, and the joint-embedding predictors of Section 53.3 predict in a representation space and never draw a pixel. This section covers the third branch: models that generate the full future observation and let you steer it, one action at a time. Genie is the landmark example. Its trick that matters most for sensing is that it learns to be steerable from raw video alone, with no action labels attached, by inventing its own latent action variable. That is precisely the situation you face with almost every real sensor log: hours of camera, lidar, or thermal frames, and no clean record of what the operator or the robot did between them. By the end you will know what "generative and interactive" buys you over a compact latent model, how the latent action model recovers control from unlabeled streams, and when a full generative world model is worth its heavy compute bill.

You need comfort with autoregressive sequence models and vector quantization (the discrete-codebook bottleneck from Chapter 17), plus the transformer machinery of Chapter 15. Everything else is built up here.

What "generative and interactive" adds

What it is. A generative interactive world model is a learned simulator. Given a starting observation \(o_0\) (an image, a sensor frame, a short clip) and a sequence of actions \(a_0, a_1, \dots\), it produces a coherent sequence of future observations \(\hat{o}_1, \hat{o}_2, \dots\), each rendered in full, and each conditioned on the action you chose at that step. Formally it approximates \(p(o_{t+1} \mid o_{\le t}, a_t)\) and lets you close the loop by feeding its own output back as the next input. Genie (Bruce et al., "Genie: Generative Interactive Environments," ICML 2024) is an 11-billion-parameter instance trained on tens of thousands of hours of unlabeled 2D platformer gameplay, and it turns a single image prompt into a world you can play.

Why generate the whole observation. Compact latent models are efficient but they answer only the questions their latent was designed to answer. A generative model commits to reproducing the entire observation, which forces it to keep track of objects, occlusion, and layout that a task-specific latent would happily discard. That completeness is the point when the observation itself is the deliverable: a synthetic camera feed for testing a perception stack, a counterfactual "what would the sensor have seen" rollout, or a playable environment for training a policy. It is the difference between a model that predicts that an obstacle is ahead and one that can draw the obstacle from a new viewpoint.

Why interactive. Interactivity is what separates a world model from a video generator. A video model produces one plausible future; a world model produces the future you asked for, responding to a control signal at every step so the rollout branches under your choices. For sensing and robotics that is the whole game, because the questions worth asking are counterfactual: what will the stream look like if the robot turns, if the valve opens, if the vehicle brakes.

Key insight

A video generator asks "what happens next?" A world model asks "what happens next if I do this?" The added conditioning on an action per step is small in parameter count and enormous in consequence: it converts a passive predictor into a controllable simulator you can plan inside (Section 53.5) and generate branching futures with.

The three pieces of Genie

Genie factors the problem into three learned components, all trained from video with no action or reward labels. Understanding the split is what lets you transplant the idea onto a sensor stream.

1. A spatiotemporal video tokenizer. A vector-quantized encoder compresses each frame into a small grid of discrete tokens, using a transformer that attends across both space and time so tokens carry motion context, not just static appearance. This shrinks a high-resolution stream into a sequence short enough for an autoregressive model to handle, exactly the tokenize-then-model recipe from Chapter 13.

2. A latent action model (LAM). This is the novel piece. Given two consecutive frames, a small inverse-dynamics encoder infers a latent action \(a_t\) that explains the transition, and quantizes it to one of a tiny set of codes (the original uses a vocabulary of eight). A forward decoder must then reconstruct \(o_{t+1}\) from \(o_t\) and that single code. The bottleneck is deliberately brutal: only a few bits pass through, so the code cannot smuggle appearance and is forced to capture the controllable degree of freedom, the "what changed that an agent could have caused." The LAM is used at training time only; at inference you replace its inferred codes with actions of your own.

3. A dynamics model. A masked, decoder-only transformer (a MaskGIT-style predictor) takes the past frame tokens plus the latent action and predicts the next frame's tokens. Rolled out step by step, with your chosen action injected at each step, it is the interactive simulator.

Videotokenizer Latent actionmodel (train only) Frame tokensoₜ Dynamics modelpredict ôₜ₊₁ rollout: feed prediction back, inject your action
Figure 53.4.1. Genie's three components. The tokenizer discretizes frames; the latent action model infers a low-bit action code that explains each transition (used only during training); the dynamics model predicts the next frame's tokens from past tokens and the action. At inference you supply the action and feed each prediction back for an interactive rollout.

Why latent actions are the sensor-AI payoff

What the problem is. Supervised world models need aligned (observation, action) pairs. Real sensor archives almost never have them: a warehouse has years of ceiling-camera footage but no synchronized log of what every forklift did; a dashcam fleet records video but not always the throttle and steering traces; a surgical endoscopy library has clips but no instrument-command stream. Action labels are the scarce resource.

Why the LAM dissolves it. The latent action model recovers a controllable action variable from the observations themselves, by asking what minimal signal, passed between two frames, best explains the change. This is an unsupervised inverse-dynamics idea, and it means you can learn a steerable simulator from pure observation logs. The recovered codes will not be labeled "turn left" or "open gripper," but they are consistent and disentangled enough to be mapped to real controls with a handful of labeled examples afterward.

In practice: a mobile warehouse robot with unlabeled camera logs

A logistics team has 4,000 hours of forward-camera video from its autonomous mobile robots but discarded the wheel-command logs years ago in a storage cleanup. They train a Genie-style model on the raw frames. The latent action model, forced through an eight-code bottleneck, settles on codes that correspond to recognizable maneuvers: two codes turn the view left and right, one drives forward, others handle stops and pivots. With just 200 clips where the team does still have commands, they fit a tiny classifier from wheel commands to latent codes. Now they have a controllable neural simulator of their own aisles, and can roll out "what if the robot rounds this shelf faster" scenarios to stress-test the perception stack, all without ever recovering the lost command logs. This is the same synthetic-environment logic that Chapter 58 uses to pretrain embodied policies.

The snippet below is a minimal latent action bottleneck: an inverse-dynamics encoder reads two frames, quantizes the transition to one discrete code, and a forward model must reconstruct the next frame from the current frame plus that code alone. It is the LAM idea stripped to its skeleton, runnable as a single forward pass on random tensors.

import torch, torch.nn as nn

class LatentActionBottleneck(nn.Module):
    def __init__(self, d=64, n_actions=8):
        super().__init__()
        self.inverse = nn.Linear(2 * d, d)         # (o_t, o_{t+1}) -> action query
        self.codebook = nn.Embedding(n_actions, d) # the tiny discrete action set
        self.forward_model = nn.Linear(2 * d, d)   # (o_t, action) -> o_{t+1} hat

    def infer_action(self, o_t, o_next):
        q = self.inverse(torch.cat([o_t, o_next], dim=-1))
        # nearest codebook entry = the discrete latent action (VQ, argmin distance)
        dist = torch.cdist(q, self.codebook.weight)
        idx = dist.argmin(dim=-1)                   # one of n_actions, per sample
        return idx, self.codebook(idx)

    def predict_next(self, o_t, action_vec):
        return self.forward_model(torch.cat([o_t, action_vec], dim=-1))

torch.manual_seed(0)
model = LatentActionBottleneck()
o_t, o_next = torch.randn(4, 64), torch.randn(4, 64)   # 4 frame-pairs
idx, a_vec = model.infer_action(o_t, o_next)
o_hat = model.predict_next(o_t, a_vec)
print("inferred latent actions:", idx.tolist())        # e.g. [3, 1, 3, 6]
print("next-frame prediction shape:", tuple(o_hat.shape))
A stripped-down latent action model. The inverse encoder proposes an action from a frame pair, vector quantization snaps it to one of eight codes (the low-bit bottleneck that forces the code to carry control, not appearance), and the forward model must reconstruct the next frame from that code alone. Training would minimize next-frame reconstruction error; here we run one forward pass to show that untrained frame pairs already resolve to discrete action indices.

The right tool: the discrete bottleneck in one line

Hand-rolling a stable vector-quantization layer (straight-through gradients, codebook commitment loss, dead-code restarts, exponential-moving-average updates) is roughly 60 lines of subtle code that is easy to get wrong. A maintained library gives you a trained-quality quantizer as a drop-in module:

from vector_quantize_pytorch import VectorQuantize
vq = VectorQuantize(dim=64, codebook_size=8, kmeans_init=True)
quantized, action_idx, commit_loss = vq(action_query)  # commit_loss joins your objective
The vector-quantize-pytorch library collapses about 60 lines of straight-through VQ machinery into a single module call, handling the commitment loss and codebook health that make latent action models actually train. You keep only the design choice that matters: codebook_size, the number of latent actions.

Rolling it out: uses, costs, and failure modes

How you use it. Three patterns dominate for sensing. First, counterfactual sensor futures: fix a starting frame, sweep the action, and read off how the stream would differ, which is a controllable cousin of the anticipation methods in Section 53.6. Second, synthetic interactive data: generate labeled rollouts to augment training sets, the neural-simulator side of the digital-twin toolkit in Chapter 55. Third, a sandbox for policies, where an agent trains inside the learned world before touching hardware.

What it costs and where it breaks. Generative rollouts are expensive: predicting every token of every frame is orders of magnitude more compute than a compact latent step, and long rollouts drift as small per-step errors compound, so consistency degrades over time. Frame rate has historically been low, and the model can hallucinate plausible-but-wrong physics because it optimizes visual likelihood, not force balance. Treat its output as a hypothesis to be checked, never as ground truth, and keep synthetic and real streams strictly separated when you evaluate, following the leakage discipline of Chapter 5.

Research Frontier

The generative-world-model line is moving fast. Genie 2 (DeepMind, December 2024) lifted the idea into 3D, turning a single image into an explorable environment with object interactions and short-term memory over roughly a minute. Genie 3 (DeepMind, August 2025) pushed to real-time interaction at 720p and around 24 frames per second, holding scene consistency for several minutes and accepting "promptable world events" that inject changes mid-rollout. In parallel, driving-focused world models (for example NVIDIA's Cosmos platform, 2025) target sensor-realistic camera and lidar rollouts for autonomous-vehicle simulation. The open frontier is physical fidelity and horizon: making the generated stream obey conservation laws and stay coherent for minutes rather than seconds, which is exactly what the benchmarks in Section 53.7 are built to measure.

Exercise

Take the LatentActionBottleneck above and turn it into a trainable toy on a controllable stream you generate yourself.

  1. Make a 1-D "world": a point on a line whose position is the observation, moved each step by one of three true actions (left, stay, right). Generate 5,000 consecutive (\(o_t, o_{t+1}\)) pairs, keeping the true action hidden.
  2. Train the module to minimize next-frame reconstruction error, with n_actions=3, adding a small VQ commitment loss.
  3. After training, build the confusion matrix between the model's inferred latent code and your hidden true action. Does each true action map to a stable code?
  4. Now set n_actions=8 and retrain. What happens to the extra five codes, and what does that tell you about choosing the codebook size?
Hint

Expect a permutation, not identity: the model has no reason to name your "left" as code 0. Score with cluster-agreement metrics (or best-match accuracy over label permutations), not raw equality. With too many codes, expect either dead codes or a single action split across several near-duplicates.

Self-check

  1. What single design choice forces the latent action code to capture "the controllable change" rather than the frame's appearance, and why does making the bottleneck wider defeat it?
  2. Why can a Genie-style model be trained on sensor archives that a supervised world model cannot use at all?
  3. Give one sensing task where generating the full observation is essential, and one where the compact latent of Section 53.2 would be the better, cheaper choice.

What's Next

In Section 53.5, we stop admiring the simulator and start acting inside it. You will see how planning and control move into the latent space of a world model, using either the compact rollouts of DreamerV3 or the controllable generations covered here, so that an agent can search over action sequences and pick the one whose imagined future it likes best, all before a single real actuator moves.