LLM Library
Inside the TransformerAnimated
State-Space Models and Hybrids
A different way to read sequences with linear cost.
The idea
Mamba-style layers keep a running state updated token by token, so cost grows linearly and no KV cache is needed. Hybrid models mix a few attention layers with many state-space layers to get the benefits of both.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
Raw text enters the system, for example "The cat sat on the".
- stage:
- 1/11
- part:
- Text in
1/11
The green dot is one token travelling through the model. The boxed section repeats for every layer.
Step by step
- 1Keep a hidden state
- 2Update it with each token using input-dependent gates
- 3Read the output from the state
- 4Insert attention layers now and then
Where it is used
Mamba, Jamba and other hybrids.
Watch out for
Pure state-space models can be weaker at exact recall from long contexts.