OpenAI logo
OpenAISample

GPT

Next-token prediction · Jun 2018

The model family that made next-token prediction famous: a Transformer trained to guess the next piece of text, then tuned with human feedback to follow instructions.

Released
Jun 2018
Access
Closed
Parameters
117M (GPT-1), 1.5B (GPT-2), 175B (GPT-3); undisclosed since GPT-4
Architecture
Decoder-only Transformer
Training data
Web text, books and code. GPT-3 saw about 300 billion tokens; later corpora are undisclosed.
TextCodeImageAudio

The statistical view

The probability of the next token given every token before it. Chained together, these conditionals give the probability of a whole text.

p(x₁ … x_T) = ∏ₜ p(xₜ | x₁ … xₜ₋₁)

Loss
L = −Σₜ log p_θ(xₜ | x<ₜ): cross-entropy, which makes pre-training maximum-likelihood estimation of the text distribution.
Answering
Sample a token from the predicted distribution, append it, repeat. Temperature T reshapes the distribution first: pᵢ ∝ exp(zᵢ / T).

What comes next?

Cover everything after position t and predict it. Repeated over a corpus, this is maximum-likelihood estimation of the distribution of text.

A demonstration of the objective, computed in your browser on illustrative data. It is not GPT running here.

How it is trained

  1. 1Split text into tokens (sub-word pieces) with byte-pair encoding.
  2. 2Pre-train: predict each next token over a huge corpus, minimising cross-entropy.
  3. 3Supervised fine-tuning on example conversations written by people.
  4. 4Reinforcement learning from human feedback (RLHF): a reward model learned from human rankings of answers steers the model towards preferred responses.

Line of descent

  1. Jun 2018GPT-1 — 117M parameters. Generative pre-training, then fine-tuning per task.
  2. Feb 2019GPT-2 — 1.5B parameters, released in stages over misuse concerns.
  3. May 2020GPT-3 — 175B parameters. Learns new tasks from a few examples in the prompt.
  4. Nov 2022ChatGPT — A GPT-3.5 model tuned with RLHF for conversation.
  5. Mar 2023GPT-4 — Accepts images as input. Size and training data no longer published.
  6. Aug 2025GPT-5 and gpt-oss — A new flagship, and OpenAI’s first open-weight models since GPT-2.

What data teams use it for

  • Text-to-SQL and code generation for analysis
  • Classifying and extracting fields from free text: tickets, reviews, contracts
  • Summarising reports and explaining query results
  • Generating synthetic text for testing pipelines

Limits

  • Fluent is not the same as correct: it can state false facts with confidence
  • The GPT-4 report found the pre-trained model well calibrated, and post-training made its confidence less reliable
  • Arithmetic and exact aggregation over large tables are unreliable without tools
  • Closed weights and undisclosed training data limit auditing

Classic algorithms underneath

The same ideas, small enough to train in a browser.

Same objective