Functions and operators

dk\sqrt{d_k} Square root

The square root. In attention, dividing by √d_k keeps dot products at a sensible scale.

In ML papers

x\sqrt{x} is the number whose square is xx. Two places it appears constantly: attention scales scores by 1dk\frac{1}{\sqrt{d_k}}, because a dot product of dkd_k random unit-variance terms has variance dkd_k, and dividing by dk\sqrt{d_k} brings it back to 1; and normalization and Adam divide by variance+ϵ\sqrt{\text{variance} + \epsilon}, a standard deviation.

How to type it

LaTeXShows
\sqrt{x}x\sqrt{x}
\sqrt[n]{x} n-th rootxn\sqrt[n]{x}

A worked example

64=8  ⇒  1664=2\sqrt{64} = 8 \;\Rightarrow\; \frac{16}{\sqrt{64}} = 2

With dk=64d_k = 64 (the original Transformer's head size), a raw score of 16 becomes 2.

Equations that use it

Related

ab\frac{a}{b}Fractionϵ\epsilonEpsilon∥x∥2\|\mathbf{x}\|_2NormVar⁡[X]\operatorname{Var}[X]Variance

Decode this example →