SOPHIA XT
Course 1 of 5 · Introduction to language models

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.

7 lessons about 16 minutes read it or have it read to you

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.

Figure 0.1 Illustrative
A reply arriving one word at a time, and what each word costYOU HAVE ALREADY WATCHED THIS HAPPENWHAT THAT ONE WORD COSTA CHAT WINDOWany of them, they all do thisyou typedHow tall is the Eiffel Tower?it answeredTheEiffelTowerisabout5 of 9 pieces writtenthe pace is not a style. It is the machine, running once per piece.Messagethe whole text so faryour question, plus every word already writtenone pass of the modelit reads all of it again, from the startone piece comes outand this pass returned "about"pass 5 of 9 for this one replynothing at all is kept between one pass and the nextwhich is why the whole text has to go back in every time
The reply came a word at a time because it was made a word at a time. Each of those words cost one whole reading of everything above it, and that reading is the single operation the seven lessons take apart.
How to read this

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.

Lesson 01

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.

Figure 1.1
One token per pass, then the whole text is read againPASS 1 OF 6THE TEXT SO FARThecapitalofFranceisamber: what you typedmint: what the model has added so farall of it, on every passthe modelone pass over the whole text, one prediction outParisexactly one token comes out, and it is appended to the row above
Watch what goes into the box on each pass. Not the newest word. All of it, from the beginning, every time, because the model has no notes from the previous pass to work from.

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.

Figure 1.2
The whole of it is one wheel, turning once per tokenONE TURN OF THE WHEEL IS ONE TOKENyour textcut intotokensthe model,one passa score forevery tokenone tokendrawnadded tothe textnothing elsehappens in herea paragraph is this wheel turning a few hundred times
Six positions, one marker, and no exit. Every remaining lesson is a closer look at one of these six positions, which is worth holding on to when a later one gets detailed.
What people usually think

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.

Lesson 02

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.

Figure 2.1 Illustrative
How three strings are split into tokensEXAMPLE 1 OF 3The cat sat on the mat.WHAT THE MODEL RECEIVESTheid 1000·catid 1313·satid 1626·onid 1939·theid 2252·matid 2565.id 28787 tokensCommon words arrive whole, with the space in front of them attached.a middle dot stands for the leading space, which is part of the token
Common words arrive whole, rarer ones are assembled out of fragments, and the space in front of a word belongs to it. These are one widely used vocabulary's splits. Another model cuts the same strings differently, so the pattern is the lesson.

This is where a whole family of failures comes from, the ones that look like stupidity and are not.

Figure 2.2 Illustrative
Why counting letters goes wrong, and what fixes itHOW MANY TIMES DOES R APPEAR IN THIS WORDasked straightstrawberrythree tokens, and not one of them is a letterasked to spell it out firststrawberrynow each letter is its own tokenthe model is working around its own input here, not reading
The top half is the question as it actually arrives. The bottom half is why asking a model to spell a word out before counting works, and it stays a strange trick until you have seen this.

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.

Figure 2.3 Illustrative
The same sentence is not the same length to a tokenizerONE SENTENCE, SAME MEANING, FIVE LANGUAGESEnglish12Spanish15German17Russian27Hindi34more tokens is more money, more of the window, and a slower replythe direction is the point; the exact counts depend on the tokenizer
A document in a language the vocabulary was not built around can cost two or three times as many tokens for the same content. Same text, two or three times as much of the room, and two or three times the money.
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.

Lesson 03

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.

Figure 3.1 Computed live
A vector is a row of numbers, and near is a calculationTWENTY SIX CELLS STANDING IN FOR A FEW THOUSANDcatdogbicyclecat against dog: 0.94one is closeness in use, the other is not, and no single cell decides itthe cell values are invented; the similarity between them is really calculated
Nothing in a row like this is readable. What is real is the comparison. Two tokens used in similar ways end up with similar rows, and the closeness is a calculation rather than an impression. A row like this is what people mean by a vector, and a token's own row is what they mean by its embedding.

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.

Figure 3.2 Illustrative
The same token, moved by the sentence around itONE TOKEN, TWO SENTENCESloandeposittellerinterestrivershoremuddycurrentthe token, always herebankI paid it into the bankthe layers pull it toward the company it is keeping in this sentence
The hollow circle is the token's own row and it never moves. The filled point is what the stages above made of it in this sentence. Two dimensions stand in for a few thousand, so read direction and not distance.

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.

Figure 3.3 Illustrative
Which words pull on this one, and how hardREADING LEFT TO RIGHT, PULLING ON THE LAST WORDIpaiditintothebankI paid it into the bankthe heavy line comes from paid, so the last word reads as moneyweights chosen to show the shape; a real model spreads them over every word at once
One heavy line and four thin ones, and changing a single word moves the heavy one. This is the shape of the mechanism course two is about, which is why it gets no name here. A name learned before the thing is learned wrong.
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.

Lesson 04

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.

Figure 4.1 Illustrative
One spike, and tens of thousands of almost nothingEVERY TOKEN GETS A NUMBER, EVERY TIMEParisthe eight bars in the figure above are eight of these, magnifiedwhen the spike is missing, the answer comes out of that flat fieldheights chosen to show the shape; the field stands for far more tokens than are drawn
A spike this sharp is a model that met the answer many times. Take the spike away and the flat field is still there, still adds to one, and something still has to be picked from it.

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.

Figure 4.2 Illustrative
Two prompts, two very different distributionsTHE NEXT TOKEN, AS A DISTRIBUTIONThe capital of France isthe top eight of a vocabulary of tens of thousandsParis92%the2%a1.4%located1.1%home0.9%one0.8%now0.6%still0.5%every other token in the vocabulary is in here too, at a number too small to drawnumbers illustrative, shapes representative
Two prompts, meaning two pieces of text somebody sent, on the same scale. Each is the top of a field like the one above. The reply reads as equally assured either way, because what reaches you is a token and never the list.

And this happens again for every token, not once per answer.

Figure 4.3 Illustrative
The same distribution, five times in a rowTOKEN 1 OF 5TherecipecallsforWHAT THE MODEL OFFERED FOR THIS ONEtwo31%a22%one14%three9%drawn: twothe list is rebuilt from scratch for every single tokennumbers chosen to show how much the shape changes from token to token
Watch the shape change between tokens. Some positions are nearly settled by the grammar and some are wide open, and the same model produces both inside one short sentence.
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.

Lesson 05

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.

Figure 5.1 Computed live
The slider you have seen, wired to the arithmetic under itSAME SCORES, DIFFERENT TEMPERATURESETTINGSthe panel any playground gives you, and most apps hideTemperature0.201.600.20Top P1.00Maximum length256greyed rows are not live in this figureThe weather today isnice97%cold3%warm0%going0%supposed0%perfect0%grim0%glorious0%cold: one option takes nearly all of it, and the model repeats itselfthe eight scores never change; only the division by temperature does
The slider is the one a playground puts in front of you. The eight scores behind it never change; the bars are a real calculation, redone at whatever number is in the box. Watch the bottom four vanish as the slider comes down.

The second dial is usually called top-p, and it does something different enough that confusing the two will cost you an afternoon.

Figure 5.2 Computed live
Top-p throws the tail away before the drawKEEP FROM THE TOP UNTIL THEY ADD UP TO Pp0.30nice42%cold21%warm14%going9%supposed6%perfect4%grim3%glorious1%cutkeeping 1 of 8, 42 percent of the weightthe eight scores are invented; the cut is really calculated from them
Temperature reshapes the whole list. This throws part of it away and draws normally from what is left, which lets a warm temperature stay interesting without reaching into nonsense.

Between them, these two settings account for most of what gets called a model's personality.

Figure 5.3 Illustrative
Four runs of one prompt, two ways of choosingRUN 1 OF 4, SAME PROMPT EACH TIMEalways the top tokenDearMsPatel,thankyouidentical on every run, which is what you want from an extractordrawn from the distributionDearMsPatel,thanksagainamber marks where this run left the greedy path
Same prompt, same model, four runs. If a question with one right answer keeps coming back differently, this is the layer to reach for, and it is far cheaper than rewriting the prompt.
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.

Lesson 06

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.

Figure 6.1 Illustrative
The frame is fixed and the conversation slides through itTHE CONVERSATION MOVES, THE ROOM DOES NOTalready droppedwhat is actually sentnot written yetthe context windownothing is retrieved from the left of that frame, evera memory feature is software copying something back in before it leavesblock widths stand for turns of different lengths
The frame does not move. The conversation does. Most diagrams draw it the other way round and quietly teach that the model reaches back through history, which is the misunderstanding rather than the mechanism.

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.

Figure 6.2 Illustrative
The conversation you can see, and the part still being sentTHE SAME CONVERSATION, AS YOU SEE IT AND AS IT IS SENTA CHAT WINDOWturn 5, and you have scrolled up to the startwhat's a good first bike?depends on the riding you have in mindcommuting, six milesa flat bar hybrid, and here is whybudget is about six hundredthe context window: what is actually sent this turn24 of 26 units of room used, 5 of 5 turns still sentnothing visible changed at the moment the faded ones fell outside the framewhich ones to drop is the application's decision, not the model's
Every turn drawn here is still on the reader's screen, which is what makes this so confusing in practice. Only what is inside the frame is still being sent, and nothing visible changed at the moment the rest fell out.

None of that is the model's decision. You were never the only claimant on the window either.

Figure 6.3 Illustrative
Everything competes for one bar, and the reply losesONE WINDOW, FOUR CLAIMS ON ITinstructions you never saw10%documents you attached22%the conversation so far6%room left for the reply62%plenty of room, and the answers can be as long as they need to beproportions chosen to show the squeeze; every product divides this differently
The instructions a product wrote before you arrived are in there, and so is every document you attached. What gets squeezed as a conversation grows is the reply, which is why long sessions start producing shorter answers.
What people usually think

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.

Lesson 07

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.

Figure 7.1 Illustrative
A fact it holds, and a sentence it assemblesFIVE DRAWS, SHOWING DRAW 1MET MANY TIMES IN TRAININGThe Eiffel Tower was finished in188918871888MarchtheThe Eiffel Tower was finished in 1889reads perfectly, and the year is rightBARELY MET AT ALLThe Brayford Mill was finished in1889184619021871theThe Brayford Mill was finished in 1846reads perfectly, and no fact sits under any of them
Same model, same settings, five draws each. On the left the draw lands on the same token nearly every time. On the right it moves, and every sentence is as well formed as the one beside it. One of these two buildings does not exist.

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.

Figure 7.2 Illustrative
A citation assembled out of four flat listsFOUR FIELDS, AND NOT ONE OF THEM IS REALTHE SURNAME CAME OFF THIS LISTA CHAT WINDOWAny studies on salt spray and roof screws?Yes. Halvorsen and Prieto (2019) tested thisin the Journal of Coastal Materials, 44(3),pages 211 to 229.NO SUCH PAPERthe author, the year, the journal and the pages were each drawnoff a list, exactly the way the word "the" is drawnthe shape of a reference is easy text, and the shape is all this isHalvorsen9%Nakamura8%Ferreira8%Okonkwo7%Lindqvist7%everything else61%flat, and one of them still had to be pickednothing in the code checks that the paper existspercentages chosen to show a flat list, not measured
Every field of that reference came off a list as flat as the one beside it. The reply is grammatical, correctly formatted, and refutable in about thirty seconds by anyone who goes looking.

The obvious next question is whether the model can tell. Partly, and less than you would want.

Figure 7.3 Illustrative
More confident is more often right, and never only rightFORTY ANSWERS, BY HOW SURE THE MODEL WASless suremore surerightwrong0.40keep only what is above the line and you hold 22 right answersand still let 8 wrong ones through, having thrown away 3 good onespoints drawn to show the shape of a real and widely reported relationship, not an experiment
The relationship is real, which is why the probability is worth reading if you can get at it. No vertical line on this chart separates the two colours, which is why it is not a solution.

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.

Figure 7.4 Illustrative
The same question, with and without the page attachedWHEN DOES THE WARRANTY ON A MODEL 400 ENDASKED COLD2 years1 year5 years90 days"The Model 400 carries a two year warranty."fluent, specific, and assembled from nothingASKED WITH THE PAGE IN THE REQUEST"...cover on the Model 400 runs for thirty six months fromthe date of installation, excluding the compressor..."36 months2 years3 years1 year"Thirty six months from installation, minus the compressor."same machinery, and now there is a sentence you can go and check
Nothing about the model changed between these two. The distribution went from flat to peaked because the answer was in the request, and the second reply can be checked against a sentence you can go and read. That is course five.
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.

End of course

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.

  1. 01What comes out of the model on a single pass?
  2. 02Why do models struggle to count the letters in a word?
  3. 03A token's embedding vector is best described as:
  4. 04Turning temperature down changes:
  5. 05A model keeps giving different answers to a question with one right answer. What is worth reaching for first?
  6. 06Between two separate conversations, a plain model:
  7. 07A long conversation stops fitting in the context window. Who decides what gets dropped?
  8. 08The model gives its chosen token a high probability. That tells you:
  9. 09Two answers, one about a famous building and one about an obscure one, both read fluently. Why?
  10. 10The most reliable way to get an answer you can check is:
0 of 10 answered
Next in this track

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.