Chapter A1
What an AI language model is
A language model writes by guessing the next small piece of text, over and over. That one skill explains why answers vary and why a fluent answer can still be wrong.
- Describe a token and say why a token is not always a whole word.
- Explain how a language model writes an answer one small piece at a time.
- Describe the two training stages and what each one gives the model.
- Explain why the same question can get different answers on different runs.
- Explain why a model sometimes states things that are wrong, and describe what its knowledge reaches up to.
Watch
Transcript
- 0:00
In this chapter you meet the large language model, a program trained on a huge amount of text whose one core skill is guessing the next small piece of text, called a token.
- 0:10
A token is not a word and not a letter. A short word may be one token, a rare word several, and the same text can count differently on different models.
- 0:20
It writes an answer one token at a time, feeding each new token back in, and because the choice among likely tokens involves some chance, the same question can get different answers.
- 0:32
Training came in two stages. In the first, the model practised guessing the next token over a very large amount of text. In the second, people wrote examples of good answers and ranked model answers, and the model was adjusted to match.
- 0:47
It only knows what was in its training up to a cutoff date. Anything later is not in its knowledge unless the application supplies it.
- 0:55
It can state wrong things with confidence. Researchers argue this happens partly because training and testing reward guessing over admitting uncertainty.
- 1:05
You will learn how a model builds an answer, why answers vary, and why a fluent answer can still be wrong.
- 1:12
To use this chapter, watch the video, read the lesson, and try the lab where you press a button and watch a made up table of chances produce different answers.
Computer-generated voice
The narrator is a computer-generated voice, made with a text-to-speech model called Kokoro. It is not a recorded person. The captions and the transcript show every word it says.
What a language model is
A large language model is a computer program trained on a very large amount of text. Its core skill is guessing what small piece of text comes next. A chat assistant is built on top of this kind of model, and the training that makes it follow instructions comes in the second stage below.
Tokens: the pieces of text
A token is a piece of text that the model reads and writes.2 It can be a whole word, part of a word, or punctuation.
A short common word is often one token. A rare or long word can be split into several tokens, and punctuation counts too.
Byte pair encoding is one subword method for this: the model gets a fixed set of pieces, and rare or unknown words are encoded as sequences of those pieces.3
The README for OpenAI's tiktoken tokeniser says its byte pair encoding gives about 4 bytes of text per token on average in practice.2 A byte is a unit of computer storage; one letter usually takes one byte.
Tokenisers: making the pieces
A tokeniser is the separate program that turns text into tokens before the model sees it.
Different companies use different tokenisers, so the same sentence can come out as a different number of tokens on different models.
Anthropic documents that its Claude 4.7 and later models use a newer tokeniser, and that the same input text produces approximately 30 percent more tokens than on its earlier models, as of 2026-10-18.4
One token at a time
Next-token prediction means producing chances for what the next token should be. The original Transformer paper describes a learned linear transformation and a softmax that turn the model's output into predicted next-token probabilities (a probability is a number from 0 to 1 for how likely an option is).1
- The model gives a chance to each option for the next token.
- One token is chosen and added to the text.
- The model runs again on the longer text, and the steps repeat.
The model's own output is fed back in as input. That is what autoregressive means: at each step, the previously generated tokens become additional input for generating the next one.1 The answer is built token by token, not written out in one finished block.
Phone autocomplete is a useful analogy, up to a point. It also predicts what comes next, but it suggests a word and waits for you. A language model keeps going by itself, feeding each new token back in until a whole answer exists.
Training stage one: pretraining
Pretraining is the first stage. The model reads a huge amount of text and practises next-token prediction over and over, adjusting its parameters, the internal numbers that shape its output.
The GPT-3 paper describes an autoregressive language model with 175 billion parameters, pretrained on a large corpus of text.5 A corpus is a collected body of text.
After pretraining, the model's basic behaviour is to continue text. Instruction following is what the second stage works on.
Training stage two: post-training
Post-training changes how the pretrained model responds. In the InstructGPT work, people first wrote demonstrations of good answers and the model was trained on them. Then people ranked several model outputs from better to worse, and the model was further trained using those rankings.6
Human evaluators preferred outputs from the 1.3 billion parameter InstructGPT model to outputs from the 175 billion parameter GPT-3 model.6 The paper also states that making models bigger does not inherently make them better at following user intent.
Sampling: temperature and top p
Real systems choose the next token with some chance in the mix; that is called sampling. Always taking the highest scorer is one option.
Temperature is a dial for that chance. Anthropic's API documents it as the amount of randomness injected into the response, with a default of 1.0 and a range from 0.0 to 1.0.7 In plain terms, a low setting makes the top scorer win nearly every time, while a higher setting lets less likely tokens through more often.
Top p is a different dial. It sorts the options from most to least likely and keeps only the smallest leading group whose chances add up to the amount you chose. Options outside that group are ignored.7
As of 2026-10-18, Anthropic marks both settings as deprecated: models released after Claude Opus 4.6 do not support setting them, and a request that sets other values returns an error.7 The dials still show how sampling works.
The paper that introduced this nucleus sampling says it truncates the unreliable tail of the distribution.8
Research on nucleus sampling found that the decoding strategy alone can dramatically affect the quality of text from exactly the same model.8
You can try both dials in the lab: guess the next token. The lab uses an invented table of chances, not any real model's numbers.
Why the same question gets different answers
Chance is part of each choice, and a different token early in the answer changes the text the model sees next, so the rest can change too. The same question can therefore get different answers on different runs.
Turning the temperature down reduces that variation, but it is not a promise of identical output. Anthropic notes that even at 0.0 the results will not be fully deterministic (the same input is not guaranteed to give the same result every time).7
The training cutoff
The training cutoff is the date after which the model saw no more training data, so events after that date are not in its training knowledge. The gap grows over time.
Anthropic lists Claude Sonnet 5.5 with a training data cutoff of June 2026, as of 2026-10-18.9 On that date, the cutoff was about four months behind.
Information newer than the cutoff has to be supplied by the application, for example by a search tool putting its results into the request.
Hallucination: fluent and false
A hallucination is a confident, fluent statement that is false. It can sound natural and still be untrue.
Kalai and colleagues argue that language models hallucinate partly because training and evaluation reward guessing over acknowledging uncertainty.10
Treat an answer as a draft to check, not as the final word.
Two common misconceptions
A token is a word
No. A token can be a whole word, part of a word, or punctuation, and the pieces depend on the tokeniser. The same text can therefore have different token counts on different models.34
A chat is one continuous session
No. A chat is a series of requests. The app resends earlier messages on each request, so the model sees the conversation as text each time.7
Check your understanding
1. Is a token always a whole word?
No. It can be a whole word, part of a word, or punctuation. A rare or long word can be split into several tokens.
2. What does autoregressive mean?
The model's own output is fed back in as input. Each newly generated token becomes part of the text used to generate the next one.
3. Why can the same question get different answers?
Sampling includes chance in the choice of each token, and an early difference changes the text used for the next choice. Even at temperature 0.0, Anthropic says results are not fully deterministic.
4. Can the model know about an event after its training cutoff?
Not from its training. Information about a later event must be supplied by the application, for example in the request.
Try it yourself
Open Lab: guess the next token. Change the temperature and top p settings, generate the same answer several times, and watch which token pieces appear.
Terms used in this lesson
- Token
- A piece of text that the model reads and writes: a whole word, part of a word, or punctuation.
- Tokeniser
- The separate program that turns text into tokens before the model sees it.
- Next-token prediction
- Producing chances for which token should come next.
- Autoregressive
- Feeding previously generated tokens back in as input when generating the next token.
- Pretraining
- The first training stage: the model practises next-token prediction over a large amount of text.
- Post-training
- The second training stage, which shapes how the pretrained model responds.
- Temperature
- A dial for the amount of randomness used when choosing the next token.
- Top p
- A dial that keeps only the smallest leading group of token options whose chances add up to the chosen amount.
- Training cutoff
- The date after which the model saw no more training data.
- Hallucination
- A confident, fluent statement that is false.
Sources
- Attention Is All You Need
- OpenAI tiktoken README
- Neural Machine Translation of Rare Words with Subword Units
- Anthropic: token counting
- Language Models are Few-Shot Learners
- Training language models to follow instructions with human feedback
- Anthropic: Messages API
- The Curious Case of Neural Text Degeneration
- Anthropic: models overview
- Why Language Models Hallucinate