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 . 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 . 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.
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 parameter | Computed value | |
|---|---|---|
| Usual notation | , , with subscripts: , | , , , , , , |
| Common name | weight, bias | activation, state, output, score |
| When it comes into being | during training | while you are reading the answer |
| Afterwards | frozen, stored in the model file | thrown away as soon as the request ends |
| It depends on | all the training data | only 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.
Take the formula , it turns up in every page about attention. Here is the current text turned into numbers (computed), is a weight matrix (learned), and is the result (computed).
Now two claims you often read: "this model shares the matrix across all heads" and "this model shares the result 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
(capital sigma, "sum"). Out loud: "add up everything that follows, letting the subscript run". So reads " plus plus ". That is all it ever means.
(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
(a "curly d", the partial derivative). reads: "how much does the loss change if I nudge the weight a hair, everything else held still". A sensitivity, nothing more.
(nabla, the gradient). This is the list of all those sensitivities at once, one per parameter. 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
(expectation). It is an average. reads "the average value of ". When you see , the subscript says what the average runs over: here over examples drawn from the dataset . Out loud: "on average, across the data". The detail is in expectation, variance and moments.
Sizes and absolute values
, single bars: absolute value, the number with its sign stripped off. . Around a set, the same bars mean "how many elements".
, double bars: the norm, the length of a vector, its overall size. For the list 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
, 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 (or ), 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:
- : the -th item of a list. The is a dummy: it points at nothing in particular, it just says "any one of them".
- : the value at step in a sequence read left to right. The is a position in time: is the state just before.
- : two labels, typically row and column of a table.
The Greek letters you will meet
Authors use them fairly consistently from paper to paper.
| Letter | Name | What it almost always stands for |
|---|---|---|
| theta | the whole set of the model's learned parameters | |
| , | alpha, eta | a learning rate: the size of the correction step |
| beta | a blending coefficient, often an inertia | |
| gamma | a decay factor, or a scaling weight | |
| lambda | the strength of a penalty added to the loss | |
| mu | a mean | |
| lower-case sigma | a standard deviation, or else the sigmoid function | |
| capital delta | a change, a gap between two values | |
| epsilon | a very small number, or added noise |
The conditioning bar
reads: "the probability of given ". 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: .
Curly braces
Curly braces describe a set: a collection with no order and no repeats, such as . The form just says "the collection of the items". The symbol reads "belongs to".
Choosing: min, max, argmin, argmax
and return a value: the smallest, the largest. is when is positive, and 0 otherwise.
and return which one won, not how much it won by. That is the entire difference. If the scores of three candidate words are , then the is while the is "the second one". Out loud: "the one that maximises". A model generating text is after an : 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 "): 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.
Big-O notation, , 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.
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?