Unlike Recurrent Neural Networks (RNNs) that process word by word sequentially, Transformers ingest the entire sequence simultaneously. Every token computes direct pairwise relationships with all other tokens via Query-Key-Value interactions.
QK^T computes similarity; V routes information.
2. Positional Encodings
Because self-attention is permutation-invariant (order-blind), deterministic sinusoidal frequencies or learned positional embeddings are added directly to the input vectors so the network understands word order.
PE(pos, 2i) = sin(pos / 10000^{2i/d})
3. Residual Highways & MLPs
Skip connections allow gradients to flow cleanly through hundreds of layers without vanishing. Each attention step aggregates cross-token relationships, while the two-layer MLP retrieves factual knowledge stored in network weights.