# Try it yourself

> Build a language model at the kitchen table in twenty minutes, with a pen, some paper and something random, and use it to write a sentence nobody has written before.

<SeedTrainingText
  client:load
  text="See Spot run. See Spot jump. Run, Spot, run. Jump, Spot, jump."
/>

# Try it yourself

![](../assets/images/hero-fundamentals.avif)

Twenty minutes, one person, a pen, some paper and something random: a ten-sided
die if you have one, otherwise a coin, or the random-number function on your
phone. By the end you'll have built a <GlossaryTerm id="language-model">language model</GlossaryTerm>, used it to write a
sentence nobody has written before, and seen what <GlossaryTerm id="chatbot">ChatGPT</GlossaryTerm> is doing when it
writes one.

## 1. Pick a text

Pick something short that you know well: a verse of a song, the opening of a
picture book, or a nursery rhyme. Three or four sentences is plenty for a first
go. We'll use this one:

> See Spot run. See Spot jump. Run, Spot, run. Jump, Spot, jump.

## 2. Train it

Write every word in lowercase, and treat each punctuation mark as a word of its
own:

`see` `spot` `run` `.` `see` `spot` `jump` `.` `run` `,` `spot` `,` `run` `.`
`jump` `,` `spot` `,` `jump` `.`

Now draw a <GlossaryTerm id="grid">grid</GlossaryTerm>: one row and one column for each distinct word (here that's
`see`, `spot`, `run`, `jump`, `.` and `,`, so six rows and six columns). Read
through the text one pair of neighbouring words at a time---`see`→`spot`,
`spot`→`run`, `run`→`.`, and so on---and for each pair put a tally mark in the
cell at that row and column. When you reach the end, the grid is your model:
each row says which words followed that word, and how often.

Here it is being built, one pair at a time:

<TrainingWidget client:visible />

That step is training: a real language model does the same thing over trillions
of words, with the tallies stored as numbers instead of pencil marks. (If you'd
rather not draw the grid, there's a [printable one](https://www.llmsunplugged.org/tools/#worksheets), and the
[Training](https://www.llmsunplugged.org/modules/training/) module has the long version with worked
examples.)

## 3. Generate

Pick a starting word and write it down. Look along its row: the tallies are the
candidates for the next word, and the more tallies, the more likely. Choose one
at random _in proportion to the tallies_, write it down, then do the same from
the word you just wrote. Keep going until you hit a full stop, or you've had
enough.

How to choose in proportion:

- **two candidates with equal tallies**: flip a coin
- **a d10**: share the numbers 1--10 among the candidates in proportion (three
  tallies against one becomes 1--7 for the first, 8--10 for the second), roll,
  and read off the winner
- **your phone**: ask it for a random number between 1 and the total number of
  tallies in the row, then count along the row to see which word it lands in

Watch the same thing happen with dice:

<GenerationWidget client:visible />

## 4. Read it out

Read your sentence aloud. It will be half sensible and half nonsense, and it
appears nowhere in the text you started from: the model made it, by looking one
word back at a time and rolling. Now do it again from the same starting word and
get a different sentence.

## What you just did

- the grid is the **model**; its tallies are the **<GlossaryTerm id="parameters">parameters</GlossaryTerm>** (a frontier
  model has about a trillion of them, same idea)
- reading through the text and tallying was **<GlossaryTerm id="training">training</GlossaryTerm>**
- the tallies in a row are a **<GlossaryTerm id="probability-distribution">probability distribution</GlossaryTerm>** over the next word
- the roll was **<GlossaryTerm id="weighted-random-sampling">sampling</GlossaryTerm>**, and the sentence is **<GlossaryTerm id="generation">generation</GlossaryTerm>**

Every reply from Claude or ChatGPT is produced by that loop: look at the
context, weigh the options, pick one, write it down. What's different is the
scale, how far back the model looks, and machinery that can spread what it
learns about one word onto related ones.

<Callout type="tip" title="Now go bigger">

- **a whole book**: grab a
  [pre-trained booklet](https://www.llmsunplugged.org/tools/#booklets-for-dice-generation) (a model of _The
  Cat in the Hat_ or _Frankenstein_ already tallied and typeset as dice
  tables) and generate from that. The
  [Pre-trained Model Generation](https://www.llmsunplugged.org/modules/pretrained-generation/) module walks
  through it.
- **change its voice without changing the model**: the
  [Sampling](https://www.llmsunplugged.org/modules/sampling/) module has a <GlossaryTerm id="temperature">temperature</GlossaryTerm> dial and eight house
  rules, haiku and alliteration among them.
- **do it with other people**: the [lessons](https://www.llmsunplugged.org/lessons/) are the same activities
  with slides, timings and presenter notes, for a classroom, a workshop, or a
  hall full of people holding one sheet each.

</Callout>

Source: <https://www.llmsunplugged.org/try-it/>\
Licence: [CC-BY-SA-4.0](https://creativecommons.org/licenses/by-sa/4.0/)\
Cite as: Swift, B. (2026). _LLMs Unplugged: Understand how AI language models work by building one yourself._ https://doi.org/10.5281/zenodo.17403824
