1. From chances to a choice
After reading a prompt, the model produces one raw score per token in its vocabulary, called a logit. A softmax (chapter 3) turns the scores into probabilities. To write text you pick one token, add it to the prompt, and ask again. There are two obvious ways to pick:
- Always take the favourite (greedy). Predictable, but it tends to get stuck repeating itself.
- Roll a weighted die (sampling). A token with a 30% chance comes up about 30% of the time. Varied, but now and then it picks something silly.
The dial between those two is the temperature. Before the softmax, divide every score by the temperature T:
probability ∝ escore / T
A small T exaggerates the gaps between scores, so the favourite takes nearly everything (as T goes to 0 you get greedy). A large T shrinks the gaps, so the chances even out (as T grows you approach pure noise). T = 1 leaves the model's own probabilities untouched. A second dial, top-k, throws away everything except the k best tokens before rolling the die, which cuts off the long tail of silly options.
5. What to take from this, and what not to
Training and sampling are separate. Temperature changes nothing inside the model; the same trained numbers can be used cautiously or wildly. You can try different settings for free, after training.
Low temperature is not "more correct". It makes the model more predictable, and a confident wrong answer is just as predictable as a right one. It also makes loops more likely.
This model is tiny. It has about 60,000 numbers and read a few megabytes of children's stories, so even its best text wanders. Big models are built the same way, trained on vastly more text; sampling works identically on them.
That is the whole pipeline of a language model: text to tokens (1), tokens to vectors (2), vectors mixing through attention (3), a loss and small steps that tune it (4), and sampling to turn its chances back into text (5). The main app builds on all five, then adds fine-tuning and preference tuning to steer behaviour.
6. Using it for your own purpose
Everything above ran on a children's-story sample, but nothing about the model is specific to it. You can point the same machinery at your own material, in two ways.
1. Train it on your own text. In the main app, choose My own text file under
Set up, pick a size and press Train. The model learns the vocabulary and style of that file: recipes, song lyrics,
product descriptions, a diary. From a terminal the same thing is
tlm train --data mytext.txt --out runs/mine. Then use Continue some text (chapter 5's sampling
under the hood) or tlm generate.
2. Teach it a task with your own examples. Under Teach it a task, choose My own examples and
give it a .jsonl file: one example per line, each with a prompt and the
response you want. The page has a sample file to start from. Fine-tuning then uses exactly the loop from
chapter 4, but measures the loss only on your responses. A tenth of your examples is held back and never trained on, so
the page can show you your answer next to the model's.
The same two steps work from the command line: tlm sft --data examples.jsonl.
What to expect
- Style yes, accuracy no. A model with tens of thousands of numbers and a 64-token window can pick up the look of your text and a fixed answer format. It cannot be relied on for facts or long reasoning.
- Watch the held-out loss. With only a few dozen examples the model memorises them within a hundred steps: training loss falls toward zero while held-out loss rises. In a test with about 100 plural examples ("Plural of lamp:" gives "lamps"), the small model learned the answer shape and some words but still got unseen words wrong. A few hundred examples of one narrow task, and fewer steps, give it a better chance of learning the pattern.
- Your own examples are not machine-checked. Preference tuning (DPO) needs a rule that says which answers are good, so the app offers it only for the built-in word task. For your own examples you judge the results by reading them.
- It stays on your computer. The text, the training and the model all live in your browser tab or your own machine. You can download the model files and open them again later.
That is the point of a tiny model: it is small enough that you can see, and change, every step of how it learns.