How does a language model continue text?

The model scores its options, adds one token, and predicts again with the updated context.

  1. 1 Tokens
  2. 2 Model layers
  3. 3 Next token

A word in context

Input

Output

Inside the networkTraining sets the weights. A different input changes the signals, not the weights.Illustrative activations
InputPhrase tokens
Model layers · Language model
OutputNumerical features

Each token gets an initial representation.

Illustration of layers and activations

Switch contexts to see how the prediction changes.

The mechanic inserted the key into the

Illustrative next-token options

  1. ␣lock
  2. ␣vault
  3. ␣file

Add one piece to the phrase

What happens inside the model?

Training changes the weights. When the model answers, the weights stay fixed and the layers process new signals.

The mechanic inserted the key into the

o200k_base tokenizer: starting phrase
  • The#976
  • ␣mechanic#75544
  • ␣inserted#40986
  • ␣the#290
  • ␣key#2140
  • ␣into#1511
  • ␣the#290

The ␣ symbol shows a space. The ellipsis is not part of the input.

The model uses the last position to score possible next tokens. Once a token is added, it becomes part of the context and the model scores the options again.

Which detail needs checking?

Source note
The city library will open on Friday. Admission is free.

Select the detail that needs checking before publication.

Model, tools and application
Model

Transforms data

A language model scores possible continuations. Models for other formats can encode audio or generate images.

Harness

Manages tools

It extracts text from files, calls search, gives results to the model and checks which actions are allowed.

Application

Provides the workspace

ChatGPT assembles conversation context. Codex can also work with project files, run commands and run checks.

Sources and simulation limits
How AI works | AI BriefWire