Autoregressive Language Models
An autoregressive model is defined as one that incorporates its previous outputs as inputs for future predictions.
A Single Goal for Pretraining
Large language models can seem to do many different things. They answer questions, summarize documents, and continue a story. It is natural to assume that each of these abilities must be built in separately, with its own training and its own machinery. The GPT family takes a different starting point. Its pretraining rests on one deliberately simple goal, and the other abilities grow out of it.
GPT is pretrained on a single objective: predict the next word in a sentence from the words that come before it. Everything else in the GPT architecture exists to make that one prediction task work well.
Keep this single sentence in mind, because the rest of this article unpacks it. We will look at what one prediction looks like, where the architecture comes from, and why the model's own outputs become part of its later inputs.
Tracing One Next-Word Prediction
Begin with a partial sentence, such as The cat sat on the. The model sees only these words. Its job is to produce a guess for the word that comes next. A plausible continuation is mat, although a model might weigh several candidates before settling on one.
What matters for the architecture is the input-output shape of this step. The words so far go in, and one next word comes out. The rest of the design is about making that mapping from context to next word as good as possible.
The source also notes that this approach helps the model understand how words and phrases typically fit together in language. That understanding is described as a foundation that can be applied to various other tasks. The next-word objective is the pretraining step, and its benefits are meant to carry over beyond that single prediction.
Where the GPT Architecture Comes From
The source compares GPT with the original transformer architecture covered earlier in the course. Its verdict is that the general GPT architecture is relatively simple. The simplification is specific. GPT is essentially the decoder part of the original transformer, with the encoder removed.
Reading the comparison from top to bottom shows the relationship. The original transformer has two named parts. GPT takes only the decoder side, so the encoder does not appear in its design. This is why it is fair to describe GPT as a decoder-only design, with the decoder serving as the entire architecture.
Why GPT Is Called Autoregressive
Decoder-style models like GPT generate text by predicting one word at a time. Because of this, they are considered a type of autoregressive model. An autoregressive model is defined as one that incorporates its previous outputs as inputs for future predictions.
The important word in that definition is previous. A model that produces a word does not throw that word away. The word becomes part of what the model reads when it works out the next one. This is the feature that gives the label its meaning.
Read the cycle as a loop. The words so far feed the prediction step. The chosen word is then added to the sequence, and the longer sequence is what the next prediction reads. This loop is the mechanism behind the autoregressive label, and it is the reason GPT's word choices depend on everything that came before.
Tracing a Sequence Step by Step
Generating a continuation one word at a time
Starting from the sequence The cat sat, show how the model builds a longer sequence through repeated next-word predictions.
- 1Step 1: read the starting sequence
The model reads The cat sat and predicts a next word. In the source's example, that word is on.
- 2Step 2: append the chosen word
The predicted word is appended, giving The cat sat on. The sequence is now longer than the original input.
- 3Step 3: read the longer sequence
The model reads The cat sat on, including the word it just produced, and predicts again. In the source's example, the next word is the.
- 4Step 4: note the dependency
Each step uses the growing sequence as its input. The word the model chooses at step 3 is shaped by on, which the model itself produced at step 1.
The sequence grows from The cat sat to The cat sat on to The cat sat on the. This is the practical meaning of each new word being chosen based on the sequence that precedes it.
The source notes that because each new word is chosen based on the sequence that precedes it, the resulting text gains coherence. Each word is anchored to the words already written rather than being picked in isolation.
What do you think happens?
After the model appends on to The cat sat, what does it read when it predicts the next word?
Reveal answer
The longer sequence The cat sat on, including the word it just produced
The chosen word is added to the sequence, and the longer sequence is what the next prediction reads. The model does not discard its own output.
Mistakes When Reading the Loop
Common mistake Thinking the model predicts the whole continuation at once
What it looks likeAssuming the model outputs The cat sat on the mat in one shot.
Why it failsDecoder-style models like GPT generate text by predicting one word at a time.
Do this insteadEach call to the model produces one next word, which is then appended before the following prediction.
Common mistake Believing the generated word is discarded after it is produced
What it looks likeTreating on as a finished output that the model forgets when predicting the.
Why it failsThe autoregressive definition depends on previous outputs being incorporated as inputs for future predictions.
Do this insteadThe produced word becomes part of the sequence the model reads for the next step.
Common mistake Assuming the encoder is part of GPT because the original transformer had one
Why it failsThe source states that GPT is essentially the decoder part of the original transformer, with the encoder removed.
Do this insteadWhen describing GPT, refer to it as a decoder-only design.
Practice: Extending a Sentence
Start with the sequence The model reads. Write out the sequence after two rounds of the loop, assuming the model first predicts a word and appends it, then predicts another and appends that too. Mark which words are the original input and which were produced by the model. Then explain in one sentence why the second prediction depends on the first.
Hints
- Each round adds exactly one word to the end of the sequence.
- The original input words are never removed; the produced words are only appended.
- The second prediction reads the sequence that already includes the first produced word.
Key Takeaways
- GPT is pretrained on one objective: predict the next word in a sentence from the words that come before it.
- The GPT architecture is essentially the decoder part of the original transformer, with the encoder removed, so it is described as a decoder-only design.
- GPT is autoregressive because it generates text one word at a time and feeds each chosen word back in as part of the input for the next prediction.
- Because each new word is chosen based on the sequence that precedes it, the resulting text gains coherence.