Multi-Head Attention Mechanism
Instead of executing a single attention function using queries, keys, and values of the model dimension , Multi-Head Attention linearly projects , , and with separate learned projections to dimensions , , and , respectively. Applying attention across each of these projected versions in parallel produces -dimensional output values that are concatenated and projected once again to form the final values:
The projections are parameter matrices , , , and . In the base model, parallel attention heads are used with for .
Multi-head attention allows the model to jointly attend to information from different representation subspaces at different positions simultaneously. In contrast, a single attention head averages attention-weighted positions, which inhibits this capability. Because the dimensions of each head are reduced, the total computational cost remains similar to that of full-dimensionality single-head attention.
0
1
Tags
Prep Sessions
Foundational Deep Learning Architectures: Transformers and Residual Networks @ University of Michigan - Ann Arbor
Ch.1 Transformer Architecture and Components - Foundational Deep Learning Architectures: Transformers and Residual Networks @ University of Michigan - Ann Arbor
Multi-Head Attention - Foundational Deep Learning Architectures: Transformers and Residual Networks @ University of Michigan - Ann Arbor
Learn After
In the Multi-Head Attention mechanism, what are the dimensions of the final output projection parameter matrix ?
In Multi-Head Attention, each of the parallel attention heads shares an identical set of projection parameter matrices , , and .
What operation is applied to the individual parallel head outputs () immediately before multiplying them by the parameter matrix ?
Compare Multi-Head Attention to a single attention head in terms of representation capability, and explain how the dimensions chosen for individual heads affect total computational cost.