What is the difference between absolute and relative positional encodings?
Last updated
Absolute encodings tag each token with its own index once at the input. The model must infer distance indirectly, and this extrapolates poorly beyond training length.
Relative encodings make attention depend on the offset i - j inside every layer. Examples: Shaw et al. embeddings, T5 bias buckets, ALiBi linear penalty, and RoPE rotations.
Relative schemes give translation invariance, better length generalization and fit KV caching. Some variants cost extra compute or break fused attention kernels.