cs.LGOct 29, 2026

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

Authors: Kağan Akman, Jake Feldman Starosta, Naci Saldi, Serdar Yüksel

Organizations: Department of Mathematics, Bilkent University, Ankara, 06800, Turkey · Department of Mathematics and Statistics, Queen’s University, Kingston K7L 3N6, ON, Canada

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 NNth order Markovian sources, it decays at an exponential rate α⌊M/N⌋α^{\lfloor M/N\rfloor}, where MM is the window length and αα is determined by filter stability (and the Dobrushin coefficients of the transition and measurement kernels). We then construct a Transformer of depth M+1M+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.

Figures & tables

Appendix figures & tables1 asset

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Transformer-like Inference from Optimal Control

    May 15, 2026Aditya Kudre, Heng-Sheng Chang, Prashant G. MehtaTransformer InferenceDecoder-Only Language Models

  2. An Optimal Control Approach To Transformer Training

    Mar 10, 2026Kağan Akman, Naci Saldi, Serdar YükselTransformerTransformer Training Dynamics

  3. Learning Source Structure: Bayesian Prediction with Transformers

    Oct 13, 2026Meir Feder, Ruediger UrbankeTransformerSequence Modeling