An autoregressive model predicts each next value from the values before it. How AR models work in time series forecasting and in LLMs like GPT, with examples.

Updated November 2026
An autoregressive model is a model that predicts the next value in a sequence from the values that came before it. In time series forecasting, an AR model writes today's value as a weighted sum of past values plus random noise. A large language model works the same way, predicting each next token (a word or piece of a word) from the tokens already written.
If you've heard the word from your forecasting team and your chatbot team, they mean the same loop: feed the past back in, predict the next step, and repeat. One forecasts next month's sales; the other writes a reply.
An autoregressive model is a regression of a variable on its own past values. Auto means self: the model's inputs are earlier values of the same series it predicts.
An ordinary regression predicts one variable from others, such as a house's price from its floor area. An autoregression predicts this month's sales from the last three months' sales.
The number of past values the model uses is its order, written p. An AR(1) model uses one previous value, and an AR(p) model uses p of them. (AR here stands for autoregressive, not augmented reality.)
The term has two homes. In statistics and econometrics, it names a family of forecasting models for time series such as temperatures, prices, and sunspot counts.
In machine learning, it names any model that generates a sequence one element at a time, each element predicted from the ones before it. Language models, some speech synthesizers, and some image generators work this way.
Both senses share one constraint: the model only looks backward. That is what lets it forecast, and it is also why it produces output one step at a time.
The two senses differ in machinery, not in idea. A forecasting model's prediction is a weighted sum of a handful of past values. A language model replaces that sum with a neural network that looks back over thousands of tokens.
An autoregressive model forecasts by multiplying each recent value by a learned weight, adding the results to a constant, and treating the gap between the forecast and what really happens as random noise.
Say you have an AR(1) model with a constant of 2 and a weight of 0.8 on the previous value. If the last value was 20, the next forecast is 2 + 0.8 × 20 = 18.
Two steps ahead, you have no real value for the next step yet, so the model feeds its own forecast back in: 2 + 0.8 × 18 = 16.4. The forecasts after that are 15.12, 14.1, 13.28, and 12.62.
Each forecast moves closer to 10, the series' long-run mean. For an AR(1) model, that mean is the constant divided by one minus the weight: 2 / (1 - 0.8) = 10.
That pull toward the mean holds only for a stationary series, one whose mean and variance stay stable over time. An AR(1) model is stationary when its weight is between -1 and 1.
At a weight of exactly 1 and no constant, the AR(1) series becomes a random walk: each value is the last one plus a fresh shock, so the series wanders with no mean to return to and its forecasts never settle.
The noise term is why real data never follows the smooth forecast path. Every step adds a fresh random shock, and the weights decide how long each shock echoes through later values.

An AR(p) model of order p takes this form: xₜ = c + φ₁xₜ₋₁ + φ₂xₜ₋₂ + … + φₚxₜ₋ₚ + εₜ. Each symbol has one job:
xₜ is the value at time t, and xₜ₋₁ is the value one step earlier.c is a constant.φ₁ to φₚ are the weights the model learns, one for each past value, or lag.εₜ is white noise: a random shock with a mean of zero and a constant variance, uncorrelated from one step to the next.The AR(1) model above is the case p = 1, with c = 2 and φ₁ = 0.8. Fitting a model means estimating c and the weights from data, usually by least squares, the method an ordinary linear regression uses.
The statsmodels library fits autoregressive models in Python with its AutoReg class. Its ar_select_order function picks the order from the data.
The example below uses the yearly sunspot numbers that ship with statsmodels, which run from 0 to 190 between 1700 and 2008. It picks the order on the years up to 1988, fits the model, and forecasts 1989 to 2008.
When you run it, the order search picks nine lags, which reach back most of the roughly 11-year sunspot cycle. Lag 1 carries the largest weight, 1.191, and four of the nine weights are negative.
A weight above 1 does not break the model. The -1 to 1 rule applies to AR(1) only.
With nine lags, stationarity depends on all the weights together. The model's characteristic roots, which statsmodels reports, all lie outside the unit circle, and that is the check this model passes.
The 20 forecasts are multi-step: each year's forecast feeds into the next, and the model never sees the 1989 to 2008 values.
The forecasts miss the actual sunspot number by 11.5 on average. Predicting the 1700 to 1988 average every year would miss by 44.0.
The order of an AR model is chosen in three steps: make the series stationary, read its partial autocorrelations, and then compare candidate orders with an information criterion.
If your series has a trend, you difference it first, which means modeling the change from one step to the next instead of the level itself. Sunspot numbers rise and fall without a long-term trend, so the example skips this step.
Autocorrelation measures how strongly a series tracks its own earlier values. The partial autocorrelation function (PACF) measures how well the value k steps back predicts today, with the steps in between taken out.
Plotted as one bar per lag, an AR(p) series shows its last bar outside the plot's shaded band at lag p, and none beyond it.
Akaike's AIC and Schwarz's BIC, two information criteria, both reward a good fit and charge a penalty for every extra weight. BIC charges more, so it tends to pick smaller models. The example's ar_select_order call runs this step with BIC.
Each autoregressive variant keeps the use of past values and adds one thing the plain AR model cannot handle:
Sunspot numbers, the series in the Python example above, are the classic time series example. Others include:
Generative examples produce text, sound, and images one element at a time:
Autoregressive models have four main limitations: they are linear, they need a stable past, their errors compound, and they produce output one step at a time.
Large language models such as GPT are autoregressive: they generate text one token at a time, and they predict each new token from all the tokens before it.
Generation is a loop. When you send a prompt, the model reads the prompt and computes a probability for every token in its vocabulary. It picks one, appends it to the input, and repeats until it writes a stop token or reaches a length limit.
The pick is usually a sample from those probabilities, not always the top token, which is why the same prompt can give you two different replies.
That loop is why a chatbot's answer can appear on your screen word by word instead of all at once.
The math behind the loop is the chain rule of probability: the chance of a whole sentence is the chance of each word given the words before it, multiplied together.
Statisticians call that split autoregressive factorization, and the GPT-2 paper defines language modeling with it.
The Transformer paper calls its decoder, the part of the model that writes output, auto-regressive for the same reason: each step consumes the symbols generated so far.

Training does not need the loop, which is why training runs in parallel while generation is the slow part.
During training the model already has the whole text, so the training setup hides the tokens to the right of each position, and the model learns every position's next-token prediction at once.
An autoregressive model produces a sequence one element at a time, left to right, while a non-autoregressive model produces many elements in parallel or fills them in using context from both sides.
| Model type | How it fills a sequence | Context it uses | Steps to produce n tokens |
|---|---|---|---|
| Autoregressive (GPT-style decoder) | One token at a time, left to right | Earlier tokens only | n |
| Masked language model (BERT) | Predicts hidden tokens inside a given text | Tokens on both sides | Not used to generate text |
| Diffusion model | Refines every position from noise | The whole sequence at each step | A fixed number of refinement steps |
| Non-autoregressive translation | All output tokens at once | The source sentence | One |
BERT is not autoregressive. It hides some words in a sentence and predicts them from the words on both sides, which its authors call a masked language model.
That design makes BERT a model for understanding text, such as classification and question answering, not for writing it.
Diffusion models drop the one-token-per-step loop: they start from noise and refine every position at each step.
The number of diffusion steps does not grow with the length of the output, which is why they can be faster than an autoregressive model that needs one step per token.
Text-to-speech models split the same way. Some generate speech tokens one step at a time, while diffusion and similar models refine a chunk of speech in parallel over a fixed number of steps.
In the first non-autoregressive translation model, parallel output cost accuracy. Gu and colleagues built a model that writes every output word at once, each chosen without seeing the others.
On English to German, the fastest version translated a sentence in 39 ms against 607 ms for the autoregressive model, but scored about 6 points lower on BLEU, a 0 to 100 translation-quality score.
Scoring 100 candidate translations and keeping the best narrowed that gap to about 4 points, but the speedup shrank from 15.6 times to 2.4 times.

A voice AI agent turns the caller's speech into text, writes a reply with a language model, and speaks it with text-to-speech.
The agent can start speaking as soon as the first sentence of the reply exists, because the language model writes that reply one token at a time.
On a phone call, you notice the silence before the agent's first word, not how long the rest of the answer takes.
That wait is the model's time to first token, or TTFT, plus the first sentence's tokens, plus speech synthesis. The first sentence is the part that sets the wait, not the length of the whole reply.
If you build the pipeline yourself, you send each finished sentence from the token stream to speech as it completes.
On Telnyx, the chat completions API streams tokens as the model writes them, the text-to-speech WebSocket turns text into audio a sentence at a time, and the Voice API carries the call.
GPT models are autoregressive. Training teaches them to predict the next token from the tokens before it, and they generate text by repeating that prediction, one token at a time.
BERT is not an autoregressive model. It predicts masked words from the context on both sides at once, so it does not generate text one token after another.
An LSTM is autoregressive only when it generates by feeding its own predictions back in. An LSTM is a type of neural network that reads a sequence one step at a time.
An LSTM language model that predicts the next word and feeds it back in is autoregressive; an LSTM that tags a sentence it has already read is not.
A regression predicts one variable from other variables, such as umbrella sales from rainfall. An autoregression predicts a variable from its own earlier values, such as umbrella sales this week from umbrella sales in recent weeks.
ARMA and ARIMA models extend the AR model. ARMA(p, q) adds q past forecast errors to p past values. ARIMA(p, d, q) also differences the series d times first, so it can handle a trend.
AutoReg, ar_select_order, and the sunspots dataset.This content was generated with the assistance of AI. Our AI prompt chain workflow is carefully grounded and preferences .gov and .edu citations when available. All content is reviewed by a Telnyx employee to ensure accuracy, relevance, and a high standard of quality.