Token embeddings capture what a token means, but not where it appears. Positional embedding adds sequence-position information so a transformer can distinguish identical tokens in different locations while preserving useful semantic similarity. section 2.3.1 section 2.1.1
Separating similar words by position
In “The cat in the hat rapidly leapt above the red fox and the brown unmotivated dog,” “red” and “brown” are semantically similar but occur at positions 10 and 14. Encoding separates their representations, while sine and cosine transformations restore much of their similarity. section 2.3.1
The technique works alongside embeddings and self-attention, allowing encoder models such as BERT to manipulate token vectors without losing the semantic comparisons established during embedding. section 2.3.1
Figure 2.5 An encoder visualized. Encoders are the first half of the full transformer architecture and excel in natural language understanding tasks like classification or named entity recognition. Encoder models improve upon previous designs by not requiring priors or recurrence and using clever positional encoding and multihead attention to create a vector embedding of each token.
Use the encoder diagram to see positional encoding placed among token embeddings and multihead attention. section 2.3.1











