The Self-Attention Equation
Self-attention allows every token in a sequence to dynamically attend to every other token. It computes $Attention(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V$. The $\sqrt{d_k}$ scaling factor prevents dot products from growing excessively large in high dimensions, which would push softmax gradients into vanishing regions.
Rotary Position Embeddings (RoPE)
Unlike absolute positional embeddings added to input vectors, RoPE rotates Query and Key representations in the complex plane based on token positions. This preserves relative distance properties and enables context window extrapolation.