Skip to content

Concepts ​

What a world model is ​

A world model is a learned model of how an environment changes. An agent acts, its actions change a hidden state of the world, and it receives partial observations of that state. A world model captures this loop: from what has been observed and an action, it predicts what comes next. An agent that can predict the consequences of its actions can rehearse them before taking them: it can plan, learn a behavior inside its own imagination, or simulate rare events instead of waiting for them.

The idea is old. Kenneth Craik suggested in 1943 that minds reason with "small-scale models" of reality, Schmidhuber trained recurrent networks to predict their own future inputs in 1990, and Ha and Schmidhuber's World Models (2018) trained agents inside a dream of their own making. Since then the field has split along two questions: what the model outputs, and what it is trained to predict.

What a world model outputs ​

Different consumers need different projections of the same agent–world loop. World Labs' functional taxonomy sorts world models by output:

kindoutputsjudged byexamples
rendererobservations: pixels for a viewer, often in real time from user inputvisual fidelityGenie 3, interactive video generators
simulatorstate: geometry, physics and dynamics a program or a person can querystructural and physical accuracy3D scene generators, physics-engine digital twins
planneractions: what to do next, given an observation and a goalwhether the agent reaches the goalmodel-based control, vision-language-action models, world action models

The kinds share what they must know about geometry, physics and dynamics, and they are converging: renderers become action-conditioned, and planners use pretrained video renderers as their backbone.

torch_world is about planners: every world model here exists to choose actions. Internally, each still renders or simulates in its own way, and the families differ in what they predict.

What a world model predicts ​

approachpredictstrained byin torch_worldelsewhere
latent predictionthe embedding of the next observationprediction error in embedding space, plus a term against collapseJEPA (LeWM, RoboJEPA), DINO-WMV-JEPA 2-AC
value-equivalent latentsthe next latent, the reward and the value of what followslatent consistency and temporal-difference learning, no decoderTD-MPC2MuZero
generative video and actionfuture frames (as video-VAE latents) and the action chunk that produces themdenoising (flow matching)world action models (DreamZero), LeWAMvideo-pretrained robot policies
reconstructionthe next latent state, and pixels from itlikelihood of the observationsPlaNet, Dreamer

Predicting pixels makes the model account for everything in the frame, including texture and noise that do not matter for control; predicting only embeddings or values lets it spend capacity on what is predictable and relevant, at the cost of needing another way to keep the representation from collapsing. Generative models pay for pixels but inherit what large video datasets know about how the world moves.

The families also include representation learners that are not world models on their own, such as I-JEPA, V-JEPA, LeJEPA and DINOv2. They pretrain the encoders that world models build on: DINO-WM plans on frozen DINOv2 features.

Predict representations, not pixels ​

The latent approach is the oldest family in torch_world. A joint-embedding predictive architecture (JEPA) encodes a context and a target and trains a predictor to map the context's embedding to the target's. It never reconstructs pixels, so capacity goes to what is predictable rather than to texture and noise.

The hard part is collapse: a constant embedding predicts itself perfectly. Models in torch_world avoid it in one of these ways:

strategyhowmodels
EMA teachertargets come from a slowly updated copy of the encoder, with stop-gradientI-JEPA, V-JEPA, DINOv2
distribution regularizerSIGReg pushes embeddings toward an isotropic GaussianLeJEPA, LeVJEPA, LeWM, LeWAM
frozen encodera pre-trained encoder is not trained at allDINO-WM, RoboJEPA
contrastiveInfoNCE pushes non-matching pairs apartVL-JEPA
reward and valuethe latent must predict reward and value, which a constant cannotTD-MPC2

From JEPA to world model ​

When the context is the present and the target is the future, and the predictor also reads the action taken, the JEPA becomes a latent world model: it imagines the consequence of an action in embedding space. Planning then searches for the actions whose imagined outcome lands closest to the embedding of a goal.

A latent world model, planning toward a goalThe observation is encoded to a latent z_t. The predictor maps z_t and an action a_t to a predicted next latent, and rolls out over several steps. A cost compares the final predicted latent with the encoded goal image, and the planner adjusts the actions to lower it.imaginegoalobservationencodeztpredictẑt+1rolloutẑTcostatplan: lower the costgoal imageencodezgoal
Encode the present, imagine the future one action at a time, and plan by searching for the actions whose imagined outcome lands closest to the goal.

Three ways to choose actions ​

Every world model here imagines with the same rollout; they differ in what the imagined future is scored against and where candidate actions come from.

planningscores imagined futures byproposals frommodels
goal reaching with CEMdistance of the final latent to the goal's (cost)a Gaussian, refit to the bestLeWM, DINO-WM, RoboJEPA, any WorldModel
reward with MPPIimagined rewards plus a learned value at the horizona Gaussian and the policy priorTD-MPC2
policy sampling with WAMPlannerthe model's own dynamics, toward the goalthe model's action head (sample_actions)DreamZero (closed loop with DreamZeroPolicy), LeWAM

Base classes ​

Every model subclasses one of three classes in torch_world.models.

base classyou writeyou get
JEPAforward(...) -> {"loss": ...}make_target_encoder, update_target(momentum)
WorldModelencode, predict(z, actions), forwardrollout, cost, planning with CEM
WorldActionModela WorldModel, plus sample_actions, predict_future and imagineplanning with WAMPlanner; decode when latents have a decoder

Conventions ​

Loss dicts. forward returns a dict with a scalar "loss" to backpropagate, plus its named components ("pred_loss", "sigreg_loss", ...) for logging.

Time is dim 1. Episodes and latents are (B, T, ...). For WorldModel, predict(z, actions) maps z[:, t] and actions[:, t] to a prediction of z[:, t + 1], for every t at once (teacher forcing).

Actions align with states. In collected episodes, actions[:, t] is applied at states[:, t] and produces states[:, t + 1]. The last action is padding.

History. WorldModel.history is the number of past latents the predictor sees. rollout slides a window of that length; None means the full past.

Masks are index tensors. A mask is a (B, K) tensor of token indices to keep, and a masking strategy returns lists of them, one per block. apply_masks gathers them and stacks multiple masks on the batch dim.

Videos are channels-first. VisionTransformer takes images (B, C, H, W) or videos (B, C, T, H, W); episodes from environments are (B, T, C, H, W), so transpose dims 1 and 2 before a video encoder.

Further reading ​