LearnBenchStart learning →

AI Research Scientist · Attention Mechanisms & Kernels

Multi-head attention design

Real lesson card · Page 1 of 4

Multi-head attention design

Multi-head attention

Multi-head attention splits the input into hh heads, each with its own learned query, key, and value projection matrices, so every head can compute attention independently before the results are combined.
Example
With h=8h=8 heads and dmodel=512d_{\text{model}}=512, each head works in a 64-dimensional subspace with its own WQW_Q, WKW_K, WVW_V matrices, learned separately from every other head.

Recall check from the same lesson

In a multi-head attention layer with d_model = 512 split into 8 heads, each producing a 64-dimensional output, the per-head outputs are concatenated into a 512-dimensional vector before being multiplied by the output projection matrix $W_O$.

Sources

· Editorial policy

One sitting · 20–30 minutes

A focused session on your AI Research Scientist interview

LearnBench starts from what you already know — skip what you have, master what you’re missing.

Start now

More Attention Mechanisms & Kernels questions