Overview: what is an LLM?
Understand the model, its computation, and its main uses
Lesson objective. Trace two generation steps with fixed parameters and distinguish generating a token, scoring an observed target and training.
Lesson skeleton
- Next-token prediction + Autoregressive generation (preview) · Trace two rounds of prediction and feedback
“What have the Romans ever done for us?” The question sets off a long series of answers. Put the same question to a conversational assistant: it carries on too. How does a program produce a continuation from a question?
The response is built one token at a time. From the text so far, the language model computes probabilities for the next token. A decoding rule selects a token, which is appended to the text before the next calculation. A language model trained at scale is a large language model (LLM).
The prefix is the question: “What have the Romans ever done for us?” It is the text supplied to the model. The continuation is what comes next. In the film, several characters answer in turn with aqueducts, sanitation, roads, and irrigation.
The scene is a hook, not a literal single-speaker generation. For calculations, the path uses an original continuation written for LLM Lab: “They built roads between distant towns.” The characters are fictional. The LLM is the model that the conversational assistant queries. This overview starts by following the model’s computation.
A model estimates a next-token distribution. It can be used to generate, score, or train: three distinct uses, not steps in one execution. An LLM is a model category, Transformer an architecture family, and GPT a decoder-only Transformer family.
Estimated reading time: 8–10 minutes.
By the end of this page, you should be able to: - trace two prediction-and-feedback steps with fixed parameters; - explain the roles of the prefix, the next-token distribution, and the parameters; - distinguish the three uses of that distribution: generation, observed-target scoring, and training.
The sections on transfer, external information, and conversational systems then broaden the overview. To continue through the main path, first retain the prediction mechanism and the distinction between its three uses.
What the model predicts
The question “What have the Romans ever done for us?” is the prefix: the text already supplied to the model. The continuation is what comes next. Given the prefix, the model computes a probability distribution for the next token. Imagine the following result:
| Possible next token | Probability |
|---|---|
| “They” | 0.6 |
| “Aqueducts” | 0.2 |
| “Nothing” | 0.1 |
| “Well” | 0.1 |
These values are illustrative. Real tokens can be word fragments; the same numbers are reused across pages so the calculations can be checked by hand.
This is a conditional distribution: probabilities are computed given the prefix and sum to 1. If the decoding rule selects “They”, the token is appended to the context; the model then computes a new distribution conditioned on the extended prefix.
In turn 2, the question followed by “They” yields a new illustrative distribution. “built” gets 0.5, “gave” 0.3 and “made” 0.2. If the rule selects “built,” the context now contains “They built.” The parameters are the same in both turns.
Three terms are enough:
- Token: a unit handled by the model, not necessarily a whole word (tokenization).
- Context: supplied tokens and tokens already generated.
- Parameters: learned numbers that stay fixed during ordinary inference.
A probable continuation is not necessarily true: good prediction does not prove human-like understanding (limits).
From text to a distribution
If the rule selects “Aqueducts” first, what changes on the second turn?
The new prefix ends in “Aqueducts.” The model recomputes the distribution from that prefix with the same parameters. The second-turn probabilities above were computed for the prefix ending in “They.”
A preview of computation inside a GPT
An autoregressive GPT turns text into tokens, their IDs into numeric representations, and processes those representations through Transformer blocks. The output head produces logits, which are converted into probabilities; a decoding rule then selects a token, appends it to the context, and starts the next computation. Selection happens after the Transformer has computed the distribution.
The diagram describes one computation, not a reading order. The canonical Understand sequence is shown in the learning map. For the individual mechanisms, see text and tokenization, embeddings, the Transformer, logits and probabilities, and generation.
One computation, three uses
A computed distribution can be used to produce a continuation, score a known sequence, or train the model.
- Generate: process the prompt first (prefill), then select a token, append it to context, and repeat during decode (generation).
- Score: at each position, condition on the observed prefix and read the probability of the target token to calculate the sequence likelihood; no token is selected and parameters stay fixed (likelihood).
- Learn: calculate a loss and gradients to update parameters; teacher forcing supplies the observed previous tokens as context (loss, gradients, training examples).
For a token with probability 0.6, surprisal is \(-\ln(0.6)\approx 0.511\) nats. Entropy is expected surprisal. Scoring measures the likelihood of a target or sequence. Evaluation compares results on held-out examples. Only learning changes parameters.
A sequence likelihood is the product of its successive conditional token probabilities (mathematical formulation). Practise the calculation on an observed continuation.
LLM, Transformer, GPT: three notions
LLM describes a language model trained at scale, not a particular architecture. No universal parameter threshold defines the category on its own: data and training compute matter too (scaling laws).
Transformer names a family of architectures with several configurations:
| Family | General behavior | Example |
|---|---|---|
| Encoder-only | Builds contextual representations of the input; often used for understanding or classification | BERT |
| Encoder–decoder | Produces an output conditioned on an input, especially for sequence-to-sequence tasks | Original Transformer, T5 |
| Decoder-only | Processes a causal context and predicts subsequent tokens | GPT-3 |
GPT (Generative Pre-trained Transformer) names a family of decoder-only Transformers pretrained to predict the next token. LLM Lab studies a small GPT of this kind because its computation can be followed and programmed end to end (architecture comparison, Build path). This is a teaching choice: not all LLMs are GPTs. For concise definitions, see the LLM and Transformer glossary.
Architecture, learning, use
Describing a model means answering three questions:
| Dimension | Question | Examples |
|---|---|---|
| Architecture | How does the network transform information? | Encoder-only, encoder–decoder, decoder-only |
| Learning | How are parameters obtained or adapted? | Pretraining, fine-tuning, SFT, preference optimization |
| Use | What do we do with the model, parameters fixed? | Generation, classification, scoring, ICL, RAG, tools |
Pretraining learns regularities from large corpora. For a GPT, the text tokens are the targets; this is generally self-supervised learning. The resulting model before adaptation is often called a base model. A foundation model is a broader notion: a model trained at scale on broad data and adaptable to many tasks, sometimes beyond language (Bommasani et al., 2021). Post-training may then adapt behavior or parameters, but it is not mandatory (post-training).
Questions and exercises for this overview.
Why can prediction support varied tasks?
Pretraining does not explicitly teach every task the model may later perform. Across large corpora, it learns language regularities, relationships, and representations that can be reused when a task is expressed in the input, examples are supplied, or parameters are adapted. This is transfer learning: a general objective can support tasks that were not explicit training objectives. Transfer nevertheless depends on the data, task, and evaluation; it is neither universal nor automatic (LLM evolution, emergence, limitations).
An information-theoretic perspective sometimes connects this prediction to predictive compression: the model adjusts probabilities to anticipate continuations. But a probability distribution does not, by itself, decompress a sequence; exact coding requires a compatible encoder and decoder. This perspective is not, by itself, a complete theory of intelligence. For what entropy measures, see the dedicated lesson; to distinguish predictive compression, model compression, and runtime memory, see the compression revision sheet. For historical milestones and Transformer trade-offs, see the history of Transformers.
Where does information reside?
An answer can draw on information stored in different places. Distinguish where it is stored, how it becomes accessible, and how it is used.
| Location | Examples | How it can influence the answer |
|---|---|---|
| Learned parameters | Regularities and representations acquired during pretraining or post-training | They participate in computation, but are not a queryable document database |
| Active context | Instructions, messages, examples, documents, and tool results actually supplied | The model conditions its prediction on this content, which can change from one request to another |
| External sources | Documents, databases, and indexes used by RAG or tools | Information matters only if it is retrieved and then made available to the model |
| Runtime state | KV cache computed during inference | It avoids some recomputation and speeds up decoding; it is neither learning nor document memory |
RAG retrieves external information and can add it to context; retrieval alone is not enough. A document can be stored, indexed, or retrieved without being supplied. Context engineering designs and structures the input; RAG and memory follows the information lifecycle; document retrieval details search and ranking methods. ICL describes what the model does with examples present in context (ICL).
From a model to a conversational system
A conversational assistant is a system built around a model. The application formats messages, manages context, and coordinates tools. System, user, and assistant are message roles, not Transformer layers. A model-generated tool request has not run: the application validates it, calls the tool, and returns the result. Persistent memory also belongs to the application (LLM evolution, Build).
Choosing an approach
Compare the roles of context and model parameters in the review plan.
Depending on the task, one can use a general model as is, supply context and external documents, adapt parameters, or have the application call tools. These approaches can be combined. The choice depends on measured quality, robustness, information freshness, cost, latency, privacy, provenance, and maintenance. A few successful prompts are not an evaluation (post-training, RAG and memory).
- History and architecture: history of Transformers and architecture comparison.
- Computation and learning: generation, mathematical foundations, and post-training.
- Context and external information: context engineering, RAG and memory, and document retrieval.
- Compression and information: entropy and the compression and LLM revision sheet.
- Watch an end-to-end overview: Andrej Karpathy — Deep Dive into LLMs like ChatGPT (2025, English video, about 3 h 31); an orientation resource, not a replacement for the detailed lessons.