Papers · Architectures and attention · 2017
Attention Is All You Need
The notation of the Transformer paper, explained: its 5 displayed equations, then every symbol it uses, grouped by category and shown the way the paper writes it.
Reading this paper
The paper that introduced the Transformer: a model built from attention alone, with no recurrence. Its central formula is , decoded term by term on its own page (linked below).
Two things trip readers up. The matrices are written unbolded, so , and look like scalars but are matrices with one row per token. And in the superscript is a label (the query projection of head ), not a power. The sizes are named , , and heads, and the positional encoding uses and as plain italic names, not products of letters.
Read from arXiv's HTML version: 5 displayed equations and 96 pieces of inline math. 29 symbols and constructs from the catalog, read as attention and transformers.
The paper's displayed equations
Open any of them in the decoder for a symbol-by-symbol reading.
Famous equations in this paper
Symbols, by category
Most used first. The examples are written as the paper writes them.
Notation conventions
- , ,
Italic letters (variables) 163 uses
A plain italic letter is a variable; conventions say what kind (x input, y target, W weights…).
- , ,
Subscript (index or label) 81 uses
A subscript picks an element (xᵢ), a time step (h_t), a named copy (W_q), or the parameters (p_θ).
- , ,
Superscript (power or label) 33 uses
Usually a power (x² = x·x), but a capital or a word up there is often just a label (W^Q).
- ,
Multi-letter names 7 uses
A run of italic letters like pos or model is usually one name, not a product of single letters.
Greek letters
Epsilon 3 uses
A tiny constant for numerical safety (10⁻⁸ in Adam), or noise ε ~ 𝒩(0, I).
Pi 2 uses
A policy π(a | s) in reinforcement learning, or the constant 3.14159…
Beta 2 uses
Usually a decay rate (Adam’s β₁, β₂), a shift parameter in normalization, or a weight on a loss term.
Alpha 2 uses
Often a learning rate or step size; also attention weights αᵢⱼ or a mixing weight.
Vectors and matrices
Centre dot 27 uses
A dot product between vectors, plain multiplication between numbers, or an empty slot f(·).
- , ,
Q, K, V (query, key, value) 21 uses
In attention: queries Q, keys K and values V, each a matrix with one row per token.
Times (cross) 5 uses
Usually the “by” in a shape (n × d); also plain multiplication or a cross product.
Bold lowercase (vector) 2 uses
A bold lowercase letter is a vector: a list of numbers.
Transpose 1 use
Swap rows and columns. xᵀy is a dot product; xyᵀ is an outer product.
Calculus and gradients
Infinity 1 use
Infinity; as a norm subscript, ‖x‖_∞ is the largest absolute entry.
Probability and statistics
- , ,
Probability p(x) 21 uses
A probability or probability density; p is usually the true or model distribution, q an approximation.
Logarithm 2 uses
A logarithm, almost always the natural log (base e) in ML papers.
Functions and operators
Big-O notation 17 uses
How a cost grows with size, ignoring constants: O(n²) means at most proportional to n² for large n.
- ,
Square root 5 uses
The square root. In attention, dividing by √d_k keeps dot products at a sensible scale.
- ,
Fraction 3 uses
Division: the top divided by the bottom.
- ,
Max and min 2 uses
The largest (or smallest) value, over the arguments or over the range in the subscript.
Softmax 1 use
Turns a vector of scores into probabilities: exponentiate each, then divide by the total.
Concatenation 1 use
Join vectors end to end: a vector of length m and one of length n become one of length m + n.
Feed-forward network (FFN, MLP) 1 use
A small network applied to each position: a linear layer, an activation, and another linear layer.
Sine 1 use
The sine function; in ML papers mostly inside positional encodings and rotary embeddings.
Cosine 1 use
The cosine function; in ML papers usually cosine similarity, a cosine schedule, or positional encodings.
Summation 1 use
Add up the expression for every value of the index, from the bottom limit to the top.
Sets, shapes and definitions
Element of 5 uses
“Is in” or “belongs to”: x ∈ S says x is a member of the set S.
- , ,
Tensor shapes 5 uses
ℝ with a superscript of sizes joined by × declares an array’s shape: ℝ^{B×T×d} is a 3-axis tensor.
Inequalities 1 use
Less than / greater than (or equal). ≪ means “much smaller than”.
4 things the catalog has no entry for yet
-
Sublayer2 -
head_{1}1 -
head_{h}1 -
head_{i}1
Formulas from arXiv's HTML version of the paper, © their authors; the explanations are this site's. Title and authors as arXiv lists them.
More architectures and attention papers
- RoFormer: Enhanced Transformer with Rotary Position Embedding (RoPE, 2021)
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness (FlashAttention, 2022)
- Mamba: Linear-Time Sequence Modeling with Selective State Spaces (Mamba, 2023)
- Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layer (Mixture of experts, 2017)
- Neural Machine Translation by Jointly Learning to Align and Translate (Bahdanau attention, 2014)
- An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale (ViT, 2020)