From LLMs to Agents

What the model is, how it is built, and how it begins to act

2026-09-15

One question: what is on the other side of the text box?

If you type into a system like ChatGPT, what exists on the other side, how was it created, and what happens to your text?

  1. raw data
  2. curated training corpus
  3. tokenizer
  4. pretraining
  5. base model
  6. post-training
  7. post-trained model
  8. inference-time context
  9. tools, external state, and the loop
  10. agentic system
The whole route in one line: raw data is curated into a training corpus and tokenized; pretraining produces a base model; post-training produces the post-trained model that products build on. At use time, the surrounding system supplies the model's inference-time context, and software outside the model adds tools, external state, and retrieval, which brings information into that context; software that calls the model in a loop with those pieces is an agentic system. Colors mark the five kinds of thing involved: data, training, the model, context, and the software around it.

The website tells the same story with the mathematics: The Short Story.

The route, in three parts

How a model is built Text is prepared, cut into tokens, fed to a neural network, and training sets the network’s numbers.

What happens when we use it Your text becomes the model’s context; it produces one token at a time; its numbers stay fixed.

How software makes an agentic system Tools, stored state, and a loop around the same fixed model.

A runnable model is code plus learned parameters

What a runnable model is architecture / runner code how to compute: sums, nonlinearities, attention + learned parameters θ learned values stored in a checkpoint model inference context in → next-token distribution out; θ unchanged

The code says how to compute. Training discovered the parameter values. Inference uses them without changing them. The application adds instructions, conversation management, tools, and other software around the trained model.

Karpathy, Intro to Large Language Models (2023) · Karpathy, llama2.c · lesson: How Pretraining Works

Before training, someone builds the corpus

  1. raw sources: web pages, code, books
  2. extract the main text
  3. filter by language and quality
  4. remove duplicates
  5. curated corpus
  6. tokenizer
  7. token sequences for training
Before any training, a corpus is built: source material is gathered from permitted sources, the main text is extracted from its raw form, documents are filtered by language and quality, duplicates are removed, and the surviving text is tokenized into the sequences the model will be trained on. The steps and their order vary between corpora; this is the general shape.

Text is gathered from permitted sources, extracted from raw pages, filtered by language and quality, deduplicated, then tokenized. What goes in shapes what can be learned.

FineWeb is one open, documented example. Closed corpora are often not disclosed.

Penedo et al., The FineWeb Datasets (2024) · lesson: From Text to Numbers

Text becomes tokens; a token ID is an address

The␣bridge␣was␣closed. → 1032247188510912

The tokenizer cuts text into entries of a fixed vocabulary; each entry has an index. The split and the numbers above are illustrative.

5109 is not larger, later, or more than 88. It only says which entry.

The ID selects a learned vector

From token to ID to learned vector “bank” token ID 3912 embedding table E row 3912 E[3912] = (0.18, −0.42, 0.07, …)

Row 3912 of the embedding table is a list of learned numbers, not a definition. Training changed them because that improved prediction.

Later layers make the vector depend on its context: ␣bank starts the same in “river bank” and “central bank” and ends different.

A neural network: learned transformations and nonlinear steps

A basic neural-network building block x inputs Wx + b learned W, b σ nonlinearity h output in this toy unit, training changes W and b

One piece: multiply the inputs by learned weights, add a bias, apply a fixed nonlinear function. Written out: h = σ(Wx + b). Large networks stack millions of such pieces, and training sets the weights.

Neural language models came first; recurrence paid a price

Recurrent sequence processing token 1 token 2 token 3 token 4 token 5 information from token 1 reaches token 5 only through 4 sequential steps

Recurrent networks pass a running state one position at a time: distant positions connect only through every step between them, and training cannot compute positions in parallel.

Bengio et al. (2003) · Vaswani et al., Attention Is All You Need (2017), §1 · lesson: Why Transformers

Attention: each position combines what it is allowed to see

What one attention head computes destination The bridge closed because it 0.03 0.55 0.12 0.25 0.05 weighted combination of vectors updated representation of “it” illustrative weights for the destination “it”; they sum to 1.00

Compare the destination with each permitted source to get a score. Softmax turns the scores into weights that sum to one. Combine the sources’ vectors with those weights to update the destination. The weights explain no more than that.

Vaswani et al. (2017), §3.2 · Bahdanau, Cho, and Bengio, Neural Machine Translation by Jointly Learning to Align and Translate (2015) · lesson: How Self-Attention Moves Information

The Transformer: attention plus feed-forward, without recurrence

Direct attention to permitted earlier positions pos. 1 pos. 2 pos. 3 pos. 4 pos. 5 each position reads its permitted earlier positions in one layer in training on a known sequence, positions within a layer compute in parallel

Attention Is All You Need (2017) built the architecture around attention and per-position computation. During training on a known sequence, positions compute in parallel; generation is still one token at a time. Causal: a position never sees later tokens.

Vaswani et al., Attention Is All You Need (2017) · lesson: Why Transformers

Pretraining: the text supplies its own answers

  1. token sequences
  2. predict the next token
  3. loss: probability given to the actual next token
  4. backpropagation: gradients
  5. optimizer: update θ
  6. repeat over the corpus

The loss scores how little probability went to the token that actually came next. Backpropagation computes gradients. The optimizer changes the parameters. Repeated at enormous scale, this produces the base model.

Karpathy, Deep Dive into LLMs like ChatGPT (2025) · Radford et al. (2019), §2 · lesson: How Pretraining Works

The base model is not a database and not yet an assistant

It captures the statistical structure of text: grammar, meaning, recurring facts, conventions of argument.

It can reproduce text it saw, but it stores no verified, searchable record of the corpus.

Given an instruction, it may answer it, continue it, or produce more instructions like it.

Radford et al. (2019) · Brown et al. (2020) · Carlini et al., Extracting Training Data from Large Language Models (2021) · lesson: How Pretraining Works §6–§7

Post-training changes the same parameters with different data

Pretraining

Data: a very large curated corpus

Objective: predict the next token

Changes: the trainable parameters θ

Supervised fine-tuning

Data: prompt → desired response

Objective: the same next-token loss, on the response

Changes: the same θ

Preference- or reward-based

Data: comparisons, or checkable outcomes

Objective: further shape behavior with the signal

Changes: the same θ again

Same loss, gradients, and optimizer. Different data and objectives. Demonstrations, preference comparisons, and checkable rewards are three different routes; providers combine and vary them.

Why a fluent answer can still be wrong

Pretraining rewards plausible continuation; nothing in it checks truth.

Post-training makes answering the default, so a well-formed answer can outrun what the parameters contain.

Recipes can teach abstention. Retrieval and tools supply inspectable evidence, which still has to be evaluated.

What happens when you type

The token-generation loop context the text so far tokenizer token IDs embeddings transformer blocks logits softmax probabilities decoding next token the new token is appended to the context and the loop runs again

One token per pass, appended, then again. Earlier keys and values are cached. Nothing in θ changes.

Some models are trained to reason longer on checkable problems

Reinforcement learning against automatically checked outcomes, such as a math answer or a passing test, can reward useful intermediate reasoning before the final answer.

DeepSeek-R1 is one published recipe: R1-Zero applied reinforcement learning directly to the pretrained base model, with no supervised fine-tuning first; the released R1 added supervised stages.

One route used by some reasoning-oriented models. Not a stage every model passes through.

DeepSeek-AI, DeepSeek-R1 (2025) · lesson: Post-training §7

“Thinking longer” at inference spends computation, not training

immediate response
  1. prompt
  2. answer
more inference-time reasoning
  1. prompt
  2. intermediate reasoning tokens
  3. more intermediate reasoning
  4. answer
reasoning with tools
  1. prompt
  2. reasoning
  3. tool request
  4. software runs the tool
  5. observation enters context
  6. reasoning
  7. answer
Three ways one trained model can be used at inference time. In every row the parameters stay fixed. In the second row the model generates intermediate reasoning tokens before its answer, which is additional inference-time computation by the same next-token mechanism, not a change to the model and not human thought. In the third row the model's reasoning produces a tool request; the software outside the model executes it, and the observation returns to the context for further reasoning.

Parameters stay fixed. Extra intermediate tokens give the same model more sequential computation before an answer. Providers expose it as effort or thinking levels; what is shown of the reasoning depends on the product. More reasoning is not a guarantee.

Anthropic, Thinking · Google, Gemini thinking · OpenAI, Reasoning models (docs, accessed 2026-09-15)

Parameters, context, and external state are different places

Parameters, context, and external state training changes these parameters θ inside the model fixed during use context tokens for this step: prompt, files, tool results external state files, databases, notes kept by software retrieval brings external state into a later context

Training changes parameters. A request fills the context for one step. Software keeps state outside and can supply it again. Only the first is the model changing.

Anthropic, Context windows (docs, accessed 2026-09-15) · lesson: From Assistant to Agent §7

One tool call: the model asks, software acts

“What is the weather in Bogotá today?” The parameters cannot contain it.

1 · contextthe request, plus a description of a weather tool
2 · model outputa structured request: weather(location="Bogotá")
3 · softwarechecks permissions, runs the tool
4 · tool resultinvented for this example: 18 °C, light rain
5 · next contextthe result is placed in the model's context
6 · model outputthe answer, resting on the result

Anthropic, Tool use with Claude (docs, accessed 2026-09-15) · lesson: From Assistant to Agent §2

Repeat the round trip under control: an agentic system

  1. objective + context + state
  2. model call
  3. tool request, or a response
  4. permission check, execute
  5. observation into context
  6. continue, ask, or stop

Workflow: the steps are written in advance. Agent: the model chooses the steps and tools, within limits. Either way, the same fixed model is called again and again.

Anthropic, Building effective agents (2024) · lesson: From Assistant to Agent §4–§5

A coding agent: inspect, edit, run checks, revise, stop

  1. inspect files
  2. edit
  3. run checks
  4. inspect results
  5. revise
  6. stop

Project instructions and skills are context loaded for the task, not retraining. Permissions live in the software. A passing test establishes only what that test checked.

Anthropic, Claude Code documentation (accessed 2026-09-15) · lesson: From Assistant to Agent §8–§11

The mental model

A learned next-token predictor: code plus parameters, set by pretraining and post-training. Once trained, the parameters are fixed; what is request-specific arrives through context. Software adds tools, state, and a loop.

  • Fluency is not evidence.
  • Tool use is not automatically verification.
  • A passing check proves only what it tested.
  • On judgment-heavy questions, evidence, review, and accountability stay with people.

Where to learn more

A ChatGPT-like product is more than the model

Backup slide, not in the prepared route

the product you type into
system prompt conversation and files retrieval tools the model: code + parameters θ safety checks, interface, product logic

Everything around the model changes what the model is given or what is done with its output. None of it changes the model.

Lesson: Post-training §9 (model versus assistant)