AI State of the Art
Fundamentals/NLP: From Classical to Modern/27 min
Section 43

GPT: Auto-regressive Language Modeling

Listen as a podcast β†’

The fundamental formula: predict the next token

An auto-regressive language model (also called a causal language model, abbreviated CLM) does something very simple: it looks at all the previous tokens (the word fragments produced by tokenization) and predicts the next one. That is the principle behind GPT, for Generative Pre-trained Transformer.

Given: "The black cat"

Predict: ?

Model's answer: "sleeps" (65%), "jumps" (20%), "meows" (15%)

Mathematically:

P(sentence)=P(t1)Γ—P(t2∣t1)Γ—P(t3∣t1,t2)Γ—β‹―P(\text{sentence}) = P(t_1) \times P(t_2 \mid t_1) \times P(t_3 \mid t_1, t_2) \times \cdots

Reading the formula. t1,t2,t3t_1, t_2, t_3 are the successive tokens of the sentence. P(β‹…)P(\cdot) is a probability, a number between 0 and 1. The vertical bar "∣\mid" reads "given": P(t2∣t1)P(t_2 \mid t_1) is the probability of the second token given the first, a conditional probability, a notion set out in probability: axioms, conditionals, Bayes. The multiplication is there because the whole sentence is the conjunction of all these events. In one sentence: the probability of a sentence is the product of the probabilities of each of its tokens, each judged in the light of everything before it.

Each prediction conditions the next. That is what auto-regressive means: the model feeds on its own output to continue.

How it's implemented: the causal mask

Causal mask matrix for attention
This matrix illustrates the principle of causal masking in attention mechanisms. Each token can only access itself and previous tokens, ensuring that information flows in only one temporal direction.Source : Modular, Build an LLM from scratch with MAX

In Transformer attention, you could theoretically look at all tokens (past and future). GPT says no. It uses a causal mask: each token looks left only.

TokenSees (self + past)Does NOT see (masked future)
"cat"[The, black, cat][sleeps, jumps, runs, ...]

This is implemented in attention: scores toward the future are set to -infinity, so attention physically can't see them.

Result: each token only knows what happened before. Natural for generation (you generate token by token).

GPT and BERT in one sentence
  • GPT: looks left only (causal) -> generates text naturally.
  • BERT (Bidirectional Encoder Representations from Transformers, see the BERT lesson): looks everywhere in the sentence (bidirectional) -> understands better, but cannot generate text.

Two strategies, two use cases.

GPT-1: the foundation (June 2018, before BERT)

GPT-1 (OpenAI) arrives before BERT (which comes out in October 2018). That matters historically. GPT-1 shows that a plain Transformer decoder, trained to predict the next token over a large book corpus and then specialized (fine-tuned) per task, beats the best results of the day.

Minimal architecture:

  • 12 Transformer layers
  • 117 million parameters (small, by today's standards)
  • Two clearly separated phases:
    1. Pre-training: learn to predict the next token on BooksCorpus, a collection of over 7,000 unpublished books.
    2. Fine-tuning: adapt the model to one specific task, on labeled data, at a tiny fraction of the compute cost.

The result the paper claims: GPT-1 improves the state of the art on 9 of the 12 tasks studied.

The context

In 2018, fine-tuning was common for images (classic deep learning). But for text? It was new and radical. The idea: a generalist model trained on a large universal corpus can perform on any task.

BERT arrives three months later and overshadows it (bidirectional, better benchmarks). But GPT-1 laid the foundation. The "massive pre-training + lightweight fine-tuning" paradigm dates from there.

GPT-2: the "oh crap, this is more powerful than we thought" moment (2019)

GPT-2 has 1.5 billion parameters, roughly thirteen times GPT-1 (1,500 / 117 β‰ˆ 13). It is trained on WebText: per the OpenAI paper, about 40 GB of text from web pages linked from Reddit, keeping only links that had received a minimum of upvotes, a crude but cheap quality filter.

The discovery that unsettled people

GPT-2 can do things with no fine-tuning at all. You just ask, in the prompt, the text instruction you send the model:

Model input:

sea otter => loutre de mer

cheese =>

Model output: "fromage"

GPT-2 translates without having been trained on a parallel English-French corpus: it simply met enough bilingual passages in the web pages of its corpus to recognize the shape "English word, arrow, French word".

This is zero-shot learning ("with no examples at all"): give the intent in the prompt, and the model extrapolates.

Other examples:

  • Text completion: "Once upon a time" -> GPT-2 generates a coherent story
  • Summarization: "Article: [...] TL;DR:" -> summarizes
  • Q&A: without Q&A training data, answers questions

The publication controversy

OpenAI initially refused to publish the full GPT-2. Reason: "fear of fake news and abuse." The community cried "censorship! this is science!" After a few months of debate, they published it.

A debate still alive in 2026: when is a model too powerful to publish? OpenAI was preaching open science but was afraid of their own creations.

The tension between science and responsibility

GPT-2 opened a debate that remains unresolved: should we always publish models? Vet them beforehand? Keep them secret to limit abuse? There is no unanimous answer in the community. Publishing favors open research and competition, but also gives disinformation tools to anyone who wants to misuse them. Withholding models protects in the short term but creates de facto power in the organizations that hold them. This balance remains difficult to find, and every major model release reignites the debate.

GPT-3: the "we're not ready" moment (2020)

GPT-3 has 175 billion parameters. The paper's abstract puts it this way: ten times more than any previous non-sparse language model. The body of the paper reports that the Common Crawl portion of the training mix amounts to 570 GB of text after filtering and deduplication (down from roughly 45 TB before filtering). See also the reading note on the GPT-3 paper.

Language Models are Few-Shot Learners

In-context learning: the illusion of understanding

GPT-3 does something that seems impossible: learn from a few examples directly in the prompt, without retraining.

Few-shot prompt:

Sentiment: "I love it!" -> Positive

Sentiment: "Meh..." -> Neutral

Sentiment: "Excellent!" ->

GPT-3 responds: "Positive"

How? During pre-training, GPT-3 met an enormous number of passages shaped exactly like this (a list of examples followed by a case to complete) and it recognizes the shape. There is no learning in the strict sense: the model's weights do not move at all. Everything happens within the computation of a single answer.

This is in-context learning, covered in in-context learning:

  • zero-shot: "Translate to French:" (no example);
  • one-shot: one example;
  • few-shot: a handful to a few dozen examples.

One honest caveat, which the paper's own abstract raises: few-shot still falls well short of a fine-tuned specialist on several datasets, and the paper flags a real methodological problem, when you train on a large slice of the web, it becomes hard to guarantee the test sets were not already in there. See benchmark limits.

The real result: confirmation of scaling laws

Kaplan et al. (OpenAI, January 2020) publish the scaling laws, covered in Kaplan scaling laws. Their form is not a product but a power law on the model's error, one per resource. For parameter count:

L(N)=(NcN)Ξ±NL(N) = \left(\frac{N_c}{N}\right)^{\alpha_N}

Reading the formula. NN is the model's parameter count. LL is the loss: the model's average error when predicting the next token, lower is better. NcN_c is a fitting constant, measured experimentally, with no physical meaning: it only sets the curve's scale. Ξ±N\alpha_N is the exponent, and it carries all the meaning. In one sentence: every time you multiply model size by some factor, the error is divided by some fixed factor, a straight line, if you plot both axes logarithmically.

The paper measures three such exponents, one per resource: about 0.076 for parameter count, 0.095 for data volume and 0.050 for compute budget. These are small numbers, and that is the point: with an exponent of 0.076, making the model 10x bigger divides the error only by 100.076β‰ˆ1.1910^{0.076} \approx 1.19, a 16% improvement. So you spend a great deal to gain a little, but you know how much you will gain, and that is what changes everything.

Before: "do we gain by going bigger?" After: "yes, and here is by how much." A lab can budget in advance the compute needed to reach a target error. Two years later, Chinchilla would correct the proposed balance between model size and data volume.

The political cost

Training GPT-3 cost several million dollars. The exact figure was never published by OpenAI; the estimates in circulation (often a few million) are third-party reconstructions from graphics-card rental prices, and should be treated as such. What is solid is the order of magnitude: in 2020, only a handful of organizations could afford such a training run.

Consequence: a concentration of power. The most capable models are expensive to train, so few actors train them, and those actors decide what the models will and will not do.

Efficiency and access

Scaling laws formalize an uncomfortable reality: the bigger the model, the better the performance. But the bigger it is, the more expensive its training, and fewer organizations can afford it. It's not just a money problem, it's a question of who controls the technology.

When only a few multinationals can train the best models, they also decide what those models can do, what they refuse to do, and who gets access. The benefits of generative AI are potentially universal, a doctor in Senegal, a teacher in Bolivia, an independent developer in Lyon. But the innovation itself concentrates where the capital is. The debate is therefore about a societal choice: should we regulate access to large models, force their open-source publication, or let the market decide? There's no simple answer, but ignoring the question is not an option.

Why "decoder-only" won the architecture war

Between 2018 and 2022, three families of architecture fought over the ground (their mechanics are described in encoder and decoder):

  • encoder-only (like BERT): bidirectional, good for comprehension;
  • encoder-decoder (like T5 and BART): bidirectional reading of the input, then sequential generation of the output;
  • decoder-only (like GPT): leftward reading only, free generation.

Decoder-only won. Why?

Reason 1: simplicity enables scaling

A decoder-only is a single stack of Transformer layers, a stream of tokens that enters one side and exits the other. No separate encoding module, no cross-attention (the mechanism by which a decoder consults the representation the encoder produced). One architecture, one path.

An encoder-decoder is two distinct modules joined by that cross-attention. More components means more complexity to optimize, more memory, and more friction when the model has to be spread across hundreds of graphics cards. At 175 billion parameters, every simplification counts.

That's why labs settled on decoder-only for their largest models.

Reason 2: extreme flexibility

A decoder can do anything:

TaskExample prompt -> output
Classification"Sentiment: excellent!" -> "positive"
Named entity recognition (NER)"Entities: Pierre lives in Paris" -> "[Pierre:PERSON, Paris:LOCATION]"
Summarization"[Article...] Summary:" -> "[3 lines]"
Translation"[English text] French translation:" -> "[French]"
Code"Write a Python function:" -> [code]
Dialogue"User: Hello. Assistant:" -> "Hello! How are you?"

Encoder-decoder shines at translation and summarization (structured tasks). But decoder-only handles everything the same way: every task becomes "generate text following a prompt."

Reason 3: in-context learning changes the game

With a decoder-only, you adapt the model to a new task just by changing the prompt, without touching the weights, without retraining anything. That is in-context learning.

An encoder-decoder like T5 doesn't have this flexibility: for a new task, you generally need to fine-tune it on a dedicated dataset. That takes time, labeled data, and compute. GPT adapts immediately, you just rephrase the instruction.

It's this ability that made GPT a universal tool: a single model that does translation, code, summarization, classification, dialogue... just by changing the instructions you give it.

Complementary paradigms, not antagonists

Each architecture kept a territory. Encoder-only (the BERT family) is still widely used in 2026 for semantic search and classification: fast, cheap, and quite good enough when latency matters. Encoder-decoder was the best answer to structured tasks (translation, specialized summarization) into the early 2020s, but it has since lost that ground to large instruction-tuned models. Decoder-only offers the universal flexibility.

The evolution: from GPT-3 to today

After GPT-3, the evolution is less about the architecture (still a decoder-only Transformer) and more about alignment and capabilities.

InstructGPT / GPT-3.5 (2022) marks a turning point: OpenAI applies RLHF (Reinforcement Learning from Human Feedback, covered in RLHF) to teach the model to follow instructions rather than merely continue a text. The model goes from "I finish your sentence" to "I answer your question."

ChatGPT (November 2022) is that model wrapped in a conversational interface. Technically, almost nothing new. The impact is cultural: the general public discovers generative AI, and everyone wants a conversational agent.

GPT-4 (March 2023) adds two things: multimodality (the model accepts images as input, not just text) and a clear step up in reasoning, math, code, logic. OpenAI's technical report notably claims a top-decile result on the US bar exam; that kind of figure comes from the company selling the model and has been contested since, so it travels with its source. GPT-4 Turbo then extends the context window to 128,000 tokens, an entire book in a single request.

Two dating notes, as of July 2026. First, the family continued (GPT-5 and later) but OpenAI stopped publishing model sizes: nobody outside the company can state a parameter count for GPT-4 or its successors, and any figure in circulation is speculation. Second, GPT-3 itself is no longer a model anyone uses: it has been retired from public interfaces and replaced by instruction-tuned models that are markedly more capable at comparable size. Its value here is historical.

The common thread: scale + alignment = new capabilities. The architecture has barely changed since GPT-1; it is scale, data quality and alignment methods that made the difference.

Why this matters

GPT illustrates something counter-intuitive: at sufficient scale, one banal task (predicting the next word) yields a general-purpose tool. The model was never explicitly trained to translate, summarize, or code. It learned to predict the next token over enough text, and those abilities showed up along the way (see emergent abilities).

The GPT family also shows that the dominant question is no longer "what new architecture do we invent?" but "how do we grow and align what we already have?" From GPT-1 (117 million parameters) to GPT-3 (175 billion), size is multiplied by roughly 1,500, the arithmetic in plain view: 175,000 / 117 β‰ˆ 1,500. Beyond that, as noted above, sizes are no longer published, so the factor cannot be extended.

The practical consequence: access to compute and to massive data now weighs more than an elegant theoretical idea.

Finally, decoder-only has won nothing permanently: encoder-only keeps its uses, and other families are advancing, notably SSMs (State Space Models) such as Mamba, and hybrid architectures. But in July 2026, decoder-only remains the dominant architecture of generative AI.

Check your understanding0 / 4

1. In the GPT-3 paper, what does the number 570 refer to?

2. During in-context (few-shot) learning, what happens to the model's weights?

3. Why did the decoder-only architecture win against encoder-decoder?

4. What do Kaplan's scaling laws say about multiplying model size by 10?