Scaled Dot-Product Attention › Key Parameters
Language AI HandbookAll chapters Scaled Dot-Product Attention › Key ParametersOne section · Sections in this chapter12 / 15 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Scaled dot-product attention introduces two primary hyperparameters, both of which interact with the quadratic complexity we analyzed above.
The first is (query/key dimension): the dimensionality of the query and key projections. Larger allows queries and keys to encode more complex patterns. This provides more expressive capacity for the similarity computation. However, it increases computational cost as and also increases the number of parameters in and . Too small a may not provide enough expressive capacity to represent the diversity of relationships the model needs to capture. Too large a wastes computation on dimensions that carry little signal. Typical values range from 64 to 256 per head in multi-head attention, with 64 being the value used in the original transformer paper's base model.
The second is (value dimension): the dimensionality of the value projections and the output. The value dimension controls the richness of the information each token contributes when attended to. Setting smaller than creates a bottleneck that forces the model to compress information, which can be a useful regularizer. Setting larger allows richer information transfer. In practice, is by far the most common choice, and it simplifies the architecture by making all projection dimensions equal. Changing changes the size of the output representation without affecting the attention weights.
The scaling factor is not a hyperparameter: it is derived from and applied without modification. There is no reason to tune it separately; it is a fixed normalization constant whose derivation we worked through in the scaling section above.