Autoregressive Decoding as a Martingale: Characterizing the Stochastic Dynamics of LLM Generation
Organizations: College of Computer, National University of Defense Technology, Changsha, Hunan, China
Abstract
Large language models (LLMs) have achieved remarkable success across a wide range of language tasks. At their core, autoregressive LLMs are conditional probability models that learn to approximate the next-token distribution given the preceding context. Despite this probabilistic nature, the stochastic dynamics of autoregressive decoding have rarely been investigated from a rigorous probabilistic perspective. In this work, we define the per-step prediction error as the difference between the sampled token indicator and the model's conditional predictive distribution, and prove that the cumulative error process is a martingale with respect to the decoding filtration, implying that its conditional first-order moment is identically zero. Beyond this first-order property, we derive a closed-form expression for the second-order behavior of the martingale sequence: its predictable quadratic variation reduces to , computable from realized token probabilities alone. This identity establishes a direct theoretical connection between sequence fluctuations and predictive uncertainty during autoregressive decoding. White-box experiments on Llama-3.x and Qwen2.5 families (1B to 72B parameters) verify that the empirically measured second-order moments closely match the theoretical predictions derived from our martingale analysis. These results provide a probabilistic framework for analyzing autoregressive LLM decoding, reveal intrinsic probabilistic fingerprints of different language models, and establish a rigorous mathematical foundation for LLM-generated text detection and uncertainty quantification.
Figures & tables
| Model | Empirical | Theoretical | Error |
|---|---|---|---|
| Llama-1B | 861.60 | 865.23 | 3.63 |
| Llama-3B | 796.40 | 781.61 | 14.79 |
| Llama-8B | 708.74 | 698.66 | 10.09 |
| Llama-70B | 475.45 | 462.09 | 13.36 |
| Qwen-1.5B | 609.81 | 622.64 | 12.84 |
| Qwen-3B | 434.98 | 436.80 | 1.83 |
| Entropy | PPL | MaxProb | |
|---|---|---|---|
| SM | 0.7203 | 0.7057 | 0.7018 |
| NSM | 0.9889 | 0.9482 | 0.9950 |
Autoregressive Decoding
Autoregressive decoding generates outputs step by step, conditioning each token on earlier ones while balancing quality, control, and inference cost.
See all 56 papers