Skip to content

GPT

A decoder-only Transformer that generates text one token at a time, each time predicting the next token from everything before it.

AlsoGenerative Pre-trained Transformer · causal language model · decoder-only Transformer

Fig. / How it works
thethecatcatsatsatononthethematmatEACH WORD LOOKS ONLY AT EARLIER WORDS
Role · kind
Models and algorithmsModel
Level
Intermediate

Radford et al., OpenAI, 2018

An autocomplete that only looks backward. It reads what has been written so far and guesses the next word, then the next, and so on, until it has written a whole answer.

Where it fits

+All relationships as a list

See it on the full map

Try it

How a language model picks the next word
Loading interactive widget…
TakeawayThe model only ever outputs probabilities. Temperature, top-k and top-p decide how adventurous the pick is, and the same model can sound careful or chaotic.

How it works

GPT uses the decoder half of the Transformer with one crucial restriction: a causal mask. When processing a token, attention may only look at earlier tokens, never later ones. That makes the training task honest: predict the next token without peeking.

Pretraining runs this on enormous amounts of text. Every position in every document is a training example: given everything so far, what comes next? It is self-supervised, so the amount of training data is limited only by the text you can collect.

Generation is a loop:

  1. Feed in the prompt.
  2. The model outputs a probability for every possible next token.
  3. Sample one, append it, and go back to step 2.

OpenAI’s GPT series showed that scaling this simple recipe goes a very long way: GPT-3 (2020) could perform new tasks from just a few examples in its prompt. Today almost every large language model, including Claude, is a GPT-style decoder-only Transformer.

Compare with BERT, which sees both directions but is not built to write.

Everyday use cases

  • Case 01

    Writing and chat

    GPT-style models draft emails, essays and code, and power chat assistants.

  • Case 02

    Phone keyboard suggestions

    Predicting your next word is a tiny version of the same task.

Famous examples

Strengths, weaknesses and when to use it

Strengths

  • Naturally generative: the same model writes, answers and reasons in text.
  • Scales remarkably well with more data and parameters.

Weaknesses

  • Sees only left context during generation.
  • Generates one token at a time, so long outputs take time.

When to use itFor any task where the output is text. "GPT-style" now describes most large language models, not just OpenAI's.

Compare with

Check yourself

  1. Q01

    What can each token "see" in a GPT model?

    Show answer

    A: Only tokens before it

  2. Q02

    How does GPT write a paragraph?

    Show answer

    B: One token at a time, feeding each new token back in

Go deeper

Learn first