HELLO LLM · FREE TO LEARN · NONCOMMERCIAL

Build a small model.
Understand large models.

Start with a neuron you can calculate by hand.
Build a small language model that learns and generates text.

Start from zero · 20 lessons · No GPU needed

From text to the next characterTinyLM
早上,小丁喜欢?
Append the new character, then repeat

Video lessons

From principles to source code and results.

23 Chinese videos · about 110 minutes

Build the model, step by step

One project throughout. A result you can check at every stage.

Start here

Meet the course, then put the finished model to the test.

Part I

Make a numerical network learn

Start with one output. See how errors change parameters.

01—06
  1. 01Neurons: What Does a Model Calculate Before It Writes the Next Character?Explain the roles of inputs, parameters, and activation.
  2. 02Vectors and Matrices: Do Two Outputs Require Two Copies of the Code?Explain input, parameter, and output shapes axis by axis.
  3. 03Nonlinearity: Why Can Multiply-and-Add Not Express Four Simple Rules?Explain the difference between stacking layers and adding nonlinearity.
  4. 04Gradients: Why Can an Update in the Right Direction Make Things Worse?Distinguish the local direction given by a gradient from the actual update step size.
  5. 05Backpropagation: Must We Test All 9 Parameters One by One?Calculate one backward path by hand and explain how branch contributions combine before parameters are updated together.
  6. 06The Training Loop: What Happens to Four Predictions After 500 Updates?Write one training iteration, explain gradient clearing, and identify incorrect comparisons caused by broadcasting.

Stage goal: Complete your first training loop

Part II

Bring text into the network

Turn text into inputs, probabilities, and training examples.

07—09
  1. 07Embedding: How Does Text Become a Network Input?Distinguish character IDs, embedding vectors, and the three tensor axes.
  2. 08Softmax: How Do Scores Become Next-Character Probabilities?Explain candidate scores, relative competition, and normalization.
  3. 09Training Targets: How Does a Sentence Become a Learnable Task?Construct shifted targets and explain average loss over valid positions.

Stage goal: Train your first character prediction model

Part III

Read context and assemble the model

Add context and order, then connect the components.

10—16
  1. 10Attention: How Does Predicting the Next Character Read Earlier Text?Calculate one attention row and distinguish reading proportions from the content being read.
  2. 11Causal Masks: Why Is Parallel Training Not Peeking at the Answer?Explain causal visibility and the correct placement of the mask.
  3. 12Multi-Head Attention: Where Does Each Head Read?Explain head splitting, independent attention weights, and merging, and identify incorrect axes even when shapes match.
  4. 13RoPE: How Does the Model Know the Order?Connect the two-dimensional rotation formula to relative positions and Q/K dot products.
  5. 14SwiGLU: What Happens After Reading the Prefix?Explain input-dependent gating and positionwise processing.
  6. 15Residual Connections and RMSNorm: Why Keep a Direct Path?Assemble head splitting, rotation, and causal aggregation into an attention component, then add residual connections and a Pre-Norm model block.
  7. 16The Complete Model: Follow the Character “欢” Through Every StepAssemble the complete model and distinguish representations, parameters, and vocabulary scores.

Stage goal: Trace a forward pass through the complete model

Part IV

Pretrain, generate, and fine-tune

Teach the same model to continue text, then answer questions.

17—20
  1. 17Pretraining: Why Can New Questions Get Worse as Training Questions Improve?Complete pretraining and use differences in the data to explain changes in evaluation results.
  2. 18Generation: How Many Choices Does One Sentence Take?Write a generation loop and explain random selection and stopping conditions.
  3. 19Supervised Fine-Tuning: Why Can It Continue Text but Still Fail to Answer?Build answer supervision and diagnose fine-tuning tradeoffs with fixed comparisons across three methods and three seeds.
  4. 20The Full Workflow: Connect Pretraining, Fine-Tuning, and GenerationIndependently complete a transfer experiment covering data, vocabulary, model construction, training, and reloading, and explain both successes and failures.

Stage goal: Reproduce training and test your understanding on new data

After the 20 lessons

Return to the beginning and see how much you can now explain.

Download the book

Use PDF for printing, or EPUB for phones and e-readers.

Chinese · v0.1.0-rc.1

Stay in touch · 好好用 AI

Follow the WeChat account to discuss what you learn and build.

For bugs and corrections, open a GitHub issue.

好好用 AI WeChat official account QR code

Scan in WeChat · Open full image

Search all 23 articles by keyword.

Experiments
Open separately
View figure
100%