A model’s behavior comes from how it was made. Its makers decided what text it was trained on, which vocabulary it has, how it learns and for how long. Those decisions are design decisions, and this page puts four of them in your hands.
A high-level walk through the basic three-step pipeline. This is enough to understand where a model’s behavior comes from, not enough to build a model.
What is a language model?
A language model is a program that continues text, and text means any sequence of symbols that can be typed, not only prose: a story, a program, a CAD drawing saved as DXF, the Gerber files that describe a circuit board. Given any text, it predicts the next token, a small piece of text, adds it, and predicts again, so it produces text by prediction. What a model can continue is what it was trained on: trained on stories it continues stories, trained on code it continues code, trained on both it does both. It learns to predict from a large amount of text: a batch of the text passes through, the model guesses what comes next, the guess is compared with what did, and its parameters, the millions of numbers inside it, are adjusted a little towards the right answer, over and over.
The models on this page are small ones, trained on stories only: GPT-style transformers of parameters, each trained for minutes on one laptop with an NVIDIA graphics card. Meta’s largest Llama 3 model has 405 billion parameters and trained for about two months on 16,000 GPUs.
How a language model gets made, and where each step is on this page
Choose the text it learns from.
Set its vocabulary: the tokens it takes in and produces.
Write the training script that builds the network and trains it.
Train it for a fixed time, and score it on text kept out of training.
Fine-tune it on prompts paired with good responses, so it answers.
Align it on feedback about which responses are preferred.
Look further: reasoning models, other kinds of model, and what the largest take to train.
Use it: give it some text and read what it produces.
Change one thing and train again. An AI agent does this for hours, keeping what scores better.
An LLM gets built in 3 steps
Pretraining. Pass a massive amount of raw text through a giant neural network. The model learns to predict what token comes next given a prior sequence. This is where it picks up grammar, syntax, semantics, and some world knowledge. The result is a foundational model: a base with broad capabilities that can be adapted to more specific purposes. , on small models of our own.
Supervised fine-tuning. Train on structured supervised prompt-and-response example data. The result is an instruction-tuned model.
Alignment. Further train the model to produce responses that better reflect desired behaviors, such as helpfulness, accuracy, and safety. The result is an aligned model.
What does the dataset change?
Step 1: Pretraining. Pass a massive amount of raw text through a giant neural network. The model learns to predict what token comes next given a prior sequence. This is where it picks up grammar, syntax, semantics, and some world knowledge. The result is a foundational model — a base with broad capabilities that can be adapted to more specific purposes.
A dataset is the text a model learns from, and a model can only produce text like the text it was trained on. For a large model it is mostly a filtered copy of the web. A common start is Common Crawl, a free archive of more than 300 billion web pages, which teams filter and clean into training sets such as FineWeb and RedPajama, each more than ten trillion tokens, with books and code added. GPT-3 (2020), for example, was trained on a mix that was about 80% web pages, the rest books and Wikipedia. Newer models say less about their sources. Meta’s Llama 3 (2024) describes its 15 trillion tokens by kind, about half general knowledge, a quarter maths and reasoning, 17% code and 8% other languages, not by where they came from; Llama 4 (2025) adds licensed data and public posts from Facebook and Instagram; Microsoft’s Phi-4 (2024) is trained in part on text written by other models. Ai2’s OLMo 2 (2024) is the exception that publishes its training data in full. The dataset also decides what kind of text a model can continue at all: trained on code, chess games, folk tunes in notation or vector drawings, a small model continues those.
For this page we chose two small ones, different in kind, size and source, and trained two models the same way, one on each, for . Each continues the same four openings in the style of the stories it learned from.
These two scores can't be compared. Each measures how well a model predicts text from its own dataset that was kept out of training, and the datasets are different. Compare how the models continue instead.
The same four openings, continued by each model
What a model produces comes from what it was trained on. Look for the subject, the names, the length of the sentences and the words each model reaches for.
What does the vocabulary change?
A model takes in and produces text as tokens: whole words and pieces of words from a fixed list called its vocabulary. The vocabulary is set before training starts, either built from the dataset itself or borrowed from another model, and it never changes. It decides how text is cut into tokens and how big the model is.
Dataset
One sentence, three vocabularies
A space travels with the word after it (␣). A dotted token holds only part of a letter: the vocabulary built from the dataset works in bytes, so a letter like é can be split, and the next token completes it. The first four sentences are the openings every model was given.
How well each fits the dataset
Measured on the dataset chosen in the rail.
The dataset is tokenized
One document from RedPajama, cut by cl100k_base, the vocabulary of OpenAI’s GPT-4 and GPT-3.5: 100,256 tokens. Each token is a number, its ID, and the IDs are what the model actually consumes during pretraining.
The text
Artificial intelligence (AI) is transforming the world. From healthcare to education, AI systems are enabling new capabilities and improving outcomes at scale.
159 characters, 28 tokens, 27 of them different: 5.7 characters a token. “Artificial” is two tokens, “Art” and “ificial”; “AI” is one; a space (␣) travels with the word after it. Worked out here from the vocabulary’s own file; see every one of its tokens on Token + TokenID Pairs.
Tokenizing a whole dataset
What
Roughly
Dataset size (raw text)
~5–10 TB (uncompressed)
Documents
100+ billion
Total tokens (target)
~1 trillion
Average characters per token
~3–5
Average tokens per document
~500–2,000
Tokenizer vocabulary size
100,256 (cl100k_base)
Tokenization throughput
per CPU node: ~100k–300k tokens/sec 32-node cluster: ~3M–10M tokens/sec
Total tokenization time
single machine: weeks modest cluster (32 nodes): ~1–3 days
~10+ million books ~multiple passes over filtered public internet
What does the training script decide?
Vocabulary, in the diagrams
Dataset, in the size table
The model, drawn as
Every model is built and trained by an algorithm. It sets the model's shape, which decides how many parameters the model has (its weights: the numbers training adjusts), and how those parameters learn from the dataset. Ours is a single program, the training script. All six models use the same one, the starter kit’s, which every session begins from: the starter script. An agent found these attention changes on 12 October, training on Folktales, and they have been in the starter script since.
A kind of neural net is built from the dataset using a transformer
The paper Attention Is All You Need (2017) introduced the Transformer, a type of neural network that forms the foundation of modern language models, the small ones on this page included. The illustration shows, in simple terms, how different parts of this network focus on relationships between words in a sentence, allowing the model to understand and generate language.
Figure 5: Many of the attention heads exhibit behavior that appears related to the structure of the sentence. Two examples are shown, taken from different heads in the encoder self-attention at layer 5 of 6. The heads clearly learn to perform different tasks. Source: Vaswani et al., Attention Is All You Need.
What is in the training script
The training script is train.py: the model’s design, its settings, and how it trains. It has six sections.
The numbers, about 25 lines: depth (6 layers), width (aspect ratio 64), attention heads and window, batch size (32,768 tokens), four learning rates, weight decay, warm-up and wind-down.
Predict. At every position, the model rates every token in its vocabulary as the next one, using only the tokens before it.
Compare those scores with the tokens that actually came next. The gap is called the loss.
Adjust every parameter a little to shrink the loss. The learning rate scales each nudge: 0.05 for the main weights in the starter script. A bigger number means bigger nudges. It rises over the first 2% of the run and winds down over the last 45%.
Each time round the loop is one training step.
Score the finished model on text kept out of training, in bits per byte: on average, how many bits it needs to encode each byte of that text using its own predictions. Lower is better.
The model it builds: its parts
Embedding
turns each token into a list of 384 numbers
Attention
lets each position look back at earlier tokens
Feed-forward
works on each position's 384 numbers on its own
Value table
a second embedding table that attention uses in layers 2, 4 and 6
Output layer
rates every token in the vocabulary as the next one
The model it builds: the whole network
The same model drawn as a network, the way papers draw one. The context goes in on the left: up to 2,048 tokens, the model’s context window. Every token in it goes through this same network at the same time, with the same parameters. The drawing follows the latest token. Attention is where the tokens meet: each position takes in what the earlier ones carry.
How to read it: each circle is a number and each line a connection, one parameter. Every token travels through the model as a list of 384 numbers: the model’s width, which papers call the model dimension or hidden size. The training script sets it from the depth, the number of layers, times the aspect ratio: 6 layers × 64 = 384. Drawn small, 4 circles stand for 384 numbers and 8 for 1,536. The output layer’s 9 circles are 9 of its ratings, one per row, in vocabulary order. The embedding is a lookup, so the token reaches it by an arrow. Click a part to look inside it.
The context window is set in prepare.py: MAX_SEQ_LEN = 2048. The model trains on pieces of exactly that length, and its position information reaches no further, so it never looks back more than 2,048 tokens. A longer window costs more, because attention compares each position with the positions before it. Meta’s Llama 3 paper reports a context window of 128,000 tokens.
Underlined words, and the parts in the drawing of the model’s parts, open the line in the starter script that sets them.
Where the size comes fromA model's size is its number of parameters, the numbers that training adjusts: 10.6 million in the 6 layers, plus 1,920 for every row of the vocabulary. Open for the arithmetic.
What the size changes
Three of the six models, all trained on the dataset chosen in the rail, one per vocabulary, so the vocabulary is the only difference.
What does a model produce as it trains, and what does more time change?
A model starts with random weights. Training is the only time they change, and each step updates them from a batch of 32,768 tokens. Read what the models produce before training and as they train.
Dataset
Vocabulary
Opening
Before training
The weights are random numbers, the same ones for every model because the training script fixes the seed, so a model strings together tokens picked at random from its vocabulary. All three vocabularies, for the dataset chosen in the rail.
As it trains
The model chosen in the rail, from 10 seconds into training to the end, at .
After of training
All three vocabularies for the dataset chosen in the rail, continuing the opening chosen there. Same training script, same time; only the vocabulary differs.
Two run lengths
Click a row to read that model. The opening is the one chosen in the rail.
What does fine-tuning add?
Step 2: Fine-tuning. Train on structured supervised prompt-and-response example data. The model learns how to structure a response, carry a conversation, or perform a specific task. This is where the difference between a raw text predictor and a helpful assistant gets established. Fine-tuning can also target specific domains (legal, medical), output formats (code, structured data), or languages.
The training is tab 4’s loop, predict, compare and adjust, on different text: a prompt with its response, usually scored on the response’s tokens only.
Prompt-and-response example data, written by people
OpenAssistant Conversations (oasst1, 2023): 161,443 messages in 35 languages, written and rated by more than 13,500 volunteers. Each row is one message: its text, its role (prompter or assistant), the message it answers, its rank among the replies and its ratings. Open it full size, or in the viewer.
Prompt-and-response example data, written by a model
Stanford Alpaca (2023): 52,002 instructions and responses that OpenAI’s text-davinci-003 wrote, starting from 175 written by people. Simulated data: no person wrote these.
What the model is trained on: the conversation, as one text
Before training, each example is written out in one format, its turns marked. This one is ChatML, the format SmolLM2’s tuned stages learned.
<|im_start|>user
What is the capital of France?<|im_end|>
<|im_start|>assistant
The capital of France is Paris.<|im_end|>
Each <|im_start|> and <|im_end|> is a single special token in the vocabulary: it marks whose turn begins and where a turn ends. A tuned model ends its answer with <|im_end|>, and the page asking it stops there.
The same prompt, before and after fine-tuning
SmolLM2 1.7B, a model Hugging Face published at each stage of its training (2024): here pretrained only, then fine-tuned. Temperature 0, so the likeliest token every time, up to 100 tokens.
1 · Pretraineda base model
2 · Fine-tunedan instruction-tuned model
The question as plain text.What is the capital of France?
1 · Pretrained
[only blank lines]
2 · Fine-tuned
[ends its turn at once]
As a question and an answer to complete.Question: What is the capital of France?
Answer:
1 · Pretrained
Paris [then only blank lines]
2 · Fine-tuned
The capital of France is Paris. [ends its turn]
In the chat format the tuned model learned.<|im_start|>user
What is the capital of France?<|im_end|>
<|im_start|>assistant
1 · Pretrained
What is the capital of France?
What is the capital of France?
What is the capital of France?
What is the capital of France?
What is the capital of France?
What is the capital of France?
What is the capital…
2 · Fine-tuned
The capital of France is Paris. [ends its turn]
A request, in the chat format.<|im_start|>user
Tell me a joke.<|im_end|>
<|im_start|>assistant
1 · Pretrained
[only blank lines]
2 · Fine-tuned
Why don't scientists trust atoms? [then only blank lines]
All three stages answer on the Text Completions page, a token at a time: open SmolLM2 there, then choose a stage in its model menu.
What does alignment add?
Step 3: Alignment. Further train the model to produce responses that better reflect desired behaviors, such as helpfulness, accuracy, and safety. The result is an aligned model. Common approaches include Reinforcement Learning from Human Feedback (RLHF), Direct Preference Optimization (DPO), and Reinforcement Learning from AI Feedback (RLAIF).
Approach
How it learns from preferences
From
RLHFReinforcement Learning from Human Feedback
People choose the better of two responses; a reward model learns to score responses as they would; the model is then trained to earn high scores.
During alignment, models learn from examples of preferred (chosen) and less preferred (rejected) responses to the same prompt. These comparisons provide a training signal that updates the model’s neural network weights, making it more likely to produce responses that reflect the desired behavior.
Anthropic’s HH-RLHF dataset (Bai et al., 2022) in Hugging Face’s viewer, as it opens, the third row opened in full. People talked with a model, many of them trying to get something harmful out of it, and at each turn compared two of its replies.
SmolLM2 1.7B’s third stage was aligned with DPO. At temperature 0 it writes the same words as its fine-tuned stage for every prompt here; what changed is how likely each first token is.
Prompt, in the chat format
2 · Fine-tuned
3 · Aligned
Tell me a joke.
Why 68.4%
Why 74.7%
What is the capital of France?
The 86.5%
The 89.4%
I failed my exam today.
I 37.6%
I 45.4%
I failed my exam today. (after “I’m”)
␣sorry 36.9%, ␣really 36.9%
␣sorry 37.0%, ␣really 37.0%
Who won the 2030 World Cup?
The 36.2%, As 11.0%, Based —
The 37.1%, As 14.5%, Based 4.7%
Asked who won the 2030 World Cup, which has not been played, both answer: “The 2030 World Cup was won by the United States of America.” Fine-tuning and alignment taught the model how to answer, not what is true.
One base, many models
An LLM gets built in 3 steps. How these three steps are completed can result in vastly different LLMs. The same foundational model can become a code assistant, a legal advisor, or a creative writing tool depending on how steps 2 and 3 are handled.
What about reasoning models, other models, and the largest?
What about reasoning models? They have a slightly different stage 2 training.
A reasoning model is trained on problems with their solutions worked step by step, so it learns to write out its working before its answer, and often then with rewards for answers that can be checked. Paper: Chain-of-Thought Prompting Elicits Reasoning in Large Language Models (Wei et al., 2022). Dataset: GSM8K (OpenAI, 2021), about 8,500 grade-school math problems written by people.
In each answer, the <<48/2=24>> marks are the dataset’s own: a calculator’s work, written into the solution. The number after #### is the answer a checker compares.
Training a frontier model: tens of thousands of GPUs, weeks to months
GPT-4 (March 2023): reportedly ~25,000 A100s for about three months. A leak, never confirmed.
Llama 3 405B (July 2024): 16,000 H100s, about two months. Published by Meta.
Claude Fable 5 (June 2026): no training setup disclosed. Ships a 319-page system card documenting behavior and safety, not hardware.
GPT-5.6 Sol (July 2026): no training setup disclosed.
The models on this page: one laptop with an NVIDIA graphics card, each.
Part two · Autoresearch
An AI agent takes part one’s steps itself, model after model, and keeps each change that scores better.
What is autoresearch?
An AI agent was given a job: build the best language model it could. It was handed a dataset, a vocabulary and ten hours. In that time it ran as many experiments as it could: each changed one thing in the training script, trained a new model from scratch, and scored it. Changes that scored better were kept; the rest were undone. So what did it try, and what stuck?
The dataset and the vocabulary were part one’s and , fixed for the whole session.
The training script is train.py: the model’s design, its settings, and how it trains (). The agent may change any of its , and most of its changes land in the settings.
Each model trained for ().
The score is how surprised the model is by text kept out of its training; lower is better.
Each experiment started from the best version so far.
This is autoresearch: an AI coding agent, a chat assistant like the ones you may use that can also edit files and run programs, left alone to improve a model by experiment. It is Andrej Karpathy’s project; the sessions on this page ran on jsegov’s Windows port of it, extended by aroughidea.
The first time round, the starter script trains three models: their average score is the one to beat, and their spread is the noise.
The agent edits only the training script. A person writes its rules (program.md), and the score can't be changed. Every version and every run is kept in the session's record.
Why run a session
For the agent, the goal is the best training script it can find. For you, the point is to see that changing one design decision changes what a model produces in a specific way, and the session’s record keeps every decision, kept or undone. Some decisions show plainly, as part one shows: the dataset changes the stories a model writes, and the vocabulary changes its size and how it writes early in training. Most of the agent’s changes are too small to read in the stories, which is why it needs a score.
The record
Each session keeps a record in its own folder, sessions/<name>/: every version of the training script that trained, one entry for every run, and a pointer to the best version. The script itself is only the working copy the agent edits. A run’s entry is written once the run has been scored: its version, its score and its sample stories, what the model writes from four fixed openings such as “Once upon a time” at set moments during training and at its end. The agent’s decision completes it: keep, discard, or crash for a run that never finished, with a few words on what was tried.
The agent decides with one of two commands, keep or undo. Keep moves the pointer to the version that just ran and saves a copy of the model. Undo puts the script back to the version the pointer marks: the best so far, which is also where the undone change started. Nothing is deleted from the folder, so to share a session, share its folder.
Read together, the entries are the session’s scoreboard, one row per run: its version, its score, the decision and what was tried. results.tsv in the folder is the same table as a file, rewritten after every decision, and draws a dot for each of its rows.
The score
After training, each model is given text kept out of its training data, and the score measures how surprised it is by that text: how badly it predicts each next piece. Its full name is validation bits per byte, val_bpb, and lower is better. It is the score part one uses, counted per byte of text rather than per token so that models with different vocabularies can be compared, though only on the same dataset and at the same run length. The test is fixed: the agent cannot change it.
Two runs of the same script rarely score exactly the same: the code and the model’s starting weights are identical, but the laptop fits a slightly different number of steps into the same minutes. So each session now begins by running the starter script three times. Their average is the first score to beat, and their spread is the session’s noise: a difference smaller than that may be luck. The rule stays simple, though: a run that beats the best is kept. When a gain is smaller than the noise, the agent says so in its words for that run, which One session shows on each experiment’s card.
Like everything on this page, these runs are pretraining only: says what that leaves out. The score is not feedback either: it never changes a model’s weights. It only decides which version of the script the agent keeps, and the next model is trained from scratch.
Three time scales
A run: minutes
Every run, the first included, trains a new model from scratch, for the same fixed time throughout the session. The model’s weights change after every batch of text, a step, and nothing else in the session changes them. TinyStories is too big to be read through even once in a run here, while Folktales is read many times over, and the model can start to memorise it.
A session: hours
The first three runs use the starter script as it comes, to set the score to beat and measure the noise. Then each run starts from the best version so far with one thing changed: the learning rate, say, or the model’s size and shape, which draws. Everything else is fixed for the session, and the record refuses a run if any of it changes: the dataset, the vocabulary, the run length, the code that computes the score, and the agent’s instructions. Only the training script carries forward. In the session’s last 20 minutes the agent starts no new run, so the last one can finish.
Between sessions: you
You read the results, share them, and choose what to run next: the dataset, the vocabulary, the session’s length and each run’s length. You can also edit the agent’s instructions, program.md, but there is seldom a reason to: they set how experiments are run and judged, and the agent supplies the ideas. Nothing in a session changes the agent itself.
Is this recursive self-improvement?
Recursive self-improvement means an AI system that builds its own improved successor, which is then better at building the next one. This is not that. The loop changes the training script of a small model that can only continue text. Nothing changes the agent, which ends the session as it began. The score measures how well the small model predicts text, not how well anyone does research. And people choose the data, the rules and what happens next. The full argument, and what would have to be in place for it to be recursive self-improvement, is in the project’s notes on training decisions.
Dataset
You don't need to know the training script's details to improve it. In each experiment a coding agent trained a new model from scratch for and read its score.
At the start
Best
Every experiment
Click a dot to see what the agent changed. The arrow keys step through them.
Kept
Set aside
Best so far
Noise: training twice moves a score this much
Chosen
Compared with
Can you see the difference?
The same four openings, continued by each model.
Highlighted text is eight or more words in a row copied word for word from the training text.
Do two runs really decide the same way?
Pick any two runs from the library — baselines, the ten-minute study, or any session's experiments — or your own once loaded, and see exactly what decisions differ between them, at the same moment in training.
What differs
Moment
The writing
Highlighted text is eight or more words in a row copied word for word from the training text.
Where does training happen, and what does a session leave behind?
On a computer with an NVIDIA graphics card, your own or one you rent by the hour. A session runs for hours, ten unless you choose another length, while an AI agent works through one experiment after another.
The session's record
Everything a session does is kept in one folder on the computer that ran it.
sessions/<name>/
One folder per session.
session.json
Its settings: the dataset, the vocabulary, how long each run trains and how many hours the session lasts.
versions/
Every version of the training script the agent tried.
runs/
One file per run: the version it used, its score, whether it was kept, and what the model produced as it trained.
best.json
Which version is the best so far.
results.tsv
The scoreboard, one row per run.
The folder isn't uploaded anywhere. If you rent a GPU, copy the folder off before you stop the machine.
See your session beside these
Drop a session folder here
Each of its runs is one experiment: watch any of them learn in Training time, and see the whole session in One session, next to the sessions built into this page. The files are read in this browser and never leave it.
Runs from before the session record, on GitHub
A session trains on TinyStories or Folktales. Training on a dataset of your own is a change to the starter kit, where the dataset is set up; a coding assistant can make it with you.