Glossary

World Models

The terms the World Models series uses, in plain words and short TypeScript.

30 terms

Aleatoric uncertainty

What nobody can know in advance, however much data there is. In the heater room it is the draughts: a gust arrives or it does not, and nothing in the log says which. More data does not shrink it. It can be measured, from how far a well-fitted model still misses, and a margin kept for it. The other kind is epistemic.

In the series: When the Model Doesn't Know

Backpropagation through time

How a model with a field is trained when the field is in no column of the log. Each prediction depends on the field, and the field depends on the step before, so the training walks an episode forwards, remembering the field at every step, and then backwards, passing each step's share of the error to the step that set its field.

// field[i + 1] = tanh(u * field[i] + input[i])
// blame[i] is how far a change in field[i + 1] would move step i's own error
let carry = 0, gradientU = 0;
for (let i = inputs.length - 1; i >= 0; i--) {
  const dField = blame[i] + carry;                // this step's error, and every later one
  const dPre = dField * (1 - field[i + 1] ** 2);  // back through the tanh
  gradientU += dPre * field[i];
  carry = dPre * u;                               // on to the step before
}

In the series: Latent State Is the Fields You Never Logged

Band

The range between the lowest and the highest forecast of an ensemble, step by step. It is wide where the members disagree and narrow where they agree. It says nothing about a mistake all the members share.

// forecasts: one row per member, one column per step
const low = (forecasts: number[][]) => forecasts[0].map((_, i) => Math.min(...forecasts.map(f => f[i])));
const high = (forecasts: number[][]) => forecasts[0].map((_, i) => Math.max(...forecasts.map(f => f[i])));

In the series: When the Model Doesn't Know

Bias

A weight that is added to every prediction whatever the inputs are. In a weighted sum it is harmless on the rows the model was fitted to, because the other weights make up for it. Away from those rows nothing makes up for it. A heater model with a bias of minus half a degree fitted the log as well as one without, and said an unheated room would settle 7.4 degrees colder than the air outside.

const change = w.leak * (outside - room) + (heaterOn ? w.heat : 0) + w.bias;
// heater off and change at zero: room = outside + w.bias / w.leak

In the series: Planning Against the Model

Blind forecast

A forecast of several steps in which the model never sees a real reading and starts each step from its own last guess. It is a rollout, and it is what a planner uses. The other way to run a model is one step ahead, shown the real reading every time, which is how a monitor uses it. A model can be close one step ahead and far out after twenty blind steps, because each step's error is the next step's starting point.

// one step ahead: shown every real reading
for (let i = 0; i + 1 < readings.length; i++) {
  guesses.push(model.act(readings[i], actions[i]));
  model.observe(readings[i], actions[i], readings[i + 1]);
}

// blind: its own guess is the next starting point
let state = readings[from];
for (const action of plan) {
  state = model.act(state, action);
  forecast.push(state);
}

In the series: Latent State Is the Fields You Never Logged

Bootstrap

A way to find out how far a number worked out from one sample can be trusted, published by Bradley Efron in 1979. Draw a new sample from the old one, the same size, with replacement, and work the number out again. Do that many times and the spread of the answers estimates how far the number would have moved if the data had come out differently.

function resample<T>(items: T[]): T[] {
  return Array.from({ length: items.length }, () => items[Math.floor(Math.random() * items.length)]);
}

function bootstrap<T>(sample: T[], statistic: (items: T[]) => number, times: number): number[] {
  return Array.from({ length: times }, () => statistic(resample(sample)));
}

In the series: When the Model Doesn't Know

Conditional probability

The probability of one thing given another, written with a bar: P(next | state, action). Computed from a log it is a filter and a count. Keep the rows where the condition held, then tally what happened next.

function pNext(log: Row[], state: string, action: string): Map<string, number> {
  const matches = log.filter(row => row.state === state && row.action === action);
  const odds = new Map<string, number>();
  for (const row of matches) {
    odds.set(row.next, (odds.get(row.next) ?? 0) + 1 / matches.length);
  }
  return odds;
}

It stops working when the state is a continuous reading, because an exact reading almost never recurs and the filter comes back empty. A fitted model is what answers then.

In the series: The World Model Equation Is a WHERE Clause

Cost function

The score a planner gives a plan, lower being better. It is where a goal stated in words becomes arithmetic. For the heater it is one point per heater step and a hundred per degree that any predicted reading falls short of the target.

function cost(temps: number[], heater: boolean[], target: number[]): number {
  let total = 0;
  temps.forEach((temp, i) => {
    if (heater[i]) total += 1;
    if (temp < target[i]) total += 100 * (target[i] - temp);
  });
  return total;
}

The post's version also takes a hundredth of a point off for having room to spare, so that between two plans with the same heater steps the safer one wins.

In the series: Planning Against the Model

Cross-entropy method

A search for a good plan when there are too many plans to try them all. It keeps a probability for each step that the heater is on, starting at a half. Each round it draws a batch of schedules from those probabilities, scores them, keeps the best tenth, and sets each step's probability to how often the best tenth had the heater on there.

type Score = (plan: boolean[]) => number;

function search(score: Score, steps: number, batch = 200, rounds = 6): boolean[] {
  let odds = Array(steps).fill(0.5);
  let best: boolean[] = [];
  for (let round = 0; round < rounds; round++) {
    const draw = () => odds.map(p => Math.random() < p);
    const plans = Array.from({ length: batch }, draw);
    plans.sort((a, b) => score(a) - score(b));   // lowest cost first
    const elite = plans.slice(0, batch / 10);
    odds = odds.map((_, i) => elite.filter(plan => plan[i]).length / elite.length);
    best = plans[0];
  }
  return best;
}

In the series: Planning Against the Model

Deep ensemble

An ensemble of neural networks, each trained on all of the data from its own random starting weights. Each network answers with a mean and a variance. The average of the variances is the noise the networks expect, and the spread of the means is how far they disagree, so one ensemble reports both the aleatoric and the epistemic kind. From Lakshminarayanan, Pritzel and Blundell, 2017.

In the series: When the Model Doesn't Know

Ensemble

Several models of the same thing, fitted separately and asked the same question. Where their answers differ, the data has not settled the matter. The eight heater models are an ensemble made with the bootstrap.

In the series: When the Model Doesn't Know

Episode

One run of the room from a starting state, with its rows kept in order. The heater log is eighty episodes of sixty steps. A model with a field has to be trained on whole episodes, because each row's prediction depends on what the rows before it wrote into the field.

In the series: Learning the Heater From Its Own Logs

Epistemic uncertainty

What the model has not been shown. In the heater room it is a night ten degrees colder than anything in the log. More data from the right place shrinks it, and an ensemble's disagreement measures it. The other kind is aleatoric.

In the series: When the Model Doesn't Know

Field

The series' word for latent state: a value the model keeps for itself and updates from each reading, standing for something the log never recorded. In the heater room it ends up tracking a door nobody wrote down. It is in the model's own units, so two models can learn it with opposite signs and make the same predictions.

class Model {
  #field = 0;                                         // lives here, and nowhere in the log
  observe(state: State, action: Action, next: State) { /* fold what just happened into #field */ }
  predict(state: State, action: Action): State { /* the next state, given #field */ }
}

In the series: Latent State Is the Fields You Never Logged

Gradient descent

The way the weights are found. Start somewhere, measure how wrong the model is over the whole log, move each weight a little in the direction that reduces the error, and repeat. For a weighted sum scored by squared error, a weight's gradient is the error times that weight's input.

// one weight: predicted change = w * input
let w = 0;
for (let epoch = 0; epoch < epochs; epoch++) {
  let gradient = 0;
  for (const row of log) {
    const error = w * row.input - row.target;
    gradient += error * row.input;
  }
  w -= rate * gradient / log.length;
}

In the series: Learning the Heater From Its Own Logs

Hysteresis

The gap between the temperature at which a thermostat switches on and the one at which it switches off. Without it the heater would flick on and off around a single number. It also acts as a margin against draughts, because the room is held above the target and not at it.

function thermostat(roomTemp: number, want: number, heaterOn: boolean): boolean {
  if (roomTemp < want + 1) return true;       // on below a degree above what is wanted
  if (roomTemp > want + 1.7) return false;    // off 0.7 above that
  return heaterOn;                            // in between, left as it is
}

In the series: Planning Against the Model

Latent state

State the model keeps that is in no column of the log. Latent means hidden, and the one it is hidden from is whoever collected the data. The series calls it the field, and that entry has the code.

In the series: The World Model Equation Is a WHERE Clause

Loss

One number for how wrong a model is over the log. Here it is the mean squared error: the gap between each prediction and what happened, squared and averaged. Training drives it down, and it stops at the size of whatever the model cannot predict. The four-weight heater model flattens at 0.01, which is the variance of the draughts.

const loss = (errors: number[]) => errors.reduce((sum, e) => sum + e * e, 0) / errors.length;

In the series: Learning the Heater From Its Own Logs

Mean flow

A way to generate a picture from noise in one pass through a network. A diffusion or flow-matching model learns a velocity: at each point on the way from noise to picture, which way to move next. Drawing a picture means following that velocity in many small steps, and every step is a pass through the network. A mean-flow model learns the average velocity over the whole trip instead, so one pass makes the jump. From Geng, Deng, Bai, Kolter and He, 2025.

// flow matching: many small steps, one pass through the network each
let x = noise;
for (let k = steps; k > 0; k--) {
  const v = velocity(x, k / steps, features);
  x = x.map((value, i) => value - v[i] / steps);
}

// mean flow: the network gives the average velocity for the whole trip
const u = meanVelocity(noise, 0, 1, features);
const picture = noise.map((value, i) => value - u[i]);

features is the condition: what the picture has to be a picture of. Elon Musk described the model that draws the surroundings in Tesla's cars as a conditional mean-flow model, conditioned on the recent sequence of outputs from the car's vision encoder. In the heater's terms the encoder's outputs are the state, and the picture is decoded from it. Anything the state does not hold, the generator has to make up.

In the series: Latent State Is the Fields You Never Logged

Model predictive control

Plan a number of steps ahead, carry out only the first step, read what the room did, and plan again. The rest of each plan is thrown away and worked out afresh with one more reading. The series calls it replanning.

while (true) {
  const plan = search(p => cost(rollout(model, state, p)), 20);
  const next = room.step(plan[0]);                    // only the first step is carried out
  model.observe(state, plan[0], next);
  state = next;
}

In the series: Planning Against the Model

Particle

One imagined run of a plan through one member of an ensemble, with the noise that member expects drawn at every step. A plan is scored on many particles so that both the members' disagreement and the noise show up in the score.

In the series: When the Model Doesn't Know

PETS

Probabilistic ensembles with trajectory sampling, from Chua, Calandra, McAllister and Levine in 2018. The model is a deep ensemble with each network trained on a bootstrap resample. The planner is the cross-entropy method inside model predictive control, and a plan's score is its average cost over particles.

In the series: When the Model Doesn't Know

Random shooting

The simplest planner that does not try everything. Draw plans at random, score each one, keep the best. It fails when good plans are rare. With a hundred random heater schedules a time, four runs in a hundred found one that kept the room warm enough. The cross-entropy method is the same idea with each batch drawn from what the last one learned.

function shoot(score: (plan: boolean[]) => number, steps: number, tries: number): boolean[] {
  let best: boolean[] = [], bestScore = Infinity;
  for (let k = 0; k < tries; k++) {
    const plan = Array.from({ length: steps }, () => Math.random() < 0.5);
    const s = score(plan);
    if (s < bestScore) { best = plan; bestScore = s; }
  }
  return best;
}

In the series: Planning Against the Model

Recurrent state-space model

What DreamerV3 calls its world model. It does the job of observe and act in four parts, and it keeps two versions of its latent at every step: a guess made before the reading arrives and an answer made after. Part of its training is closing the gap between the two, and the guess is what lets it imagine many steps ahead with no readings at all.

interface RecurrentStateSpaceModel {
  carry(h: Recurrent, action: Action, z: Latent): Recurrent;    // the sequence model
  guess(h: Recurrent): Latent;                                  // before the reading
  encode(h: Recurrent, reading: Observation): Latent;           // after it
  decode(h: Recurrent, z: Latent): Observation;                 // back to a reading
}

In the series: Latent State Is the Fields You Never Logged

Representation collapse

A model scoring perfectly by declaring every state identical. It can only happen when the thing being predicted is something the model produces itself, such as its own summary of the next reading, since a summary that never changes predicts itself exactly. The heater model cannot do it, because its target is a thermometer reading it has no way to change.

In the series: Latent State Is the Fields You Never Logged

Rollout

The model called in a loop, each prediction fed back in as the next state. It is how a plan is tried without touching the hardware. Each step starts from the last step's guess, so errors add up along the way.

function rollout(model: Model, state: State, actions: Action[]): State[] {
  const states: State[] = [];
  for (const action of actions) {
    state = model.predict(state, action);
    states.push(state);
  }
  return states;
}

In the series: A World Model in Forty Lines of TypeScript

Shape

The form of a model's function, fixed before any fitting: which inputs it takes and how they are allowed to combine. The weights come from the log and the shape comes from outside it. Two shapes can fit the same log equally well and part company where the log has no rows, which for the heater was a night colder than any recorded.

// a weighted sum: the fit decides how the two temperatures combine
const free = w.room * room + w.outside * outside + w.heater * heater + w.bias;

// physics-shaped: the temperatures only ever appear as their difference
const shaped = (w.leak + w.doorLeak * field) * (outside - room) + w.heat * heater;

In the series: Planning Against the Model

Transition

One row of the log: the state, the action taken, and the state one step later. It is what telemetry looks like once the commands are joined on, and it is all a world model is trained from.

type Transition = { state: State; action: Action; nextState: State };

In the series: Learning the Heater From Its Own Logs

Weighted sum

The simplest model with a body nobody wrote. Multiply each input by a weight, add them up, and call the result the change in room temperature for the step. It can only learn relationships that are a straight line through the inputs it is given. The heater's first learned model is four weights.

const change = w.room * roomTemp + w.outside * outsideTemp + w.heater * (heaterOn ? 1 : 0) + w.bias;
const nextTemp = roomTemp + change;

In the series: Learning the Heater From Its Own Logs

World model

A function that answers one question: if things are like this and I do that, what happens next? It is learned from logs of state, action and next state, which is what telemetry with the commands joined on already is.

type WorldModel = (state: State, action: Action) => State;

The heater's model is nine weights and predicts one temperature. The same idea runs at the other end of the scale. In November 2026 Elon Musk wrote on X that Tesla has had a world model close to pixel-perfect since 2025, used to generate synthetic training data, and that its cars run a much smaller one that draws the surroundings from the recent outputs of the vision encoder the car drives from. Training data generated from a model is a rollout used as a log. The picture in the car is a latent state turned back into something a person can look at, the step the recurrent state-space model entry calls decode. The mean flow entry has how the small one is fast enough.

In the series: Your Time Series Is Already Training Data and The Heater Room So Far, in Seven Posts