Attention Is All You Need

Notation sheet

Every symbol the paper uses, in the order you meet them: what it means, its value in the paper's base model and in our miniature, and where the lab explains it. Print it and keep it beside the paper.

Symbol Meaning The paper Our model Explained in
\(N\) identical layers in each stack 6 2
\(d_{\text{model}}\) numbers in every vector between sub-layers, and in the embeddings 512 64
\(h\) heads, run side by side 8 4
\(d_k\) numbers in each query and key 64 16
\(d_v\) numbers in each value 64 16
\(d_{ff}\) numbers inside the network, between the two layers 2048 256
\(Q,\ K,\ V\) queries, keys and values: one row per token, made from its vector by W^Q, W^K and W^V rows of 64 numbers per head rows of 16 numbers per head
\(W^{Q}_i,\ W^{K}_i,\ W^{V}_i\) head i's own projection matrices, d_model × d_k each 512 × 64 64 × 16
\(W^{O}\) the output matrix that mixes the joined heads, h·d_v × d_model 512 × 512 64 × 64
\(\sqrt{d_k}\) what every score is divided by 8 4
\(-\infty\) the score given to a forbidden position before the softmax; its weight becomes e^{−∞} = 0 decoder self-attention only the same
\(\mathrm{LayerNorm}(x + \mathrm{Sublayer}(x))\) the output of every sub-layer: the residual sum, normalised after every sub-layer (post-normalisation) the same
\(W_1,\ b_1\) the first linear layer: widens the vector 512 × 2048, and 2048 biases 64 × 256, and 256 biases
\(W_2,\ b_2\) the second linear layer: narrows the vector back 2048 × 512, and 512 biases 256 × 64, and 64 biases
\(\sqrt{d_{\text{model}}}\) what an embedding is multiplied by when it is looked up about 22.6 8
\(PE_{(pos,\,2i)},\ PE_{(pos,\,2i+1)}\) the positional encoding: a sine for the even dimension, a cosine for the odd one, added to the token at position pos fixed sine waves the same
\(pos\) the token's position in the sentence, from 0 any 0 to 31
\(i\) which pair of numbers: dimensions 2i and 2i + 1 0 to 255 0 to 31
\(n\) the sequence length a sentence of word pieces up to 10 tokens in training
\(d\) the representation size, d_model 512 64
\(k\) a convolution's kernel size: how many neighbours it reads any not used
\(r\) the neighbourhood of restricted self-attention a suggestion for future work not used
\(\beta_1,\ \beta_2\) how much Adam's running averages of the slopes and of their squares remember 0.9, 0.98 0.9, 0.98
\(\epsilon\) a tiny number that keeps Adam from dividing by zero 10⁻⁹ 10⁻⁹
\(warmup\_steps\) the steps over which the rate rises; the peak 4000 800
\(step\_num\) the current training step, from 1 up to 100,000 (base) up to 4,000
\(P_{drop}\) the share of values dropout switches off, in training only 0.1 (base), 0.3 (big; 0.1 for English–French) 0.1
\(\epsilon_{ls}\) the share of the target spread over all tokens 0.1 0.1
\(\text{beam size}\) how many beginnings beam search keeps at every step 4 4
\(\alpha\) the length penalty's strength: larger favours longer translations 0.6 0.6
\(\text{BLEU}\) how closely a translation matches a human one, from 0 to 100 28.4 (EN-DE), 41.8 (EN-FR), big model 99.95 on our 805 held-out sentences
\(\text{PPL}\) perplexity per word piece on the development set; lower is better 4.92 (base) not measured; we use the held-out loss
\(\text{params}\) the number of weights, in millions 65 (base), 213 (big) about a quarter of a million

Values from Vaswani et al., Attention Is All You Need (arXiv:1706.03762v7); ours read from the lab's models. Ch. is a Course chapter, § a section of the paper in the Theory tab.

An unhandled error has occurred. Reload 🗙

Reconnecting…

Your connection to the Transformers and Attention Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.