liveBook · Manning

Decoder-only transformer

As explained in How Large Language Models Work

A decoder-only transformer is a transformer architecture composed of decoder-style layers that generates outputs autoregressively from preceding context.

A decoder-only transformer generates text by taking a partially written document and predicting a likely next token. It is the architecture behind systems such as GPT and Gemini, though its fluent output should not be confused with human understanding or reasoning. section 3.1

A simple generation loop looks like this:

  • Represent tokens as numerical embedding vectors and add position information so the model can track word order. section 3.5
  • Use attention, a fuzzy-dictionary process involving queries, keys, and values, to relate parts of the context. section 3.5
  • Produce probabilities for every possible next token, then select one through unembedding or sampling. section 3.5
  • Feed the selected token back with all previous tokens and repeat, making the process autoregressive. section 3.5

Continuing a document

Given a partially written document, the model predicts a likely continuation one token at a time. Adjusting sampling randomness can make the result more consistent or more creative, but not necessarily more accurate. section 3.1 section 3.5

How How Large Language Models Work covers it

How deep it goes
Explains embeddings, position, attention, probabilities, and sampling, but does not derive transformer mathematics or training procedures.
Examples
Uses GPT, Gemini, ChatGPT, and the continuation of a partially written document as examples.
What you can do after
Evaluate generated text by recognizing next-token prediction, probability-based output, and sampling randomness.
How it connects
Connects decoder-only transformers with transformers, attention, embeddings, encoder-only transformers, and encoder-decoder transformers.

Also explained in

Compare how 8 books explain decoder-only transformer →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of How Large Language Models Work. The section links point to the parts of the book it draws on.