AI Grimoire
Sheet
statuscommon
difficultyadvanced
timeO(n·d·N)
described2020
revisedtoday

HiPPO

A random linear recurrence forgets exponentially. Derive the matrix that instead keeps an optimal polynomial approximation of everything seen so far, and the same architecture handles sequences of sixteen thousand steps.

Standing

Commonly usedEstablished and frequently the right choice, but competing with live alternatives rather than having settled the question.

Load-bearing for the S4 line and the reason those models worked when earlier linear RNNs did not. Later work found the specific matrix matters less than it first appeared.

judged as of 2026-09 · what the labels mean

Theory

A linear recurrence ht=Aht1+Bxth_t = A h_{t-1} + B x_t with a random AA forgets at a rate set by AA‘s eigenvalues. Nothing about a random matrix makes the forgetting useful — the state ends up holding a decaying blur of the recent past and nothing of the distant one.

HiPPO asks a sharper question. Suppose the state’s job is to hold the best NN-coefficient approximation of the entire input history so far. What must AA be?

Memory as projection

Treat the input as a function x(t)x(t) and the state as its coefficients against a basis of orthogonal polynomials, under a measure that weights how much each part of the past counts.

h(t)=xt,  pnμ(t),n<Nh(t) = \Bigl\langle x\big|_{\le t},\; p_n \Bigr\rangle_{\mu^{(t)}}, \qquad n < N
eq. 1 — the state is a projection, maintained online

The requirement is that this stay true as tt advances — that the coefficients of the best approximation at time t+dtt+dt follow from those at time tt by a linear update. Remarkably, for the standard measures they do, and differentiating the projection gives an AA in closed form.

Ank={(2n+1)(2k+1)n>kn+1n=k0n<kA_{nk} = -\begin{cases} \sqrt{(2n+1)(2k+1)} & n > k \\ n+1 & n = k \\ 0 & n < k \end{cases}
eq. 2 — HiPPO-LegS, the uniform-weight case

Lower-triangular, with entries growing as nk\sqrt{nk}. Nothing about it looks like a matrix anyone would guess, and that is the point — it is derived, not searched.

Why it mattered

S4 is a linear recurrence, a parallel scan, and this initialisation. Remove the initialisation and the architecture fails outright on long-range tasks — the Long Range Arena’s Path-X, at 16 384 steps, went from “nobody has ever beaten chance” to solved.

The specific claim is narrow and worth keeping straight: HiPPO does not make the model more expressive. The same AA is reachable by gradient descent in principle. What it does is put the optimisation somewhere it can succeed from, and for this architecture the gap between a reachable optimum and a reached one turned out to be the whole result.

Implementation

python · numpy
import numpy as np


def hippo_legs(n: int) -> np.ndarray:
    """HiPPO-LegS transition matrix. Gu et al. 2020, eq. 2."""
    q = np.arange(n)
    r = 2 * q + 1
    m = -np.tril(np.sqrt(r[:, None] * r[None, :]), -1)        # n > k
    np.fill_diagonal(m, -(q + 1))                             # n = k
    return m                                                  # strictly lower + diag


def normal_plus_low_rank(n: int) -> tuple[np.ndarray, np.ndarray]:
    """S4's decomposition: A = normal − P Pᵀ, which is what makes the
    convolution kernel computable without materialising A^t."""
    a = hippo_legs(n)
    p = np.sqrt(np.arange(n) + 0.5)
    return a + p[:, None] * p[None, :], p

That decomposition is where S4’s difficulty lives. Running the recurrence needs powers of AA, which for a dense N×NN \times N matrix is prohibitive; writing AA as normal-plus-low-rank makes the powers computable in O(NlogN)O(N \log N) via a Cauchy kernel. Several pages of the S4 paper are about that and none of it is about sequence modelling.

How the story ended

Two later results reframe it.

S4D replaces the derived matrix with a diagonal one whose eigenvalues are initialised along the same part of the complex plane, and performs about as well. The dense structure was not essential; the eigenvalue placement was.

The LRU paper goes further, taking an ordinary linear RNN and applying three changes — diagonal complex parameterisation, stable exponential parameterisation of the eigenvalue magnitudes, and normalisation at initialisation — and matches S4 on Long Range Arena with no HiPPO at all.

The honest reading is that HiPPO answered a question nobody had posed correctly and, in doing so, revealed what the answer needed to look like: eigenvalues just inside the unit circle, spread over a range of timescales. It got there by derivation. Once seen, the same configuration can be had by initialising for it directly — which is what Mamba does, keeping the diagonal form and the timescale spread and dropping the polynomial argument.

LSTM
≈ 60%
Random-init SSM
fails
HiPPO-init SSM
> 90%
Sequential CIFAR, 1024 steps

Related

References

[1]Gu et al. — HiPPO: Recurrent Memory with Optimal Polynomial Projections (2020)arXiv:2008.07669
[2]Gu et al. — Efficiently Modeling Long Sequences with Structured State Spaces (2021)arXiv:2111.00396
[3]Orvieto et al. — Resurrecting Recurrent Neural Networks for Long Sequences (2023)arXiv:2303.06349