Deconstructing multi-head self-attention mechanics: query-key compatibility, scaled dot-product normalization, and contextual representations in real time.
Self-attention allows every word in a sequence to dynamically route information from every other word. Instead of static dictionary vectors, words project into three distinct roles: Query ($Q$) ("What am I seeking?"), Key ($K$) ("What information do I hold?"), and Value ($V$) ("What content do I transmit?").
The affinity between token $i$ and token $j$ is calculated via their dot product scaled by $1/\sqrt{d_k}$ to prevent gradient saturation, then normalized with $\text{Softmax}$ so all incoming weights sum to 1.0. Multi-head attention allows the model to simultaneously track syntactic dependencies, coreference, and positional context across parallel subspaces.