Several heads run attention in parallel on different learned projections of the same input, so each can specialize (for example syntax, coreference, nearby versus distant tokens).
Their outputs are concatenated and projected back to the model dimension.
The total cost stays about the same because each head works in a smaller subspace (model dimension divided by number of heads).
Loading…