Positional information identifies where each token occurs in a sequence. Because self-attention and token embeddings are position-independent, adding it helps the model represent order and token relationships. section 2.8
Use two broad positional-embedding strategies:
- Absolute positional embeddings assign a distinct learned vector to each sequence position and add it to the token embedding. section 2.8
- Relative positional embeddings represent distances between tokens, supporting generalization to sequence lengths not seen during training. section 2.8
Combining token and positional embeddings
For inputs shaped [8, 4], a token embedding layer produces [8, 4, 256]. A positional embedding layer produces [4, 256]; broadcasting and addition yield [8, 4, 256] input embeddings for the LLM layers. section 2.8
Figure 2.18 Positional embeddings are added to the token embedding vector to create the input embeddings for an LLM. The positional vectors have the same dimension as the original token embeddings. The token embeddings are shown with value 1 for simplicity.
Visualizes positional vectors matching token-embedding dimensions and being added to form input embeddings. section 2.8







