Positional encoding is the technique that gives transformer models information about the order of tokens in a sequence, since the architecture processes all tokens simultaneously rather than sequentially. Without positional encoding, the model would treat «dog bites man» and «man bites dog» as identical. Modern approaches include learned embeddings and rotary positional encoding (RoPE), which enable models to generalize to longer sequences than seen during training.