Positional embedding represents where an item occurs in a sequence and combines that signal with the item’s content representation. This matters because self-attention processes tokens simultaneously: without position information, “The dog bit the man” and “The man bit the dog” look alike. section 11.15
A sinusoidal positional encoding assigns each position a vector of sine and cosine values. Every position receives a distinct pattern, while nearby positions receive similar patterns; the vector width can be adjusted to the model’s embedding width. section 11.15
Combining meaning and location
For a token at position 1, a four-value positional vector can be [0.8415, 0.5403, 0.0100, 1.0000]. Adding it element by element to the token embedding produces one vector containing both what the token means and where it occurs. For example, [-0.008, 0.005, -0.002, 0.009] becomes [0.8335, 0.5453, 0.0080, 1.0090]. section 11.16
A simple implementation follows this sequence:
- Look up each token’s embedding, add its positional row, and pass the resulting matrix into the Transformer. section 11.16
The same sinusoidal idea can represent a diffusion model’s timestep. Encoding a value such as t = 22 creates a vector that tells the model how much noise is present, so it can adjust denoising strength. section 12.10
Figure 11.29 An odometer analogy showing how sinusoidal positional encoding works
Use the odometer analogy to see how several changing numerical signals can jointly identify a sequence position. section 11.15











