Home › Learn › Small model from scratch › 14 steps

Building a language model from one sentence

The whole training text is the cat sat on the mat and the cat was happy.. Fourteen steps, one at a time; use the buttons or the arrow keys. The numbers come from a real run of one_sentence_llm.py. Overview and code.

Step 1 of 14

The corpus: one sentence

Goes inNothing yet
What happensWe pick the text the model will learn from
Comes outOne sentence of 45 characters
the cat sat on the mat and the cat was happy.our whole corpus: 1 sentence, 45 charactersour LLMgiven "the" …… it writes the rest

A real LLM learns from billions of sentences. Ours learns from one, so that every number in every step fits on the screen. The goal: after training, if we give it the word the, it should write the rest of the sentence by itself.