State space model
In short
A state space model reads a sequence by keeping one hidden state and updating that state with each new input, instead of looking back at every earlier step.
- Also called
- SSM, State-space model
- Topic
- How AI models work
- Level
- Some background helps
In the continuous-time form used by Gu, Goel and Ré, a state space model maps an input u(t) to an output y(t) through a latent state x(t)1. The state moves by x'(t) = A x(t) + B u(t), and the output is y(t) = C x(t) + D u(t)1. They describe these models as a foundational tool in control theory, not a method invented for chatbots1. Gu and Dao say the structured deep-learning versions take their inspiration from classical state space models, citing Kalman (1960)2.
In discrete time the same model is a recurrence: the new state depends only on the previous state and the new input1. When the rule does not change with time, it can also be a convolution and trained in parallel1. Their 2021 model, S4, was a reparameterisation that made that convolution practical1. On Long Range Arena, S4 solved Path-X, length 16,384, at 88% accuracy, where they say every earlier model was near chance, about 50%1. On CIFAR-10 and WikiText-103 it generated about 60 times faster than standard autoregressive models1.
A state space layer is not attention. Attention stores earlier tokens and looks back at them. The state here stays a fixed size, so cost grows linearly with length, but a small state can drop detail2. Mamba, from Gu and Dao in 2023, lets the update depend on the current token, so the model can keep or forget information2. Their Mamba block has no attention and no separate MLP block2. They report about five times the inference throughput of Transformers. A 3 billion parameter Mamba beats Transformers of the same size and matches Transformers twice its size, in pre-training and downstream tests2.
Products can mix the two. Jamba, from Lieber and colleagues, interleaves Transformer blocks with Mamba layers, which they call a recent state space model, plus mixture-of-experts in some blocks3. That paper's model has 12 billion active parameters and 52 billion in total, and was built to fit one 80GB GPU3. AI21's current docs do not say state space. They label the type "Joint Attention and Mamba" and list Jamba Large at 398 billion parameters, 94 billion active, with a 256,000 token context4.
Example
Reading a long contract, an attention layer can look back at earlier words. A state space layer folds each new word into the same hidden state and does not keep a growing cache, which is why S4 can also run as a plain recurrence1.
Why it matters
It is the main current alternative to attention for long sequences: a fixed state and linear cost, with hybrids such as Jamba keeping attention in only some layers23.
Questions people ask
Is a state space model the same as a Transformer?
No. A Transformer attention layer looks back across earlier tokens and stores them. A state space layer keeps one hidden state and updates it, so the cost grows linearly with length12. Hybrids such as Jamba use both in different layers3.
What is Mamba?
Mamba is Gu and Dao's 2023 selective state space model. The update depends on the current token, so the model can pass information on or drop it. Their block uses no attention. They report five times the throughput of similar Transformers, and a 3 billion parameter model matching Transformers twice that size2.
Did AI research invent state space models?
No. Gu, Goel and Ré describe them as a foundational model in control theory and other sciences1. The Mamba paper points to Kalman's 1960 work as the classical source, and then uses the structured deep-learning form that starts with S421.
What is Jamba?
Jamba is AI21's hybrid: Transformer layers interleaved with Mamba layers, plus mixture-of-experts3. The 2024 paper's model has 12 billion active parameters out of 52 billion. Current docs list a larger Jamba Large, 398 billion parameters with 94 billion active, and a 256,000 token context4.
Related terms
Sources
- Gu, Goel and Ré (2021), Efficiently Modeling Long Sequences with Structured State Spaces, arXiv:2111.00396
- Gu and Dao (2023), Mamba: Linear-Time Sequence Modeling with Selective State Spaces, arXiv:2312.00752
- Lieber et al. (2024), Jamba: A Hybrid Transformer-Mamba Language Model, arXiv:2403.19887
- AI21 Labs, Jamba foundation model documentation