# When can Optimally Trained Transformers Achieve Near-Lossless Token Prediction for non-Markovian Data?

DevFeed: [When can Optimally Trained Transformers Achieve Near-Lossless Token Prediction for non-Markovian Data?](<https://devfeed.tech/articles/when-can-optimally-trained-transformers-achieve-near-lossless-token-prediction-for-non-markovian-data-111534.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2610.41038>)

Author: Ka\\u{g}an Akman, Jake Feldman Starosta, Naci Saldi, Serdar Y\\"uksel

Published: 2026-11-02T05:00:00Z

Content type: article

Language: en

Sources: [arXiv: Machine Learning](<https://devfeed.tech/sources/arxiv-machine-learning.md>)

Topics: [AI Models](<https://devfeed.tech/topics/ai-models.md>), [context window](<https://devfeed.tech/topics/context-window.md>)

Tags: [abstract](<https://devfeed.tech/tags/abstract.md>), [alpha](<https://devfeed.tech/tags/alpha.md>), [approximation](<https://devfeed.tech/tags/approximation.md>), [architectures](<https://devfeed.tech/tags/architectures.md>), [arxiv](<https://devfeed.tech/tags/arxiv.md>), [bounded](<https://devfeed.tech/tags/bounded.md>), [can](<https://devfeed.tech/tags/can.md>), [consider](<https://devfeed.tech/tags/consider.md>), [context](<https://devfeed.tech/tags/context.md>), [control](<https://devfeed.tech/tags/control.md>), [cs-lg](<https://devfeed.tech/tags/cs-lg.md>), [data](<https://devfeed.tech/tags/data.md>), [either](<https://devfeed.tech/tags/either.md>), [entropy](<https://devfeed.tech/tags/entropy.md>), [error](<https://devfeed.tech/tags/error.md>), [exists](<https://devfeed.tech/tags/exists.md>), [filter](<https://devfeed.tech/tags/filter.md>), [first](<https://devfeed.tech/tags/first.md>), [math-oc](<https://devfeed.tech/tags/math-oc.md>), [math-pr](<https://devfeed.tech/tags/math-pr.md>), [prediction](<https://devfeed.tech/tags/prediction.md>), [token](<https://devfeed.tech/tags/token.md>), [transformers](<https://devfeed.tech/tags/transformers.md>)

## AI overview

The paper gives conditions under which theoretically trained Transformers can make next-token prediction errors arbitrarily small on non-Markovian data as context length, data, and approximation refinement increase. It studies general stationary ergodic sources and finite-order hidden Markov models, including possibly non-stationary ones. For stationary ergodic sources, finite-window error is bounded by an entropy gap; for Nth-order Markov sources, it decays exponentially with window length when filter stability holds, with the rate depending on stability and Dobrushin coefficients. The authors construct a depth M+1 Transformer with one head per layer to implement a truncated filter, then use stochastic optimal control to obtain a near-optimal model. Numerical studies accompany the theoretical results.

## Source excerpt

arXiv:2610.41038v1 Announce Type: new Abstract: There exists little mathematical theory explaining why Transformer architectures are empirically successful even for non-Markovian data. To this end, this paper studies next-token prediction via stochastic optimal control theoretically trained Transformers for such sources, where we consider either stationary and ergodic non-Markovian sources or those which are hidden Markov models of some finite order (possibly non-stationary). In either case, we first obtain error bounds via finite models with finite window approximations. For stationary ergodic sources, the resulting error is bounded by an entropy gap; for $N$th order Markovian sources, it decays at an exponential rate $\alpha^{\lfloor M/N\rfloor}$, where $M$ is the window length and $\alpha$ is determined by filter stability (and the Dobrushin coefficients of the transition and measurement kernels). We then construct a Transformer of depth $M+1$, one head per layer, realizing the truncated filter, and we optimally train it with stochastic control developed in earlier work, which rigorously returns a near optimal Transformer. In particular, we show that for a non-Markovian source, either under stationarity and ergodicity for general models or under filter stability for hidden Markov models, an optimally trained Transformer has arbitrarily small performance error with increasing context length, data, and approximation refinement. Numerical studies accompany the theory.