AI State of the Art
Fundamentals/Machine Learning: The Basics/19 min
Section 2

How to Read the Formulas in This Course

Listen as a podcast →

The problem: a formula is not an obstacle, it is a shorthand sentence

Research papers are written by people in a hurry. Rather than write "add up the thirty-two numbers in the list", they write ∑\sum. That is not difficulty, it is stenography.

This page is the decoder. It does not teach you mathematics: it lets you read a formula back as an English sentence, and above all recognise the formulas you can skip without losing anything. Other lessons link here instead of re-explaining everything each time.

Vector, matrix, dimension

Three words show up everywhere. They name very simple things.

  • A vector is a list of numbers in a fixed order. For instance (0.2;−1.5;3.0)(0.2 ; -1.5 ; 3.0). Nothing more. One row of a spreadsheet.
  • A matrix is a table of numbers, with rows and columns. One sheet of a spreadsheet.
  • The dimension of a vector is simply how many slots it has.

These three objects, and the tensor that generalizes them, are covered in detail in vectors and matrices.

When a page says a model works "in dimension 4096", it means: each token (the unit the model manipulates, a word or a piece of a word) is represented inside the model by a list of 4096 numbers. None of those numbers has an isolated meaning you could put a name to. It is the whole list, taken together, that encodes meaning.

The one sentence that carries fifty pages of this course

Multiplying a matrix by a vector means mixing the components. Each slot of the result is a weighted average of all the slots of the input, with weights specific to that slot.

The practical consequence: after a single matrix multiplication, no output slot depends on any single input slot any more. Everything depends on everything. That is exactly why you cannot open up a neural network and read off what slot number 317 is for.

What is learned and what is computed

This is the most useful distinction in the whole course, and the one papers assume you know without ever saying it.

Learned parameterComputed value
Usual notationWW, bb, with subscripts: WQW_Q, WKW_KQQ, KK, VV, hh, xx, yy, zz
Common nameweight, biasactivation, state, output, score
When it comes into beingduring trainingwhile you are reading the answer
Afterwardsfrozen, stored in the model filethrown away as soon as the request ends
It depends onall the training dataonly on the text at hand

A model you download is exactly the set of its learned parameters, and nothing else. The computed values exist nowhere at all until someone asks a question.

Why this distinction changes what sentences mean

Take the formula K=X⋅WKK = X \cdot W_K, it turns up in every page about attention. Here XX is the current text turned into numbers (computed), WKW_K is a weight matrix (learned), and KK is the result (computed).

Now two claims you often read: "this model shares the matrix WKW_K across all heads" and "this model shares the result KK across all heads". They look like different statements. They are the same one. Because a single matrix applied to the same input can only produce a single result: sharing the recipe and sharing the dish cannot be separated.

So when a page says "it shares X" without saying which, do not hunt for a subtlety. There isn't one.

The symbols, one at a time

The two accumulation operators

∑\sum (capital sigma, "sum"). Out loud: "add up everything that follows, letting the subscript run". So ∑i=13xi\sum_{i=1}^{3} x_i reads "x1x_1 plus x2x_2 plus x3x_3". That is all it ever means.

∏\prod (capital pi, "product"). Same thing, but multiplying instead of adding. You meet it for the probability of a whole sentence: the probability of each word, all multiplied together.

The two slope operators

∂\partial (a "curly d", the partial derivative). ∂L∂w\frac{\partial \mathcal{L}}{\partial w} reads: "how much does the loss L\mathcal{L} change if I nudge the weight ww a hair, everything else held still". A sensitivity, nothing more.

∇\nabla (nabla, the gradient). This is the list of all those sensitivities at once, one per parameter. ∇θL\nabla_\theta \mathcal{L} reads: "for each parameter, which way and how hard you would have to push it to make the error go up". Training then does the opposite of what that list says, see Gradient descent.

Expectation

E\mathbb{E} (expectation). It is an average. E[X]\mathbb{E}[X] reads "the average value of XX". When you see Ex∼D[…]\mathbb{E}_{x \sim D}[\ldots], the subscript says what the average runs over: here over examples xx drawn from the dataset DD. Out loud: "on average, across the data". The detail is in expectation, variance and moments.

Sizes and absolute values

∣⋅∣\lvert \cdot \rvert, single bars: absolute value, the number with its sign stripped off. ∣−3∣=3\lvert -3 \rvert = 3. Around a set, the same bars mean "how many elements".

∥⋅∥\lVert \cdot \rVert, double bars: the norm, the length of a vector, its overall size. For the list (3;4)(3 ; 4) the usual norm is 5, by Pythagoras. Useful when you want to say "is this vector big or small?" without caring which way it points. The different ways of measuring that length are in norms and distances.

Two operations on arrays

⊙\odot, a circle with a dot: the element-wise product (Hadamard product). Slot 1 times slot 1, slot 2 times slot 2. This is not a matrix product: nothing gets mixed, every slot stays in its own lane. It is how a gate filters a memory slot by slot, as in LSTM and GRU.

The superscript ⊤^\top (or T^T), the transpose: the table flipped, rows becoming columns. It is pure bookkeeping, there so that dimensions line up in a multiplication. You can ignore it with no loss.

Subscripts

A subscript is a label, not a calculation. Three conventions cover the whole course:

  • xix_i: the ii-th item of a list. The ii is a dummy: it points at nothing in particular, it just says "any one of them".
  • hth_t: the value at step tt in a sequence read left to right. The tt is a position in time: ht−1h_{t-1} is the state just before.
  • yi,jy_{i,j}: two labels, typically row ii and column jj of a table.

The Greek letters you will meet

Authors use them fairly consistently from paper to paper.

LetterNameWhat it almost always stands for
θ\thetathetathe whole set of the model's learned parameters
α\alpha, η\etaalpha, etaa learning rate: the size of the correction step
β\betabetaa blending coefficient, often an inertia
γ\gammagammaa decay factor, or a scaling weight
λ\lambdalambdathe strength of a penalty added to the loss
μ\mumua mean
σ\sigmalower-case sigmaa standard deviation, or else the sigmoid function
Δ\Deltacapital deltaa change, a gap between two values
ε\varepsilonepsilona very small number, or added noise

The conditioning bar

p(y∣x)p(y \mid x) reads: "the probability of yy given xx". The vertical bar separates what you want the probability of (on the left) from what you already take as settled (on the right). All of text generation lives in this notation: p(next word∣text so far)p(\text{next word} \mid \text{text so far}).

Curly braces

Curly braces describe a set: a collection with no order and no repeats, such as {cat,dog,bird}\{\text{cat}, \text{dog}, \text{bird}\}. The form {x1,…,xn}\{x_1, \ldots, x_n\} just says "the collection of the nn items". The symbol ∈\in reads "belongs to".

Choosing: min, max, argmin, argmax

min⁡\min and max⁡\max return a value: the smallest, the largest. max⁡(0;z)\max(0 ; z) is zz when zz is positive, and 0 otherwise.

arg⁡min⁡\arg\min and arg⁡max⁡\arg\max return which one won, not how much it won by. That is the entire difference. If the scores of three candidate words are (1.2;4.8;0.3)(1.2 ; 4.8 ; 0.3), then the max⁡\max is 4.84.8 while the arg⁡max⁡\arg\max is "the second one". Out loud: "the one that maximises". A model generating text is after an arg⁡max⁡\arg\max: it needs to know which word to write, not what score that word got.

Which formulas can you skip?

All of them, on one condition: that the page told you what the formula does. A well-attended formula is a precise restatement of the sentence before it. Three concrete cases:

  • A definition ("the sigmoid is 1/(1+e−z)1/(1+e^{-z})"): skip it. Remember the shape of the curve, not the expression.
  • A count (cache size, number of bytes): do not skip it. It is arithmetic, it explains a real cost, and it can be checked.
  • An impossibility argument ("these two stacked layers equal one single layer"): do not skip it. It is short, and it is often where the invention actually lives.
Two notations covered elsewhere

Big-O notation, O(…)O(\ldots), which describes how a cost grows with the size of the input, has its own lesson: Computational complexity.

The softmax function, which turns a list of scores into probabilities, is covered in Activation functions.

Why it matters

A technical paper about a language model rarely contains hard mathematics. It contains abbreviated mathematics. The difference between a statement about a weight matrix and a statement about an intermediate result changes entirely what is being said, and it shows up as the choice of a single letter.

Check your understanding0 / 5

1. When a vector is multiplied by a matrix, what does each cell of the result depend on?

2. In the formula K = X · W_K, which pieces are learned during training and which are computed on every request?

3. One paper says a model shares the matrix W_K across all its heads; another says it shares the result K. What is the difference?

4. What does the element-wise product (the circle with a dot) do, and how is it different from matrix multiplication?

5. The scores of three candidate words are 1.2, 4.8 and 0.3. What does argmax return?