Positional Encoding

Positional encoding gives a transformer information about token order and position.
Also known as
position embedding

Intuition

Attention can compare tokens, but by itself it does not know which token came first. Positional information adds that ordering signal.

Technical definition

Positional encoding injects absolute or relative position information into token representations or attention computations.

Example

Sinusoidal encodings add position-dependent vectors to token embeddings before attention layers.

Common misunderstandings

  • There are many positional encoding methods, not only the original sinusoidal approach.
  • Position handling matters more as context length and sequence structure become important.

Need this inside a product?

The studio builds the systems these terms describe. Tell us what you are working on.