What is the purpose of the output projection matrix after concatenating attention heads?
Last updated
The output projection W_O mixes head outputs: concatenation only stacks them, while
W_Omakes each output dimension a learned combination of all heads (equivalently, a sum of per-head projections).It maps the result back to
d_modelwidth so the residual addx + MHA(x)works, and decides where in the shared residual space each head writes.Cost:
d_model²parameters, about a quarter of the attention layer's weights.