Skip to content
StackDecode
LLM Library
State-spaceOpen weightsArchitecture animation

Mamba

Replaces attention with a state that is updated token by token, so cost grows linearly.

At a glance

Made by
Gu and Dao (academic)
Released
2023
Type
State-space
Access
Open weights
Parameters
130M to 2.8B
Context window
Not fixed (linear-time)
Attention
None: selective state-space layers

How it works

Mamba makes the state-space parameters depend on the input so the model can choose what to remember or forget. It is fast for long sequences and has no KV cache.

Architecture, step by step

A token travels from text in to prediction out. The boxed layers repeat many times.

× N layersText inTokenizerEmbedding + positionNormSelective state-space layerAdd (residual)Final normLM head (vocabulary scores)Softmax, then sample next token

Raw text enters the system, for example "The cat sat on the".

stage:
1/9
part:
Text in
1/9

The green dot is one token travelling through the model. The boxed section repeats for every layer.

What stands out

  • Selective state-space layers
  • Linear time in sequence length
  • Hardware-aware scan

Keep in mind

Pure SSMs can be weaker at exact recall of earlier text.