Last chapter's state decayed by the same fixed factor every single step — whether the current token carried real information or was pure filler. A model that could tell the difference wouldn't decay on filler at all. What if and weren't fixed?
Step through the sequence. The faint curve is last chapter's fixed rule — it decays every step, filler or not. The bold curve is selective: dead flat through every run of zeros, then snapping instantly to a new value the moment a real signal arrives.
A selective state-space model (the mechanism behind Mamba) makes and functions of the current input instead of fixed constants:
- — the hidden state at time step .
- — the hidden state from the previous time step.
- — the current input.
- — the decay factor, now itself a function of the current input instead of a fixed constant.
- — the input gate, also a function of the current input instead of a fixed constant.
This chapter's selection rule is the simplest one that still makes the point — a token is either signal () or filler ():
- On filler: freeze the state
freezes the state exactly — nothing decays, because there's nothing worth forgetting from.
- On signal: overwrite it completely
overwrites the state completely — the model chooses to forget everything it was holding, on purpose, because something worth remembering just arrived.
Same 7-token sequence, same starting state, two different final answers. The selective rule's answer is exactly the sequence's last real value; the fixed rule's is a decayed, blended approximation of it — contaminated by a signal from four steps earlier that the fixed rule had no way to just drop.
Sequence — one signal, three filler tokens, a second signal:
- The first signal writes the state
is signal, so : .
- Three filler tokens change nothing
, each filler: gives every time. — the exact same number, three steps running.
- The second signal overwrites it completely
is signal again: . The isn't faded — it's gone, replaced outright, in exactly the step where replacing it was the right call.
Find the timestep, among the seven, where the fixed and selective models' states diverge the most.
"Forget on purpose" cuts both ways: the selective rule forgets nothing on filler and forgets everything on signal — both are choices, made per token, instead of one fixed rate applied uniformly. Real Mamba layers learn , , and the discretization step size as smooth functions of the input (not this chapter's hard on/off switch), so selection can be partial and learned rather than all-or- nothing. This closes out the mechanism side of the part. The last chapter puts a Transformer and a Mamba-style model side by side on one long sequence and watches the cost and memory gap this whole part has been building actually show up.