The 5 Stages of Transformer Computation
Unlike recurrent networks (RNNs) that process word-by-word sequentially, Transformers process all words concurrently. Positional vectors ($\sin$ & $\cos$ frequencies) are added to token embeddings so the model knows word order.
Each token vector is multiplied by three learned projection matrices: $W_Q$ (what it is looking for), $W_K$ (what it contains to match against), and $W_V$ (the actual information payload to pass forward).
The similarity score between Query $i$ and Key $j$ is computed as $q_i \cdot k_j / \sqrt{d_k}$. Softmax turns these raw logits into a rigorous probability distribution that sums to exactly 1.
Multiple attention heads operate in parallel subspaces. One head tracks pronouns (e.g. resolving "it" to "animal"), another tracks direct objects, and another tracks subject-verb agreement.
The aggregated values $\sum \alpha_j V_j$ are added back to the input vector through a skip connection (LayerNorm), followed by a 2-layer Feed-Forward neural network that synthesizes high-level factual knowledge.