Scaled dot-product attention
Every token proposes a query, every token advertises a key, and the match between them decides whose value gets read. Dividing by the square root of the key dimension keeps the dot products from growing with width and flattening the softmax gradient.
- The queries — what each position is looking for.
- The keys — what each position offers.
- The values — what actually gets mixed and returned.
- The key dimension, whose square root rescales the scores.