how llms work

watch a language model learn to write

A real one, training in this tab, from random numbers to words.

how it works
step 0 how wrong 4.17 state ready

its writing, untrained

…

a recorded run, after 6,000 steps

The Log deather and a ungraing him the seizes. A feart her for and in when own his you had chins treies, the Lion et and him had…

one token at a time

Every token it writes is one full trip through the model.

1Thedogdroppedtheballbecauseitwas2“was” as 2,304 numbers (26 shown)3layers 1 to 6words and grammarlayers 7 to 18meaning and reasoninglayers 19 to 24back toward a token×3passeslooks back over all the textlooks back 1,024 tokens4tired46%hungry11%flat7%too6%and about 200,000 more, most near 0%5…becauseitwastiredadd it, then go again
sizes from inkling-2-mini, an open model
  1. split into tokens

    The text is cut into tokens: whole words or pieces of words. The newest one, “was”, makes this trip.

  2. turn it into numbers

    Each token becomes a list of 2,304 numbers. At first they only say which token it is.

  3. run the layers

    Each of 24 layers adds a little to those numbers. Layers 7 to 18 run three times, so a token gets 48 layer steps.

  4. score every next token

    The final numbers become a score for each of about 200,000 tokens, turned into chances that add up to 100%.

  5. pick one and go again

    It picks one, usually from the top few, adds it to the text, and the whole trip starts over.

every layer does two jobs

First it looks around, then it applies what it knows.

Thedogdroppedtheballbecauseit3%58%6%2%22%5%4%

Each token pulls in what it needs from the tokens before it. Here “it” draws most on “dog”.

That’s how the model keeps track of what “it” means. The shares are an example.

“it” inchooser128 specialists8 runresults blended in“it” out

Each layer holds 128 small specialist networks. A chooser picks the 8 that fit this token.

So Inkling-2-Mini holds 26 billion numbers but uses about 3.4 billion per token.

it learns by guessing

A new model is random numbers. Training repeats one loop over trillions of tokens.

1real textbecauseitwastiredit must guess “tired”2guesslayersits chancesthe9%a6%flat3%tired1%3comparereal tokentiredit gave “tired” 1%rightwrong4work back through the layers5nudge every number0.4127→0.4131−1.0338→−1.03350.0815→0.0809all of them, a tiny bit eachnext piece of text
1real textThedogdroppedtheballbecauseitwastired.2guessthe9%a6%flat3%tired1%3comparereal tokentiredit gave “tired” 1%rightwrong4work backthrough the layers5nudge every number0.4127→0.4131−1.0338→−1.03350.0815→0.0809next piece of text

from reader to assistant

Two more rounds teach it to answer.

Asked: What’s the capital of France?

  1. reading

    It continues the page.

    It replies: What’s the capital of Spain? What’s the capital of…

  2. example conversations

    It learns to answer.

    It replies: Paris.

  3. practice with rewards

    It learns to reason first.

    It replies: thinking it through… Paris.

train one yourself

The same loop, on Aesop’s fables.

Training text

step
0
letters read
0
how wrong
4.17

its writing as it learns

    next letter after and th

      this one next to a real one

      The same design and the same loop. The difference is size.

      28,576

      numbers in the model in this tab

      26 billion

      numbers in Inkling-2-Mini

      Measurethis tabinkling-2-mini
      layers224, the middle 12 run three times
      tokens it knows65 letters and marksabout 200,000 word pieces
      text read0 letters so fartens of trillions of tokens
      trained onthis browser tabhundreds to thousands of data-center GPUs

      Text read and hardware are typical for a model its size.