Study
Transformers · Multi-head attention
Splitting d_model into several heads so attention can look at different things at once, implemented by reshaping, and checked against nn.MultiheadAttention.
- Multi-head attention runs h smaller attentions in parallel and concatenates the results.
- With d_k = d_model / h, total compute stays about the same as one big head.