Skip to content

Stage 1 · From scratch · MA7

Reading the math

The formula inside every chat model fits on one line, and you can learn to read it aloud.

12 lessons · 118 minSteady

About this chapter

Most people stop at the formulas, so this chapter teaches you to read them. You will say a formula out loud, find what every letter holds, follow little numbers to their seats, and turn a sigma into a loop. Then come the symbols of change and chance, and three real lines from real papers: a loss, the attention formula behind chat models, and the optimizer most models train with. You work each one with tiny numbers by hand, then in code.

What you will be able to do

  1. 1

    A formula is a sentence

    Read a short formula out loud and say what each letter is doing.

    8 min
  2. 2

    Little numbers above and below

    Read subscripts as addresses and tell a power from a label up high.

    9 min
  3. 3

    Whole lists in one letter

    Tell a number, a list and a grid apart by how they are written, and read their shapes.

    9 min
  4. 4

    Adding up a thousand things

    Read a sum or a product with its limits, and turn one into a loop.

    10 min
  5. 5

    Functions inside functions

    Read $f(g(x))$ from the inside out and follow data through a layer.

    9 min
  6. 6

    The best, and where it is

    Tell $\max$ from $\arg\max$ and read training as an $\arg\min$.

    9 min
  7. 7

    Bars around letters

    Read $|x|$, $\lVert \mathbf{x} \rVert_1$ and $\lVert \mathbf{x} \rVert_2$, and say what a penalty on weights does.

    9 min
  8. 8

    Symbols of change

    Read $\Delta$, $\frac{dL}{dw}$, $\partial$ and $\nabla$, and the update rule they build.

    10 min
  9. 9

    Symbols of chance

    Read $P(A \mid B)$, $\mathbb{E}[X]$ and $X \sim \mathcal{N}(\mu, \sigma^2)$ aloud and work each one out.

    10 min
  10. 10

    Reading a loss

    Read mean squared error and cross-entropy piece by piece, and tell what a loss number means.

    11 min
  11. 11

    Reading attention

    Read $\operatorname{softmax}(QK^{\top} / \sqrt{d_k})\,V$ piece by piece and work one row by hand.

    12 min
  12. 12

    Read any formula

    Use a five-step habit to read a formula you have never seen, and code it.

    12 min

Before you start

All chapters