QUESTION 9 OF 10

How does model width relate to head dimension in standard multi-head attention?

Reveal the answer and explore the explanation.

09
Medium

How does model width relate to head dimension in standard multi-head attention?

Answer
Answer

With equal-sized heads and a standard partition, each head has dimension model width divided by head count.

Practical example

A 768-wide model with 12 heads uses 64 dimensions per head.

PythonRelated concept example
width, heads = 768, 12
assert width % heads == 0
print('Head size:', width // heads)

This assumes the common equal-width head partition.

Reference: Further reading ↗

Last 30 min revisionHigh-yield interview Q&As