Skip to main content
Back

Illinois Derives a Transformer-Like Architecture Called the Dual Filter Without Attention

A new paper derives transformer-like architectures from first principles by reformulating next-token prediction as an optimal control problem over hidden Markov models.

Pro

  • New paper derives transformer-like architecture from first principles by reformulating next-token prediction as optimal control on hidden Markov models.
  • Introduces the dual filter algorithm with O(d^2 T) complexity, independent of vocabulary size, using a backward stochastic difference equation.
  • Resolves a longstanding open problem: extending Kalman's minimum variance duality beyond linear-Gaussian settings to discrete HMMs.
  • Layer-by-layer correspondence with decoder-only transformers, without attention heads, softmax, or positional encodings.
  • Numerical experiments use nanoGPT-scale parameters (d=384, m=65, T=256) and match the exact nonlinear filter.
  • No code, no learning framework yet; parameters (mu, A, C) must be known, extensions to trained models are future work.

Transformers are usually treated as an engineering artifact that happened to work, then reverse-engineered by theorists trying to explain why. A new paper from Heng-Sheng Chang and Prashant Mehta at the University of Illinois flips that direction. It starts from the prediction problem a decoder-only transformer is supposed to solve, and derives an architecture that solves it optimally. The result, called the dual filter, ends up looking a lot like a transformer, but without positional encodings, attention heads, or softmax.

The problem being solved from scratch

The setup is deliberately narrow. Observations (tokens) are assumed to come from a hidden Markov model (HMM): a latent state evolves as a Markov chain over a finite state space of dimension d, and each state emits a token from a vocabulary of size m+1. Given a sequence of past tokens, compute the conditional probability of the next one. That is exactly the input-output signature of a decoder-only transformer, and the paper frames it as a minimum mean-squared error (MMSE) estimation problem.

The theoretical goal is to write the conditional expectation as a causal, nonlinear predictor of the form:

pi_T(F) = constant - sum_{t=1..T} U_{t-1}^T e(Z_t)

where e(Z_t) is essentially a one-hot encoding of the observed token and the weights U_t are themselves random variables that depend on past observations. That last part is what makes the predictor nonlinear. If the weights were fixed, this would collapse to a Wiener filter, the classical linear predictor. Letting them react to the observed sequence is what buys you transformer-like expressivity.

Duality: turning estimation into control

The core theoretical move is to recast MMSE estimation as an optimal control problem. The authors introduce a backward stochastic difference equation (BSDelta E) as a dynamic constraint, then define a quadratic cost whose minimizer produces the weights U in the predictor above. This is a discrete-time, discrete-observation extension of Kalman's minimum variance duality.

That extension matters historically. In a 2008 paper widely cited in the control community, Emanuel Todorov argued that Kalman's duality was an artifact of the linear-quadratic-Gaussian setting and could not be generalized. This paper explicitly resolves that as an open problem, producing the first extension of minimum variance duality to discrete-time HMMs with discrete observations. The mechanism is a fixed-point equation on the space of probability measures over the hidden state.

The dual filter algorithm

Solving that fixed-point equation gives you the algorithm. The authors define a layer transformation N_dfltr that maps a sequence of T probability measures over the hidden state space to another sequence of T probability measures. Iterating this map converges to the conditional distribution you want. The paper offers two variants:

  • Iterative algorithm: each iteration does a single backward pass over the sequence, and multiple iterations refine the estimate. This is the version that structurally mirrors a transformer's stack of layers.
  • Single-shot algorithm: performs T backward passes in one iteration, using the result of pass t to compute pass t+1. More efficient in practice.

Complexity is O(d^2 T), and crucially independent of the vocabulary size m. That is a sharp contrast with attention, whose per-token cost scales with the embedding dimension and whose output projection scales with vocabulary. The dual filter would be cheap in the regime where m is in the hundred-thousands, which is where modern LLMs live.

Where it lines up with transformers, and where it doesn't

The correspondence between the dual filter and a decoder-only transformer is spelled out layer by layer:

There is no analog of attention heads, no query-key-value matrices, no residual connections, no layer normalization. The temporal ordering that a transformer injects through positional encodings is instead baked into the Markov transition matrix A. And the softmax at the output is replaced by a straightforward linear operation on the emission matrix.

The authors are careful to say they are not claiming that a transformer is a dual filter, or that the brain of GPT is an HMM. Their claim is that if you take the prediction task at face value and derive the optimal architecture under a tractable probabilistic model, you get something with the same input-output shape and layered structure.

Numerics at GPT-scale parameters

The experiments use HMM dimensions borrowed from Andrej Karpathy's nanoGPT character-level configuration: d = 384 hidden states, vocabulary size m = 65, and context length T = 256. Ground truth is computed by running the exact nonlinear filter (the classical forward algorithm) on the same HMM. The dual filter is then compared against it.

Results:

  • The single-shot algorithm converges to the exact posterior in one pass.
  • The iterative algorithm converges over roughly 6 layers, with the error metric (max absolute difference in predicted token probabilities) dropping progressively at each layer.
  • When the transition matrix mixes rapidly (small spectral gap), the optimal control weights are near-zero except for the most recent few tokens, meaning long-range attention is not useful.
  • When the dynamics are near-deterministic, the weights are large early and drop to zero once the state is identifiable. Intermediate spectral gaps produce the long-range dependency structure that resembles transformer behavior.

A side experiment trains nanoGPT on data sampled from the same HMM. On some random emission matrices the transformer's predictions closely track the exact filter; on others (including one where the dual filter works fine), nanoGPT fails to converge to the right conditional distribution. The pattern suggests transformers do well when the true next-token distribution is sparse over the vocabulary, and struggle when it is diffuse.

What is and isn't useful here

There is no code release, no pretrained model, and no attempt to train the dual filter on real language data. The framework is purely for inference on a known HMM, meaning the transition matrix A, emission matrix C, and prior mu are all given. The paper is explicit that learning these parameters from data, or extending the framework to non-Markovian real-world sequences, is future work.

What is on offer is a principled baseline. If you believe your data generating process is roughly an HMM, the dual filter gives you the optimal inference architecture for it, and that architecture happens to be a stack of causal, measure-valued layer maps of the same shape as a transformer. That is useful in three concrete directions: analyzing filter stability and contraction properties of transformer-like layer maps, understanding when positional encodings actually help (versus being absorbed into transition dynamics), and connecting sequence models to the predictive state representation literature from reinforcement learning on partially observed Markov decision processes.

The bigger claim, that Kalman's minimum variance duality generalizes beyond LQG after all, is the kind of result that tends to unlock a decade of follow-on work in control theory. Whether it also unlocks better sequence models is now a learning problem, not a theory problem.

ConceptDual filterTransformer
Embedding matrixEmission matrix C(x,z)Learned matrix C_xfer
State space dimensiond (hidden Markov state)d (embedding dim)
Layer outputProbability measure in P(S)Signed measure in M(S)
Output projectionLinear: sum over statesSoftmax over vocabulary
Position informationEncoded in Markov transition APositional encoding W_p