ML//transformer//attention//attention head

An attention head is one unit of multi-head attention, with its own projections \(W_Q, W_K, W_V\) operating on a reduced dimension (for example 128 dimensions instead of 12288). The full process (the scores \(Q \cdot K\), a softmax over them, the multiplication by \(V\), the sum over columns and the suggested change to the vector) is one head of attention.


An attention head is one unit of multi-head attention, with its own projections WQ,WK,WVW_Q, W_K, W_VWQ​,WK​,WV​ operating on a reduced dimension (for example 128 dimensions instead of 12288). The full process (the scores Q⋅KQ \cdot KQ⋅K, a softmax over them, the multiplication by VVV, the sum over columns and the suggested change to the vector) is one head of attention.

The dimension is reduced so that each head can specialize in a different type of relationship (syntax, coreference, semantic, positional) by operating in its own subspace. No explicit mechanism forces that specialization; it emerges from training. If two heads learn the same thing they do not reduce the loss, so backprop pushes them to diversify.

The specializations observed empirically are syntax tracking, coreference resolution, positional distance and induction heads (pattern-copying circuits for in-context learning, the best-understood example of a head's specialization).

GPT-3 has 96 heads per layer and 96 layers. The outputs of the heads are concatenated and projected back to the model dimension through WOW_OWO​.

Whether what each head does can be identified across all 96 heads of all 96 layers is the question of mechanistic interpretability, and an answer would give a complete map of how the model thinks.