Transformers and LLMs

Positional Encoding, explained

Positional encoding gives a transformer information about token order and position.
Back to Glossary

Part of the Semantic Notion technical glossary.

Short Definition

Positional encoding gives a transformer information about token order and position.

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.

Start here

Need the broader concept map?

Return to the glossary index to move from this definition into adjacent AI, ML, mathematics, and computer science terms.