Artificial Intelligence

Positional Encoding

A technique used in transformers to inject information about the position of each token in a sequence. Since transformers process all tokens in parallel, they need explicit position information.

Why It Matters

Without positional encoding, a transformer would treat 'the dog bit the man' and 'the man bit the dog' identically. Position information is essential for language understanding.

Example

Adding sinusoidal position values to token embeddings so that the model knows that 'cat' is the 3rd word in one sentence but the 7th word in another.

Think of it like...

Like page numbers in a book — the words alone do not tell you what order they are in, so you need an explicit numbering system to maintain sequence.

Related Terms