Positional Encoding

The same words in a different order can mean something different. A model that receives token vectors needs a way to know where those tokens occur, which positional information provides.

9 sections · 5 questions · 3 coding challenges

1 / 9

How Would a Model Know Which Word Came First?

BOTIE

The same words can describe different events when we change their order. A collection of word representations alone does not distinguish who acted on whom. If our architecture no longer processes tokens one after another, we need another way to make their positions available.

The 2017 Transformer removed recurrence from its sequence-processing architecture and added positional information to token embeddings. Its paper considered learned positions and used a fixed pattern of sine and cosine values in the reported model.

Think of attaching an address to each token's representation. The content says which token is present; the positional information helps identify where it appears. Different position schemes provide different ways to compare addresses, including relative separations. Position is additional information for the model to use, not a guarantee that it will interpret every ordering correctly.

Sources for this history