Transformers calculate dynamic attention weights across all tokens in parallel using Query, Key, and Value vectors.
The new contextual embedding for token is computed as the sum of all Value vectors weighted by these exact percentages.
Every token embedding is multiplied by learned weight matrices W_q and W_k to produce Query and Key vectors representing what it is looking for and what it contains.
The dot product Q · K measures compatibility. Dividing by √d_k prevents vanishing gradients in large dimensions before passing through Softmax.
Different heads track different linguistic relationships (e.g. coreference vs grammar) simultaneously without sequential recurrence bottleneck.