LLMs as World Models?

A language model can say what a room looks like after an action. Chain twelve actions and one early slip spreads: in this toy the plain model ends wrong on 3 of 4 objects. A state tracker that checks each step against the rules keeps all 4 right.

Learn what a language model can and cannot do as a world model: state, action, consequence, score.

Run all 12 actions with the plain model. Then switch on the state tracker and run them again. Slide the count back and watch where the first wrong cell appears. Then we build, piece by piece, the four roles of one model, probes, reasoning, imagined rollouts, executable code worlds and tests.

You need a little Python and the idea of a next-word predictor. We build the rest from zero.

Based on Lecture 19 of Penn CIS 6280: World Models (Fall 2026), taught by Jiatao Gu. Lecture slides. Every idea is re-taught here in our own words and devices. It follows Lecture 16, Learning 3D and 4D World Models in this series.

Predict the room, step by step

12

Illustrative: four objects (key, map, coin, lamp) and four places (table, chest, drawer, bag). Each step moves one object or empties one place into another. The "model" is a script. It applies each action to its own belief and slips at steps 3, 6 and 9. The tracker runs the rules on an explicit state and repairs the belief after each step. These are not measured model errors.

Chapter 0

Words Can Describe How a World Changes, and Drop Detail

See what a sentence keeps of a scene, and what it loses

A robot sees a red block and a blue block on a table. You say, "Place the red block on the blue block." You expect to read afterwards, "The red block is supported by the blue block."

PartExample
Current situationThe red and blue blocks are on the table.
Candidate actionPlace the red block on the blue block.
Predicted changeThe red block is supported by the blue block.

Earlier lectures stored the world as latent variables, video or 3D structure. This lecture asks a new question. Can an LLM (large language model, a network that writes text one piece at a time) do the same job in words?

Words chain well. Words also drop detail. Move the slider to find where.

What the sentence keeps

The sentence is always the same. Slide the true gap. Then switch the planner from the words to the numbers.

1.0 cm

Illustrative: each block is 6 cm wide. One gripper finger needs 2 cm of free space to reach the red block. The planner that keeps only the sentence assumes the space is free.

Course notes: November 24 is an invited lecture. The final project report and code are due December 14. Each team gets $100 of cloud compute.

  1. The gap is 1 cm. The sentence says "next to".
  2. The finger needs 2 cm. A plan from the sentence sends the finger in. It hits the blue block.
  3. A plan from the numbers sees 1 < 2. It pushes the blue block aside first. The grasp works.

Failure. Symptom: a plan that reads well and fails on contact. Measure: replay it in a simulator and count failed grasps. Fix: keep the numbers that decide the next action in the state.

The road for the rest of the lecture:

  1. Four roles: one model, four kinds of question.
  2. Reading a state: probes, rewards and values.
  3. Reasoning: where a consequence gets predicted.
  4. Acting and looking again: SayCan, ReAct, ASPIRE.
  5. PEAR: a prediction inside a robot policy.
  6. RAP: imagine two futures, send one action.
  7. Executable models: CWM and WorldCoder.
  8. Code, simulation and video: who computes the next state.
  9. Reliability: how to test a rollout.
  10. The field guide: numbers, code, links.
A planner reads "The red block is next to the blue block" and grasps. The true gap is 1 cm and the finger needs 2 cm. Why does it fail?

Chapter 1

One Model Plays Four Roles, and the Question Picks the Role

Change what you ask and the same weights state, choose, predict or judge

An LLM writes one token (a small piece of text or code) at a time. Each token it writes joins the context, the text the model reads, for the next one.

pθ(y | x)
The chance that the model writes the whole answer y after the context x.
∏k
Multiply over every token, one after another.
pθ(yk | x, y<k)
The chance of token k, given the context and the tokens already written.

Training sets the weights θ. Pretraining predicts the next token of recorded text and code. SFT (supervised fine tuning) predicts the next token of a demonstration. A new prompt changes the context. It does not change θ.

The four roles below use one model. Only the question and the context change.

QueryCondition onGenerate
State inferencehistory of observations and actionsa current-state description
Policyhistory + goala candidate action
Transitionhistory + candidate actiona predicted consequence
Evaluationoutcome + task criteriaa judgment or score

Ask the same model four questions

Pick a query. The weights box never changes. The input and the output do.

The scene is the red and blue block example from the lecture. The outputs are examples of what each query could return, not recorded model output.

A transition query predicts an observation before the action runs:

ôt+1
The predicted next observation. Nothing has run yet.
ht, at
The history so far and the candidate action.

Now chain predictions. Say each predicted state is right 95% of the time.

  1. After 2 steps: 0.95 × 0.95 = 0.9025.
  2. After 4 steps: 0.9025 × 0.9025 = 0.8145.
  3. After 8 steps: 0.8145 × 0.8145 = 0.6634.
  4. After 12 steps: 0.8145 × 0.6634 = 0.5404. The chain is right about 54% of the time.

Failure. Symptom: you ask what to do and get what happens, or the reverse. Measure: log the role of each call and compare its inputs with the table. Fix: name the role in the prompt, and pass the action only to the transition query.

Which inputs does a transition query need?

Chapter 2

Reading a State Is Not Predicting a Change

Separate a probe from a transition test, then separate reward from value

You read: "A key is inside an open chest. You pick up the key." Where is the key now? In your hand. Is the chest empty? Yes.

Li, Nye and Andreas (ACL 2021) ask if such facts can be read from the internal vectors of BART and T5 models. The story advances one event at a time. Gurnee and Tegmark (ICLR 2024) read place locations from Llama 2 vectors. Both use a probe: a small model trained to read one property from a larger model's internal vectors.

A probe shows that the fact is present. It does not show that the model can predict what happens if it acts here. That needs a separate prediction test. Try both below.

Read it, or predict it

Press an event. Then switch on "Ask first" and press again: the model predicts the result and nothing changes.

Illustrative: a four-rule toy world. A closed chest blocks picking up the key and putting it in. The "prediction" is computed by the rules, as a stand-in for a model's answer.

Goals need a score. Language to Rewards (CoRL 2023) has the LLM write a motion description and reward parameters, and MuJoCo MPC searches with the physics model. Eureka (ICLR 2024) writes reward code, trains a policy with RL, and revises the code from training feedback.

NameQuestionMeaning
Reward rtDid this transition help?A score for a state, action or outcome.
Value Vπ(st)How promising is this situation?Expected future return under a stated continuation.

A discount γ shrinks a reward by γ for each step you wait. Take γ = 0.9 and a reward of 1 at the goal. A state 3 steps away has value 0.9 × 0.9 × 0.9 = 0.729.

Failure. Symptom: the model answers "where is the key" and still fails after a new action. Measure: compare predicted and executed results on actions held out of the story. Fix: test read-outs and transitions as two separate tests.

A probe decodes where the key is with high accuracy. What does that show?

Chapter 3

Reasoning Is Where the Consequence Gets Predicted

Watch intermediate text predict a result before the model acts

The task: "Place red on blue." Blue is covered by a green block. The command pick_place(red, blue) fails, because blue is not clear. What should the model write first?

With chain of thought the model writes intermediate text z before the final command a. The weights θ stay fixed.

(z, a)
The reasoning text z and the final command a.
pθ(z | h, g)
The model writes its reasoning first, from the history h and the goal g.
pθ(a | h, g, z)
Then it writes the command, with its own reasoning in the context.
FunctionWhat the text says
Infer the stateBlue is covered. Red is on the table.
Set a subgoalClear blue before stacking red.
Predict a consequenceMoving the covering block will leave blue clear.
Evaluate and decideThat enables the goal. Move it, then check the result.

This is one possible process. The functions need not be separate networks.

Stack red on blue

Pick commands until red is on blue. A blocked command costs a turn. Switch on "Think first" to see each command's predicted result before you press.

Illustrative: three blocks and a simulator. A block can move only if nothing is on it and its target is clear. The "thinking" lines come from the simulator, as a stand-in for model reasoning.

RL trains the model itself. RL (reinforcement learning) scores outputs that the model made. SFT gives an output to copy.

  1. Sample several reasoning traces and answers.
  2. Score each with a test, a verifier or a reward model.
  3. Update the LLM so the relatively better outputs become more likely.
J(θ)
The score RL raises: the average reward of the model's own answers.
Ey ~ πθ
Average over responses y that the model samples for the task x.
R(x, y)
The reward for response y, reasoning included.

Worked toy: four samples earn rewards 1, 0, 0, 1. The mean is 0.5. Relative scores are +0.5, −0.5, −0.5, +0.5. The update raises the first and the last.

Failure. Symptom: fluent reasoning, wrong plan. Measure: compare each predicted consequence with the executed result. Fix: score with a test, and run the action before you trust the text.

In the blocks task, what makes the reasoning step useful before the first command?

Chapter 4

Acting and Looking Again: SayCan, ReAct and ASPIRE

Choose a skill that is useful and likely to work, then read the real result

A robot has a library of skills. You say, "I spilled my drink." Which skill should it run first? SayCan (Ahn et al., Google Robotics, 2022) scores each skill twice.

CheckQuestion
Task relevanceDoes this skill help satisfy the instruction?
FeasibilityCan the skill succeed in the current situation?
ExecutionRun the selected skill, then choose again.

Choose a skill

Relevance is fixed. Move the feasibility sliders, then switch feasibility on and off.

0.20
0.90
0.90

Illustrative: the relevance numbers (0.60, 0.30, 0.10) and the product rule are a toy. They are not SayCan's measured values.

Default numbers: sponge 0.60 × 0.20 = 0.12. Sink 0.30 × 0.90 = 0.27. Apple 0.10 × 0.90 = 0.09. The sink wins. Relevance alone picks the sponge, which the robot cannot reach.

ReAct (Yao et al., ICLR 2023) adds real feedback. The model writes a thought and an action. The environment answers. The answer joins the history and generation continues.

WhoText (ALFWorld, condensed)
LLM thoughtI need the keychain before I can put it in the safe.
LLM actionOpen the drawer.
EnvironmentThe drawer contains a keychain and a watch.
LLM continuationThe keychain is visible. Take it from the drawer.

Experience can change two different things. In agentic RL (CWM, Section 5) tool results join the history, external tests score the outcome, and the LLM weights update. In ASPIRE (Lu et al., 2026) the model writes a robot program, runs it, reads the execution trace and repairs it. The weights stay fixed. The program and the skill library change.

Failure. Symptom: the robot picks a useful skill that cannot succeed. Measure: the success rate of the chosen skills. Fix: score feasibility next to relevance.

The sponge has relevance 0.60 and feasibility 0.20. The sink has 0.30 and 0.90. Which skill does SayCan-style scoring pick?

Chapter 5

Find the Prediction Inside a Robot Policy: PEAR

Look for a consequence the policy predicts before it moves

A robot arm must pick up a spray can. The model sees camera views, robot pose and gripper width, and writes the next arm or gripper command. The lecture asks where the world model is in that loop. The example is one recorded pickup by Qwen3.8-27B-PEAR on RoboDojo.

The policy part chooses the next command. The world-model part reasons about what that command will do in the current physical situation. The lecture shows three local judgments, paraphrased from an episode report.

PartJudgment (paraphrase)
RepresentationThe can is probably grasped. The arm may be at its reach limit.
PredictionRetracting while lifting may let the hand rise farther.
InteractionExecute the command, observe the motion, revise the hypothesis.

The prediction depends on both the arm configuration and the action. Lifting straight up gave no more height. Retracting while lifting did. The inferred constraint is a hypothesis.

Gripper width gives a second example. If closing should stop at contact and the fingers stop early, something is between them.

Read the gripper

The close command targets 0 cm. Slide where the fingers stopped. Then supply the closing rule.

3.5 cm

Illustrative: widths in centimetres and the 0.5 cm tolerance are a toy. In the lecture's report, the stopping rule was supplied in the interface and the LLM applies it to this scene.

  1. Expected: closing on nothing ends at 0 cm.
  2. Observed: the fingers stop at 3.5 cm.
  3. The gap to target is 3.5 > 0. With the rule, the model infers that the can is probably between the fingers.

Failure. Symptom: the model calls a grasp secure after contact. Measure: lift and check that the object rises. Fix: treat contact as a hypothesis, not a result.

The close command targets 0 cm. The fingers stop at 3.5 cm. What can a model infer, given the closing rule?

Chapter 6

RAP Imagines Two Futures and Sends One Action

Predict the state after each candidate, score it, and search

Blocksworld: orange and blue are clear on the table and the hand is empty. The goal: orange on blue. RAP (Hao et al., EMNLP 2023) turns the LLM into both a scorer of actions and a predictor of states.

  1. Propose: list the legal actions and score them with the LLM.
  2. Predict: ask the LLM for the resulting state.
  3. Search: explore the promising action sequences.
A(st)
The legal actions in the current state.
ŝt+1
The predicted next state. It becomes the context for the next step.
pθ
The LLM, used as a next-state predictor.

The model imagines both branches. Neither has run. A goal-condition score compares predicted block relations with the goal. Search compares continuations. Only the chosen action goes to the environment.

Search two futures

Slide the look-ahead. Then make the model mispredict candidate A.

2

Illustrative: a real two-block search with three move types (pick up, stack, put down). The score is the number of actions to reach the goal. A wrong prediction here means the model says A leaves the hand holding blue.

  1. A: pick up orange (1), stack it on blue (2). Goal in 2 actions.
  2. B: pick up blue (1), put it down (2), pick up orange (3), stack (4). Goal in 4 actions.
  3. At look-ahead 2, A reaches the goal and B does not. A wins.

Failure. Symptom: search ignores the best branch. Measure: compare predicted states with executed states on one step. Fix: check the first-step prediction before you chain it.

In RAP, what is sent to the environment?

Chapter 7

Executable World Models Move the Rules into Code

Learn the transition from execution traces, or write it as a program and revise it

A program that acts returns a command. A program that predicts returns a consequence. The inputs and outputs decide the role.

python
def choose_action(history, goal):      # a program that acts
    return pick_place("red", "blue")      # returns a command to execute

def step(state, action):               # a program that predicts
    next_state = apply_rules(state, action)
    return next_state                  # returns a consequence for a supplied action

CWM (FAIR CodeGen team, Meta, 2025) is a 32B decoder-only LLM trained on execution. Python traces pair each executed line with the change in local state. Docker interaction pairs commands with feedback from a software environment. Execution gives the target for prediction.

L(θ)
The training loss. It falls when the recorded outcome gets more likely.
pθ(ot+1 | ht, at)
The chance the model gives the recorded next observation, after the history and the action.

The same experience trains two skills. "What followed this action?" has the recorded next observation as target and teaches prediction. "Which choices led to success?" has a reward and teaches the policy.

WorldCoder (Tang, Key and Ellis, NeurIPS 2024) writes Python rules instead. It observes states, actions and results, writes the rules, then runs the model to plan. A surprise changes the model. Add the rule, then recheck the earlier transitions.

Revise the model

A row of 6 cells has two teleporters (purple). Replay more recorded transitions. Then add the rule.

1

Illustrative: a one-row version of the lecture's schematic teleporter case (Sokoban with teleporters). The recorded transitions are made up.

Replay 2 shows the first counterexample. Replay all 6 and the model without the rule misses 2 of 6. With the rule it misses 0.

Failure. Symptom: a model that fits the first few moves and fails later. Measure: replay all recorded transitions after every edit. Fix: add the rule, then recheck the old ones.

A rule model misses 2 of 6 recorded transitions. What does WorldCoder-style repair do?

Chapter 8

Code, Simulation and Video: Who Computes the Next State?

Keep the state in a program and let a video model draw it

Four systems from this lecture compute the next state in four different ways. They can be combined.

SystemNext-state computationObservation or evaluation
Interactive agentThe actual environment evolves.Sensors and external task feedback.
Language rolloutThe LLM predicts a state description.Task rules or a learned evaluator.
Executable world modelGenerated code executes transition rules.Program output, checked against evidence.
Simulation + videoA simulator advances the proxy world.A generative model renders observations.

GPT4Motion (Lv et al.) splits the work. GPT-4 writes a Blender scene and simulation script. The simulation renders depth and edges. An image diffusion model draws the appearance.

Coding Agent as World Brain (Chen, Lin and Zhang, 2026) keeps persistent state and rules in a program. A coding agent edits them, and a video model renders frames from a proxy. Mundo builds a 3D proxy and an executable scene from context images.

Where does the state live?

A cup goes behind a wall. Slide how long it stays hidden. Then move the state from the recent frames into a program.

6 frames

Illustrative: a model that sees only its last 4 frames. The window size is a toy value, not a property of any named system.

  1. The window holds 4 frames.
  2. The cup is hidden for 6 frames. 6 > 4.
  3. After the 4th hidden frame the window holds no sighting. The frame-only model has lost the cup. The program still lists it.

Failure. Symptom: an object vanishes after it leaves the view, then reappears changed. Measure: hide an object for longer and longer, and find where identity breaks. Fix: keep persistent state outside the frames.

In a simulation plus video system, which part computes the next state?

Chapter 9

Can You Trust the Rollout? Test the Prediction Itself

Catch a model that grades its own mistake, and a reward that misses the goal

A robot assumes it holds the object securely. It predicts that a lift will raise the object. It judges that the action will finish the task. The assumption was wrong, and it entered both the prediction and the judgment.

Lift, then grade the lift

Slide the true grip. Three graders look at the same lift. Then add the object to the reward.

0.30

Illustrative: the grip is secure at 0.5 or more, and the hand always rises to 30 cm. This is a teaching case, not a reported Eureka experiment.

  1. True grip 0.30 is below 0.5. The grip is not secure.
  2. The hand rises to 30 cm. The object stays at 0 cm.
  3. The self-check passes, because it shares the assumption. A hand-height reward gives full credit. The object check fails.
RiskWhat goes wrongCheck
Text loses detailPose, clearance and friction drop out.Choose an abstraction that keeps what the next action needs.
Self-evaluationOne wrong assumption enters prediction and judgment.An external check on the result.
Incomplete rewardCredit without the missing condition.State every condition of the intended behavior.
Time scaleSlow task reasoning meets fast motion.Match action duration and feedback rate to the environment.
Looks rightA frame looks plausible but drifts.Score visual quality and fidelity to the world separately.
CapabilityA direct test
State inferenceCheck the inferred relations against observations.
World predictionCompare predicted and executed results of held-out actions.
EvaluationCheck judgments against external task criteria.
Reasoning benefitHold tools and compute fixed. Test whether the predictions improve decisions.

Failure. Symptom: a high score and a failed task. Measure: the object height after the lift, from outside the model. Fix: test the prediction first, then test whether reasoning uses it.

The hand reaches 30 cm. The object stays on the table. The reward gives credit for hand height only. What does the reward report?

Chapter 10

Field Guide: Numbers, Terms, Code and Where to Go Next

Keep the lecture on one page

World modeling can be part of reasoning. Keep track of what is true. Predict and decide. Make predictions executable so that reasoning can query them.

The numbers to remember

IdeaNumberChapter
Toy room, 12 actionsplain model wrong on 3 of 4 objects; tracker 0 of 4Hero
Gap vs finger (toy)1 cm gap, 2 cm needed: the sentence plan fails0
Chained predictions (toy)0.95 per step, 12 steps: 0.54041
Discounted value (toy)0.9 × 0.9 × 0.9 = 0.7292
Relative RL score (toy)rewards 1, 0, 0, 1: +0.5, −0.5, −0.5, +0.53
Skill scores (toy)0.12 sponge, 0.27 sink, 0.09 apple4
Gripper stop (toy)target 0 cm, stopped at 3.5 cm5
Search length (toy)A: goal in 2 actions. B: 4 actions6
Replay (toy)2 of 6 transitions missed without the rule7
Window (toy)4 frames kept, 6 hidden: object lost8
Hand-height reward (toy)hand 30 cm, object 0 cm: full credit, failed task9

The terms

TermPlain meaningChapter
LLM, token, contexta text writer, its small piece, and what it reads0, 1
State inference, policy, transition, evaluationfour queries to one model1
Probea small model that reads a fact from internal vectors2
Reward, value, discounta step score, a future score, a shrink per step2
Chain of thoughtreasoning text written before the command3
RL, SFTlearn from scored outputs, or copy a demonstration3
SayCan scoretask relevance with feasibility4
ReAct, ASPIRE, agentic RLact and read feedback; repair a program; train on trajectories4
RAP, goal-condition scoreimagined rollouts; predicted relations versus the goal6
CWM, WorldCoderlearn from execution; write rules as code7
Persistent statestate kept outside the generated frames8

A checklist before you trust a rollout

The core as code

python
def rollout(state, actions, rules):               # Ch 7: explicit state, rules run every step
    for a in actions:
        state = rules(state, a)                   # one program, one source of truth
    return state

def replay_misses(rules, recorded):             # Ch 7: recheck all old transitions
    return [t for t in recorded if rules(t.state, t.action) != t.next_state]

def saycan_pick(skills, relevance, feasibility):  # Ch 4
    return max(skills, key=lambda s: relevance[s] * feasibility[s])

def chain_ok(p_step, n):                         # Ch 1: 0.95, 12 -> 0.5404
    return p_step ** n

def value(gamma, steps_to_goal):                 # Ch 2: 0.9, 3 -> 0.729
    return gamma ** steps_to_goal

Run chain_ok(0.95, 12) and you get 0.5404. Run saycan_pick on the Chapter 4 numbers and you get the sink.

Where this sits

Lecture 16 learned 3D and 4D worlds from images. This lecture asks whether language and code can carry a world model. Lecture 14 showed interactive world models that respond to actions.

Keep going

Source: Penn CIS 6280: World Models, Fall 2026, Jiatao Gu. Lecture 19 slides.

The takeaway. Ask four questions of any language-model world model: which role is this query, did anything actually run, what detail did the text drop, and who checked the result.
An LLM writes a predicted state. A program then checks the move against the rules and repairs the state. Which row of the "who computes the next state" table is this closest to?