Positional Encoding
Category: Neural Networks & Architectures
A mechanism that injects information about token position into transformer inputs, since self-attention has no inherent notion of order.
Full Explanation
Positional encoding provides transformers with information about the position of tokens in a sequence, since self-attention treats all positions equivalently and has no inherent sense of order. The original Transformer used fixed sinusoidal positional encodings with different frequencies, allowing the model to learn attention patterns based on relative position. Learned positional embeddings, which train a separate embedding for each position, are another common approach used in BERT and GPT-2. More recent methods include Rotary Position Embeddings (RoPE) and ALiBi, which encode relative positions more efficiently and generalize better to unseen sequence lengths. The choice of positional encoding significantly affects a model's ability to handle long sequences and extrapolate to lengths not seen during training. Positional encoding is one of the key design decisions in transformer architectures.
Related Terms
More in Neural Networks & Architectures
Explore More
- AI Tools Library — Discover AI tools related to Positional Encoding
- AI Education — Courses to learn about Neural Networks & Architectures
- AI News — Latest news and updates