← See all modules
Bonus 2Full course

An LLM from scratch

Open the black box: build and train a tiny language model and run an SLM on your own computer.

4 lessons · 95 min

What you'll build

Open the black box. You build a tiny language model from scratch, train it on your own computer, and watch it generate text. Along the way, you understand tokens, embeddings, and attention without scary math. At the end, you run a real SLM locally and know when a small model is enough.

  • From scratch, line by lineNo magic library: you write the core pieces and understand each one.
  • Trains on your laptopA model small enough to train in minutes, no expensive GPU needed.
  • Watch the model learnTokens, embeddings, and attention in a small example you can inspect.

What you'll learn

  • What happens inside an LLM when it generates a response
  • Tokens, and how to write a tokenizer
  • Embeddings and attention, explained with visual examples
  • Training a tiny model that generates text
  • SLM or LLM: running a small model locally and when to use each

The lessons

0 of 4 lessons complete
  1. 1How an LLM worksFollow text from tokens to vectors, attention, and the next-token prediction, with an example you can change.🔒
  2. 2A tokenizer from scratchTurn characters into IDs and back, handle spaces and accents, and keep the vocabulary stable.🔒
  3. 3Training a tiny modelTrain a character model in plain JavaScript, watch its error fall, and separate learning from memorizing.🔒
  4. 4Running an SLMRun a small pretrained model with Ollama, call it from Node with fetch, and test whether it fits your task.🔒