Basis Lab

Answers · How models work

What is actually stored in the state that a model carries forward?

In shortIt is a fixed-size block of numbers rewritten at each step from its old value and the new input, not a stored copy of earlier inputs.

A model's carried state is a fixed-size block of numbers, not a stored transcript of what it has seen. At step tt it is a vector hth_t, the same length as ht−1h_{t-1}, and it is produced by an update rule that reads only the old state and the current input: ht=f(ht−1,xt)h_t=f(h_{t-1},x_t).

ht=f(ht−1,  xt),dim⁡(ht)=dim⁡(ht−1)=nh_t = f(h_{t-1},\; x_t), \qquad \dim(h_t)=\dim(h_{t-1})=n

What the rule can read

Write the state as nn numbers. The update has no argument for xt−10x_{t-10}, no argument for the position tt, and no separate store that the current input can be written into and left alone. Anything from step t−10t-10 reaches step tt only by having been inside ht−11h_{t-11}, then ht−10h_{t-10}, and so on through every intermediate update. That is why the same function can run on a sequence of any length: it never needs to know how long it has been running, and the price is that it also cannot address an earlier position directly.

The fixed length is not a detail of notation. It means the model cannot defer the decision about what to keep: every input must be folded into the same nn numbers at the moment it arrives, and later inputs compete for the same coordinates. There is no growing buffer that can be sorted at the end.

Take the simplest update that mixes and forgets: ht=0.5ht−1+xth_t=0.5h_{t-1}+x_t, starting from h0=0h_0=0, with inputs 22, 44, 66. Then

h1=0.5(0)+2=2,h2=0.5(2)+4=5,h3=0.5(5)+6=8.5.h_1=0.5(0)+2=2,\quad h_2=0.5(2)+4=5,\quad h_3=0.5(5)+6=8.5.

The first input is not sitting in a slot. At step 3 its contribution is 0.50.5, because it was multiplied by 0.50.5 at step 2 and again at step 3; at step 4 it would be 0.250.25. After ten further updates its contribution is 2(0.5)10=2/1024=0.0019531252(0.5)^{10}=2/1024=0.001953125, which is still present in exact arithmetic and is far below what most downstream arithmetic will notice. After twenty further updates it is 2(0.5)20=2/1,048,576≈0.00000192(0.5)^{20}=2/1,048,576\approx0.0000019. This is the sense in which a state stands in for the past: the past is folded in, mixed with later items, and progressively attenuated unless the update rule is built to preserve it.

FIG 1A scalar state over three inputs
stepstate hwhat happened
10h_0=0. Nothing has been read.
22h_1=0.5(0)+2=2. The input 2 is the whole state at this instant.
35h_2=0.5(2)+4=5. The 2 has become 1 inside the state, and 4 has contributed 4.
48.5h_3=0.5(5)+6=8.5. The 2 has become 0.5, while 6 contributed 6.
4 steps
Each row is the entire state after that input. There is no row for the first input and no column that stores it; the single number has been rewritten twice since it arrived.

Why the transcript picture fails

The natural picture is a compressed transcript: some record of each earlier item, shortened but still addressable. The update rule above has no place to put such a record. It has one block of nn numbers, and every coordinate is rewritten from the whole previous block and the current input. No coordinate is reserved for the third sentence, or for the item at position 900; after enough updates, the only thing that can be said about an earlier item is whatever is still detectable in the transformed block. A transcript can be compressed by dropping words, but it retains a correspondence between locations and earlier events. A state does not promise that correspondence, and a trained one typically has information spread across coordinates rather than stored in named slots.

That is why inspecting a state does not tell you a list of remembered items. You can ask what the state does on a task, but you cannot read the third item off coordinate seven. The coordinates are a code, not an index.

Where the fixed size bites

If the state has n=512n=512 numbers, it has 512 numbers after one item and 512 after 10,000; the count is fixed before the sequence length is known. Keeping every position instead, at 128 numbers per item, gives 128×100=12,800128 \times 100=12,800 numbers after 100 items and 128×10,000=1,280,000128 \times 10,000=1,280,000 after 10,000. At 10,000 items that is 2,500 times the 512-number state, since 512×2,500=1,280,000512 \times 2,500=1,280,000. The fixed state is cheaper by a factor that grows with length, and the same fixed size is why something must be discarded: a summary of 10 items and a summary of 10,000 items have the same room, so the update rule has to decide what earns space while the sequence is arriving.

None of this says a fixed state must lose exact bits. If the update rule copies one coordinate straight through, that coordinate survives indefinitely, and gated rules can learn to hold a value for a long time. What the fixed size rules out is storing a separate entry for every past item. For a task that needs the gist, a fixed block is the right shape. For a question about a number in the fourth line of a table nine thousand words ago, a fixed summary is the wrong shape, and a design that keeps every position, or carries a fixed state plus a short exact window, is doing a different job.

Worth keeping

  • A carried state has the same number of slots at the first step and after a million steps.
  • The update at each step sees only the previous state and the new input, so an earlier item survives only by being transformed again and again.
  • A fixed state is the right shape for a summary and the wrong shape for exact recall of an arbitrary earlier item.

Where this goes next

This question is one step of Models That Carry a Memory, a course that works through its subject from the beginning. The page that teaches this part of it is A Fixed Summary Carried Forward, and it reads the whole way through whether or not you have an account.

What an account changes is the practice: problems standing under every idea, marked with a reason rather than a tick, in a copy of the course that is yours.

Read that pageThe whole course

Other questions people ask about this

  1. Why does a transformer need a cache that grows with sequence length?A transformer stores the key and value for every token it has already seen so later tokens can look back at them, and that store grows with the conversation.
  2. Why can a linear recurrence be computed as a convolution?Because a linear recurrence adds up past inputs with fixed decaying weights, and that weighted sum is a convolution with the recurrence's impulse response.
  3. How can a model remember a sequence without keeping every past input?A model can remember a sequence by keeping a fixed-size block of numbers and rewriting it at every step from its old value and the new input.
  4. How does a gate let information pass through unchanged?A gate lets old information take a direct additive route through the steps, with a learned fraction deciding how much survives each step.
  5. Why does the model get stuck repeating the same sentence over and over?The model is not stuck in a memory loop: once it has written a phrase, that phrase is in its context and makes writing it again more likely, so a decoder that always picks the top word cannot leave.
  6. Why does diffusion add Gaussian noise instead of any random corruption?Diffusion adds Gaussian noise because Gaussian errors combine exactly: each step keeps the spread fixed and gives a closed-form noisy picture at any later step, which makes the reverse step learnable.

Read alongside