liveBook · Manning

Positional embedding

As explained in Machine Learning Algorithms in Depth

A positional encoding is a representation added to token embeddings to convey a token's position in a sequence.

Positional embeddings inject token-position information into transformers, whose attention mechanism otherwise needs explicit sequence-order information. They are added to input token embeddings in both encoder and decoder stacks. section 11.3

The construction follows three constraints:

  • Match the embedding dimensions so positional and token representations can be summed. section 11.3
  • Make an identical word’s representation differ when its sequence position changes. section 11.3
  • Support order-aware processing alongside self-attention, multihead attention, residual connections, and normalization layers. section 11.3
Figure 11.10 Transformer architecture
figure

The transformer architecture diagram locates positional encodings at the input bottoms of the encoder and decoder stacks. section 11.3

How Machine Learning Algorithms in Depth covers it

How deep it goes
Explains purpose, placement, dimensional compatibility, and summation, but does not specify an encoding formula or implementation.
Examples
Uses encoder-decoder transformer stacks and the same word appearing at different sentence positions as illustrations.
What it assumes
Assumes familiarity with token embeddings and transformer attention while leaving encoding construction unexplained.
What you can do after
Evaluate how transformers preserve sequence order when attention processes token representations.
How it connects
Connects token embeddings with self-attention, multihead attention, transformers, encoder-decoder architecture, and layer normalization.

Also explained in

Compare how 12 books explain positional embedding →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Algorithms in Depth. The section links point to the parts of the book it draws on.