How a model turns your words into an answer
By the end of this you will know what a language model receives, what it hands back, and why that one shape explains nearly everything people find strange about these systems.
A language model is a piece of software that was shown an enormous amount of writing and can now carry on any text you hand it. You have used one. This starts from what you saw.
Twenty-two figures carry most of the argument, and each says on its face whether its numbers were chosen or calculated live. No mathematics is needed, and the folds marked Deeper are optional.
A model only ever answers one question
Everything a language model does is a single operation, run over and over.
Think back to the last time you used one of these. You typed a question and the answer came back a word at a time. That was not a style choice. It is the machine, running once per piece.
Each run, called a pass, does one thing. The model reads everything in front of it and guesses what comes next. Not a sentence and not an answer. One piece of text, shorter than a word usually, and the name for that piece is a token.
The guess is stuck on the end and the whole thing goes back in. The text is one token longer now, so the next guess differs. A few hundred of those in a row is the reply you watched arrive.
Drawn as a line it looks like a sequence. It is closer to a wheel, and the wheel is why one model can write code, summarise a contract and translate Portuguese without three systems being built. Same turn, different text in.
The model works out its answer, then writes it down.
There is no plan sitting anywhere. When a model writes the word "three" in "there are three reasons", nothing in it has committed to what those reasons will be. They get worked out on later passes, from the text, because the text is all there is.
That cuts both ways, usefully. Asking a model to work through something on the page changes its answers rather than just their length, because the working becomes text and the text is read on the next pass. Writing is the only scratchpad it has.
Deeper: the models that think before they answer
Some models now produce a long stretch of working before showing you anything. That is not a different mechanism. The working is tokens from the same loop, and the product does not display them. The scratchpad is still text you were not shown.
There is real machinery that stops the model recomputing the whole sequence on every pass, usually called a key value cache. It is an optimisation over the same arithmetic, and it gives the model no plan that survives outside the text.
A language model predicts one token at a time, and every prediction is made by reading the whole text again from the start.
Text arrives in pieces, and the pieces are not words
Before anything else happens, your sentence is cut up and turned into numbers.
A model cannot receive letters. Your sentence has to become numbers first, and the step that does it is called tokenisation. It cuts the text into pieces somewhere between a letter and a word. Every piece comes from one fixed list, called the vocabulary, drawn up before training, the one-off process that built the model, and unchanged since.
This is where a whole family of failures comes from, the ones that look like stupidity and are not.
The other consequence is money. Tokens are the unit everything is priced in, and the same meaning does not cost everybody the same number of them.
Deeper: why a fixed vocabulary, and why it cannot be changed later
Byte pair encoding starts from single bytes and repeatedly merges the most frequent adjacent pair until the list reaches its target size. Frequency buys brevity, and that is the whole of the cost difference above. The merges were learned from a corpus, so text resembling that corpus compresses better.
It is also why the vocabulary cannot be swapped after training. Every entry is bound to a row of learned weights, so changing the list means training the model again.
The model receives numbered pieces of text, never letters, and which pieces exist was decided before training began.
Each piece starts as a point, and the sentence moves it
Where meaning actually lives, and where it does not.
Every entry in the vocabulary owns a list of numbers learned during training. A few thousand of them, in most models, and not one of them means anything on its own.
But the row for "bank" is one row. It is identical whether you mean a river or a mortgage, because it was fixed long before your sentence existed. What your sentence changes is what gets built on top of that row, stage by stage, as the text passes up through the model's layers.
What does the pulling is the rest of the sentence, and not evenly. Most words barely matter and one or two decide the whole reading.
Deeper: cosine similarity, and the arithmetic people quote
The closeness in figure 3.1 is cosine similarity, the angle between two rows rather than the gap between them, which is why a rare word and a common one can still come out close.
The famous trick where king minus man plus woman lands near queen came out of older word vector work and holds only loosely, on chosen examples. Take it as a sign that the space has structure, not an operation to build on.
A token's starting vector is fixed. Its meaning in your sentence is built above it, out of the tokens around it.
The output is a whole distribution, not a word
The most useful thing about a model's answer is something you are never shown.
When a pass finishes, what comes out is not a word. It is a score for every single entry in the vocabulary, all of them, every time, squeezed into probabilities that add up to one. A list of probabilities like that is what distribution means.
You will rarely see it drawn that way. Eight bars is the usual picture, and now you can see what it leaves out. The flat part decides the answer when there is no obvious one.
And this happens again for every token, not once per answer.
Deeper: logits, softmax, and what a probability is not
The raw scores are called logits and they are unbounded, positive or negative. Softmax exponentiates each one and divides by the total, turning any set of scores into a distribution that sums to one while keeping their order.
A high probability means the model found that continuation likely given its training. It is not a claim that the statement is true. Most APIs return these numbers if you ask, and for classification work reading each label's probability beats parsing a sentence the model wrote about it.
Every pass produces a probability for every token the model knows. A peaked distribution and a flat one are indistinguishable in the reply you actually read.
Choosing from the list is a separate decision, and it is yours
The setting that most people never touch and most often need.
The model produces the distribution. Something else picks one token out of it, and that something else is not the model. It is a short piece of code with settings on it, and the settings are usually yours.
Take the highest number every time and the same prompt returns the same answer forever. Draw at random instead, weighted by the probabilities, and you get variety. Temperature is the dial deciding how closely that draw follows the numbers.
The second dial is usually called top-p, and it does something different enough that confusing the two will cost you an afternoon.
Between them, these two settings account for most of what gets called a model's personality.
Deeper: why identical settings can still give different answers
Temperature zero is not a guarantee of identical output in practice. Floating point addition is not associative, so the way a server batches your request alongside other people's can shift the last digits of a score, and two nearly tied options can swap places.
Models that route each token to a subset of their own components are sensitive to what else is in the batch for the same reason. If you need reproducibility you need it stated by the provider, not inferred from a setting.
The model hands you a distribution. Temperature and top-p decide how that becomes a word, and they are settings rather than personality.
It only knows what is in front of it
There is no memory. There is a window, and it is re-sent in full every turn.
A model has no memory of you between requests. None at all. A conversation that appears to remember what you said ten minutes ago works by sending all of it again, invisibly, as part of the text.
The frame has a size. It is called the context window and it is measured in tokens. When a conversation outgrows it something has to go, and different products choose very differently.
None of that is the model's decision. You were never the only claimant on the window either.
It remembers our earlier conversations.
Unless a product has built a memory feature, which stores things and pastes them back into later conversations for you, a new chat starts with a model that has never encountered you.
Talking to it does not change its weights, the numbers fixed during training that are the model. Nothing you say is learned during your conversation, whatever else a provider may do with the transcript.
Deeper: why a long window is not free
In the standard arrangement every token is compared against every other token, so that part of the work grows with the square of the length. Doubling the text roughly quadruples it. Engineering has softened this, but the shape of the cost is why a long window is an achievement rather than a number somebody chose.
Recall across a long window is also uneven. Published work has repeatedly found that material at the very start and the very end is used more reliably than material buried in the middle, so filling a window is not the same as being understood.
There is no memory. There is a window, it is re-sent in full every turn, and what falls out of it is your application's decision.
Why it invents things, stated precisely
The behaviour people complain about most is the behaviour the first six lessons predict.
The model produces a distribution and something draws from it. For a fact it met thousands of times, the distribution is a spike and the draw lands on the right token. For a fact it met twice, or never, the distribution is flat across a handful of plausible options. The draw lands on one of them anyway, because nothing in the code checks whether it knows.
You have most likely met this as a citation. The shape of a reference is easy text, and nothing checks that the paper is real.
The obvious next question is whether the model can tell. Partly, and less than you would want.
So the dependable fix is not a better instruction, because an instruction cannot create knowledge that was never there. It is putting the material into the request.
Deeper: what confidence is actually worth
The probability on the chosen token carries real information. Low probability answers are wrong more often, so a system that reads those numbers can act on them. Published work also shows that a model's internal activations separate true from false better than its own stated confidence does.
But a model asked how sure it is produces that reply the same way it produces everything else, by predicting likely text. Training on human feedback rewards answers that sound confident. Its stated confidence is worth much less than its measured confidence, and neither is a guarantee.
A confident sentence about something the model never learned looks exactly like a confident sentence about something it did. The difference lives in a distribution you were never shown.
Test yourself
10 questions, and 70 percent passes. The score stays in this browser and goes nowhere else, so there is no account to make and nothing at stake in getting one wrong.
Attention, and how a model decides what matters
Course one treated the model as a box that turns text into a distribution. This one opens the box. What a layer does, why every token gets to look at every other token, and how a pronoun four hundred words later still lands on the right name. It is also where the costs come from, so it explains why context windows are expensive rather than just large.
In production. The track page has the full plan.