Even last chapter's factored attention still needed a running state built from every key seen so far — the state's size didn't grow with , but building it required a full pass over the sequence up front. What if a model never needed to look back at all — just carry one number forward, one token at a time?
Click "process next token" a few times. There's no cache, no matrix, no list of past tokens anywhere — just one number, overwritten every step. Whatever happened three tokens ago only survives insofar as it's still baked into that one number.
A (linear) state-space model updates a hidden state with a plain recurrence and reads its output straight from that state:
- — the hidden state at time step : the one number the model carries forward.
- — the hidden state carried over from the previous time step.
- — the input at time step .
- — the output at time step , read straight from the hidden state.
- — the decay constant: with , how much of the previous state survives each step.
- — the constant controlling how much of the current input gets mixed into the state.
- — the constant mapping the hidden state to the output.
- A, B, C are fixed constants
In a real model these are learned; here they're chosen so every value is checkable by hand.
- A is a decay, and that's the whole point
With , older inputs' contributions shrink geometrically every step — the same exponential forgetting Part III's vanishing-gradients chapter treated as a bug. Here it's the entire mechanism: the state is supposed to fade.
Attention's memory (dashed) grows in lockstep with the sequence — every past token adds one more key-value pair to keep around. The state-space model's memory (bold) doesn't move: one number, whether the sequence is five tokens or five thousand.
Running over the sequence , starting from :
- t = 1
. Output: .
- t = 2
. The first input hasn't vanished — it's still in there, halved.
- t = 3
. Every step, everything already in the state ages by one more factor of :
- Token 1's contribution is now scaled by
- Token 2's contribution is scaled by
- Token 3's contribution is scaled by (just added, unchanged)
Find the timestep, among the five, whose hidden state has the smallest magnitude.
One update, one fixed-size state, memory that's flat no matter how long the sequence runs. The tradeoff this chapter doesn't show yet: , , here are the same three numbers at every timestep — the model can't decide to remember one token harder than another, or forget faster when it sees something irrelevant. Real state-space models like Mamba fix exactly that, and it's the next chapter's entire subject: what happens when , , and are allowed to depend on the current token instead of being fixed constants.