Pytte
A tiny language model that writes Swedish children's stories. I trained it from scratch on my laptop, to understand how a language model actually works.
Everything below runs in your browser. Nothing is sent anywhere.
The same opening, the same random seed, six models. Drag the slider and watch language take shape: from loose sentences at 0.3 million parameters to a story at 7. Pytte writes in Swedish. The default opening means “Alma lives in a small cottage in the forest. One day”.
Ask for a story in Swedish: Berätta en saga om Freja och en katt som utspelar sig på en bondgård (Tell a story about Freja and a cat, set on a farm). Then ask: Vad händer sedan? (What happens next?) Pytte can do one thing, stories for small children. The stories are about a child, and Pytte follows the name and the place you give more often than the object.
The model does not see letters but tokens: pieces of words it learned from the stories. Type something in Swedish and see how it is split, and which tokens the model expects next.
Tokens
Next token
The model files are 0.4–16 MB and load only when you pick them.
See what happens inside
Type a sentence and follow it through the model: how it is split into pieces, which words look at each other, how the answer takes shape layer by layer, and how chance picks the next word. Everything is computed in your browser, with the model's own numbers.
Open Inside Pytte

How Pytte works
Pytte does one thing: it guesses the next piece of text. The picture shows the way from what you type to that guess. Click a part to see what it does and how big it is.
Why I did this
I wanted to understand every part of a language model: how text becomes tokens, what attention does, what a layer is, and why the model can end up writing a sentence. The only way I know to really understand something is to build it.
So I built one. No existing models, no paid services, no budget at all. The same kind of architecture as the large models, only thousands of times smaller, trained on my MacBook in between five minutes and half an hour.
Everything was documented while it was built: every run, every measurement and every mistake is in a log. That way I keep learning the whole time, and the lessons are what I want to share.
Pytte in numbers
- 6
- models, from 0.3 to 15.7 million parameters
- 120,000
- Swedish children's stories as training data, generated locally
- 5–30 min
- training time per model on a MacBook Pro
- 0.4–16 MB
- per model, in a single file
- 0 kr
- budget. Only electricity.
What I learned
- 01
It takes surprisingly little
A model with a third of a million parameters writes grammatical Swedish sentences. At about one million it writes short, coherent stories. That model is 1.4 MB and trains in eight minutes.
- 02
The data decides more than the model
My first models could not form plurals, whatever their size. The stories were about one child and one ball, so they had hardly seen a plural. When 40 percent of the new stories were written with several things in the plural, every model got it right, even the smallest. A model can do what its data shows.
- 03
A model can learn a template instead of a language
The first version of the data was too uniform: every sixth story opened with the same sentence. The models looked excellent in my measurements but fell apart on freer text. I only found out when I made a second, more varied batch of stories.
- 04
Variety costs coherence
The new, more varied stories gave better grammar, but when several children appeared the models started mixing up who was who. A mix in which the new stories have a single child kept most of both.
- 05
Numbers lie unless you count twice
Every error I found was found because two numbers did not agree: a metric divided by the wrong count, a clock that kept running while the laptop slept, junk characters in twelve percent of the training data. The errors and the fixes are in the report.
What I do not know
This is a hobby project, not research. I want to be clear about where the limits are.
- I do not know how good Pytte is compared with other people's small models. I have only measured against my own.
- No person has rated the stories systematically. The grades come from another AI model, which is also a relative of the one that wrote the training data.
- Almost everything was trained once. Small differences between the models may be chance.
- Pytte knows only children's stories with a few thousand words. It knows nothing about the world and cannot be used for anything practical.
- Nobody outside the project has reviewed the code, the data or the conclusions. If you find a mistake, I would like to know.
- The code and the report were written together with an AI assistant, Claude Code. I decided what to do, read the stories and approved each step. The report says who did what.
Download
The report
19 pages in English with a Swedish summary: data, models, measurements, twenty findings, limitations and mistakes.
The models
Each file contains the model and its vocabulary and is all you need to run it. The chat versions take a request; the base versions continue a text.
| Model | Parameters | Size | Base | Chat |
|---|---|---|---|---|
| pytte-0.3m | 0.33 million | 0.38 MB | Download | Download |
| pytte-1m | 1.33 million | 1.44 MB | Download | Download |
| pytte-2m | 2.24 million | 2.37 MB | Download | Download |
| pytte-3m | 3.44 million | 3.59 MB | Download | Download |
| pytte-7m | 7.16 million | 7.33 MB | Download | Download |
| pytte-15m | 15.74 million | 15.97 MB | Download | Download |
Run it on your own computer
One C program with no dependencies. Works on Mac and Linux.
cc -O3 -o run run.c -lm
./run pytte-7m-chat.bin -chatrun.c The code and the log
All the code, the recipe for the training data, the measurements and the log of the whole project are on GitHub.
Go to GitHubThe training data
SagoSvenska: 120,000 Swedish children's stories, each with the recipe that produced it. Free to use with attribution (CC BY 4.0).
Download (zip, 49 MB)Code and models: Apache-2.0. Data: CC BY 4.0.