dk,dv,dheadd_k, d_v, d_{\text{head}}

d_k, d_v — the width of one head

Read "d k" and "d v". They are the number of entries in one attention head's key and value vectors, usually d_model divided by the number of heads.

With dmodel=512d_{\text{model}} = 512 and h=8h = 8 heads, dk=dv=512/8=64d_k = d_v = 512 / 8 = 64. Splitting the width this way means multi-head attention costs about the same as one full-width head, while each head can learn to focus on a different kind of relationship.

dkd_k is the width of queries and keys, which must match because they are dotted together. dvd_v is the width of the values. They are usually equal but do not have to be. dheadd_{\text{head}} is another name for the same per-head width.

Example

dk=dmodelh=5128=64d_k = \frac{d_{\text{model}}}{h} = \frac{512}{8} = 64

The original Transformer's sizes.

Where the course uses it

Related terms