Glossary

What is Positional encoding?

In Turkish: Konumsal kodlama · Topic: Models and training

Information added to the vectors of a Transformer model that tells it where each piece of the input sits in the sequence. The attention mechanism does not know order on its own, so the model needs this signal to tell word order apart.

How does it work?

Text is first split into pieces (tokens), and each piece is turned into a vector of numbers. The attention mechanism treats these vectors more like a set than an ordered list, so the position of each word is not known by default. To fix this, a pattern specific to each position is added to the token's vector or fed directly into the attention calculation. The original Transformer paper used fixed sine and cosine patterns; later models popularized learned position vectors and methods based on relative distance, such as RoPE and ALiBi.

Why does it matter?

In language, meaning depends heavily on order: the same words arranged differently say something else. The positional method also affects how well a model can handle texts longer than those it saw in training. That is why discussions of long context windows often come back to this topic.

Example

Without positional encoding, a model could treat 'he ate first, then went for a walk' and its reverse as the same bag of words.

FAQ

Why is positional encoding needed?

A Transformer's attention mechanism weighs each token against the others but has no built-in sense of order. Without position information, sentences made of the same words in a different order could look identical to the model.

Do RNNs use positional encoding too?

Usually not. Recurrent networks read text one piece at a time, so order information comes from the structure itself.

All terms