Explainer
Positional encoding
Information about where each token sits, added so a model can use word order.
Attention compares tokens by what they contain. “The dog chased the cat” and “the cat chased the dog” hold the same tokens in a different order, and the order carries the meaning. The original Transformer paper says the model “must inject some information about the relative or absolute position of the tokens” (Vaswani et al., 2017). That design added a fixed pattern of numbers for each position to each token's embedding, the list of numbers that represents the token. The general idea is positional encoding, also called position embedding or positional embedding.
Many current open models use rotary position embedding, RoPE, instead. Rather than adding a pattern, RoPE turns each query and key by an angle that depends on the token's position, so a comparison between two tokens also reflects how far apart they are (RoFormer paper). One survey of recent architectures notes that positional embeddings “have evolved from absolute to rotational (RoPE)” (Raschka's architecture comparison). Positional encoding is not the token's ID, which says which token it is, and not the “lost in the middle” effect, which is a behaviour (Claimed and effective context length).
Going deeper
The position method affects how far a model can stretch. YaRN's authors note that RoPE models “fail to generalize past the sequence length they were trained on” and give a way to extend them (YaRN). gpt-oss-20b's configuration records "rope_type": "yarn" with an original length of 4,096 positions (its configuration file). ALiBi instead lowers attention scores in proportion to distance (ALiBi), and one study found decoder-only models with no explicit position information (NoPE) generalized to longer inputs better on its tasks (Kazemnejad et al.).
In the long read: how position gets in.