A positional embedding encodes an element’s location in a sequence and combines that information with its content representation. Transformers need this because attention compares sequence elements without inherently noticing whether a word comes first, last, or somewhere in the middle. section 15.3.4 section 15.3.5
A positional embedding layer typically works as follows:
- Represent each token with a learned word vector. section 15.3.5
- Add each position vector to its corresponding token vector to produce a position-aware representation. section 15.3.5
Transformer translation
A translation Transformer applies the positional embedding layer to both English source tokens and Spanish target tokens before passing them to the encoder and decoder. Training uses Adam, sparse categorical cross-entropy, and weighted accuracy; adding positional information produced 67% next-word accuracy. section 15.3.5











