ICLR 2026 · Oral
From Markov
to Laplace
How Mamba in-context learns Markov chains
Presented by
Shengbo Gong
Authors
Bondaschi, Rajaraman, Wei, Ramchandran, Pascanu, Gulcehre, Gastpar, Makkuva
arXiv:2502.10178 / EPFL · UC Berkeley · Google DeepMind · Télécom Paris
01
The question underneath
What counts as
intelligence?
One workable answer: infer a rule from a handful of examples and apply it immediately — no retraining, no gradient step.
Five capabilities
Ilya Sutskever · scope of this talk
01
In-context learning
this talk
02
Early stopping before failure
open
03
Lifelong learning
open
04
Zero-shot transfer
open
05
Deploy-time learning
open
In-context learning
Definition
Inferring an unseen task from examples in the prompt, and applying it in the same forward pass — with the weights frozen.
Example · mathematical
A rule drawn at random
Example · natural language
A label map drawn at random
Two accounts
Literature
Account A
Implicit gradient descent
von Oswald+ 2022 · Dai+ 2023
Account B
Implicit Bayesian inference
Xie+ 2021
One lens
Interpretive bridge / HMM hypothesis
Sequential modeling / literal HMM
States move; observations follow.
Infer a transition law from one trajectory, then predict the next observation. In the paper, the emission is identity: zt = xt.
LLM demonstrations / HMM-style hypothesis
Meaning is hidden; text and answers reveal it.
Infer the shared task mechanism from demonstrations, then complete the missing answer. Tokens are treated as emissions from a latent task state.
Shared inference template
p(next | context) = ∫ p(next | θ, context) p(θ | context) dθ
02
Two architectures, one estimator
Background
What Mamba is, what Laplacian smoothing is, and why a Markov chain is where they meet.
Complexity
Background · Gu & Dao 2312.00752 / Dao & Gu 2405.21060
Mamba LM
Background / paper Fig. 2 · Bondaschi et al. 2502.10178
Autoregressive interface
Prefix in.
Next-token distribution out.
01
Embed every observed token xt.
02
Pass embeddings through Mamba; its recurrent state moves left to right.
03
MLP + linear + softmax produce P(xt+1 | x≤t).
Horizontal arrows between Mamba cells carry the recurrent state. Vertical arrows carry the token representation toward the language-model head.
Mamba block
Background · Mamba-2 / S6, Gu & Dao 2312.00752 · Dao & Gu 2405.21060
The data
Background / data
The estimator
Background / target
Counts for one fixed context
n — times that context occurred.
nj — times token j followed that context.
Naive: raw frequency
njn
Assigns probability zero to anything unseen — and a single zero sends cross-entropy to infinity.
FIX: ADD-𝛽 BEFORE DIVIDING · LAPLACE, 1814
Pβ(xt+1=j|ctx) = nj + βn + 2β
Why this exact estimator
The Bayes-optimal closed form
For the unknown binary transition row θ ∼ Dirichlet(𝛽, 𝛽), the posterior predictive is exactly
E[θj | n0, n1] = nj + βn + 2β
That closed form is add-𝛽. It is the exact Bayes-optimal predictor for next-token cross-entropy, not a heuristic correction.
So the loss has a known floor — ask not "does it learn?" but "does it reach the optimum?"
Worked example
BACKGROUND / TARGET · 𝛽 = 1, ORDER 1
03
How this field actually works
Toy examples
You cannot prove anything about a frontier model. So you build the smallest synthetic task that still contains the phenomenon.
Lineage
Lineage
01
Linear & sparse regression
Fresh weight vector per sequence — compare against least squares. Garg+ 2022
02
Trees & two-layer nets
Labels from a random tree or random network — tests non-linear classes. Garg+ 2022
03
Random Markov chains
Fresh transition matrix per sequence — the only setting used from here on. Edelman+ 2024
From here on: random binary Markov chains and their known add-𝛽 optimum.
Setup
Method
Architecture
Mamba-2, 1 layer, 1 head
Baselines
GPT-2 1–2L, linear attn 1–2L
Optimizer
AdamW, lr 1e-3, cosine
Iterations
10 000
Embedding dim d
grid { 2, 4, 8, 16, 32 }
SSM state dim N
N = d
Expansion factor e
e = 1 ⇒ inner width ed = d
State matrix Ht
Ht ∈ ℝ(ed)×N = ℝd×d
Conv window w
2 … 6
Compute
1× A100, 10–60 min per run
Objective
L(θ) = −Σt E [ log fθ(xt+1 | x1t) ]
averaged over positions t
Plain next-token cross-entropy — nothing bespoke. Its minimizer is provably add-β, so the loss floor is known in advance.
Batch lab
Live / toy data lab
Hidden P(1 | ctx) seq 1
Batch of 5 one fresh P per row
Five sequences, five different transition matrices. At order k, the recurrent state Ht must keep one transition-count row for each of the 2k contexts.
Convergence
Live / convergence
Sequence t = 0 / 96
Recurrent state — transition counts
Charted context —
add-β
—
true kernel
—
| error |
—
raw freq.
—
Estimated P(next = 1) for one fixed context
The solid line is computed from counts alone; the dashed line is the kernel the estimator was never told. They converge — that convergence is the in-context learning.
04
The finding
One layer is
enough.
A single-layer Mamba tracks the Bayes-optimal estimator. A single-layer transformer cannot get off the ground.
On the optimum
Result / paper Fig. 1
The 1-layer Mamba curve sits on the optimum. The 1-layer transformer never leaves the marginal; two layers only track it loosely.
The measurement
Result / paper Fig. 1 · measured, not schematic
Left: the predicted probability along one test sequence. Right: the L1 gap from optimal across Markov orders 1–4. Mamba's line and the optimum are indistinguishable.
Two layers
Mechanism / transformer
One block
Mechanism / Mamba
The depth gap comes from where binding happens — not from attention.
05
Ablations
Which part is
load-bearing?
Take the architecture apart one component at a time. The answer is not the part anyone expected.
Ablation
Ablation / procedure
Convolution
Ablation / paper Fig. 11
Bolt a convolution onto a transformer's Q, K, V and one layer suddenly suffices — the curve climbs onto the optimum. The depth requirement was about binding, not attention.
The measurement
Ablation / paper Fig. 11 · measured, not schematic
The convolution-augmented single-layer transformer lands on Mamba and the optimum; the plain single-layer transformer stays flat, well above the loss floor.
Gate open
Ablation / paper Fig. 4
The learned gate stays at at ≈ 0.996 everywhere.
The optimal estimator needs every historical count, so the model learns almost no forgetting. Selectivity is available, but this stationary task does not use it.
Order sets the window
Limits / local binding
An order-k transition contains two objects: a context of k tokens and the one token observed after it.
This is the local requirement. It says what feature must enter the recurrence before any counting can be correct.
Paper Fig. 3b · learned, not constructed
The threshold moves one step for every increase in k.
Below w = k+1 the gap is large; at and above it, the gap collapses to zero. The staircase is the signature of a representational threshold.
Order sets the state
Limits / global memory
The same k creates the global requirement
An order-k binary chain has 2k contexts. The recurrent state H must preserve a separate predictive count for every one of them.
Ht := all recurrent states, flattened ∈ ℝd
For fixed accuracy and precision:
dim(H) = Ω(2k).
This is an information bound on the total recurrent state, not a quirk of one Mamba parameterization.
Measured, not just argued: d = 4 handles k = 2 and fails at k = 3. Each curve gives out one order after the last.
So order controls both resources: locally, w ≥ k+1; globally, the state capacity grows exponentially in k.
What depth changes
Depth / two roles
Mamba is flat in depth here because one layer already saturates the task.
Transformer / local binding
Layer 1 binds.
Layer 2 retrieves and counts.
Depth supplies the missing local step — which is why a transformer needs two layers.
SSM / Mamba / global memory
Depth and capacity are interchangeable.
Stacking recurrent layers adds capacity linearly through L · C, where C = dim(H) is the recurrent-state capacity per layer.
The capacity law
Limits / L · C ≳ 2ᵏ · training-free sweep
Gap to add-β collapses to zero exactly when L · C ≥ 2k.
One layer · grow state capacity C
k \ C
2
4
8
16
1
.000
.000
.000
.000
2
.234
.000
.000
.000
3
.319
.243
.000
.000
4
.374
.326
.209
.000
Zero exactly on and past C = 2k. Capacity alone must grow exponentially in k.
Fixed C = 4 per layer · grow depth L
k \ L
1
2
4
8
1
.000
.000
.000
.000
2
.000
.000
.000
.000
3
.243
.000
.000
.000
4
.326
.209
.000
.000
Same staircase — depth and capacity enter symmetrically, as the product L · C. Depth does add capacity, but only linearly, while the demand grows as 2k — so the layers needed still double each order.
Trade-offs
Summary · sequence length T / Markov order k
06
Consequences
At LLM scale
Does any of this survive on real text — and what did the frontier labs ship once they had to choose?
Real text
At scale / WikiText-103
Same ablation, real language. Mamba-2 at 14.5 M parameters on WikiText-103 — remove one component at a time and read the perplexity.
Model
PPL
Δ
Mamba-2, full
27.55
—
without non-linearities
28.98
5%
without convolution
30.68
11%
without gating factor
32.16
17%
The two components the Markov analysis singled out are the two that hurt most on real text.
An honest caveat
At 12 layers the
advantage nearly
vanishes.
Mamba-2, 110 M
21.38
without convolution
21.46
Likely because other layers learn to approximate the convolution themselves. The mechanism is still needed — it just stops needing its own module.
Kimi K3
LLM practice / mixed memory
Take away
Close
01
A 1-layer Mamba implements the exact Bayes-optimal add-β estimator.
02
The convolution binds context to successor; recurrent state H accumulates the counts.
03
Order k sets both costs: w ≥ k+1 locally and L × C ≳ 2k globally.
04
Markov prediction is not language, and in-context learning is only one capability of an LLM.
Thank you
Questions?
Paper
From Markov to Laplace: How Mamba In-Context Learns Markov Chains. ICLR 2026, Oral. arXiv:2502.10178
Architecture
Gu & Dao, Mamba: Linear-Time Sequence Modeling with Selective State Spaces. arXiv:2312.00752 · Dao & Gu, Transformers are SSMs (Mamba-2 / SSD). arXiv:2405.21060
Code
github.com/Bond1995/Markov-Mamba — and the training-free reproduction shown here, in toy_reproduce.py
Presenter
Shengbo Gong