Definition
Since transformers process all tokens in parallel rather than sequentially like RNNs, they lack inherent knowledge of token order. Positional encoding adds specific vectors to input embeddings to preserve sequence information. Common methods include sinusoidal functions learned during training or learned embeddings. This allows the self-attention mechanism to weigh the importance of different tokens based on their position, enabling the model to understand syntax and context effectively.
Summary
A technique that injects information about the relative or absolute position of tokens in a sequence into transformer models.
Key Concepts
- Sequence Order
- Self-Attention
- Sinusoidal Functions
- Token Embeddings
Use Cases
- Machine Translation
- Text Summarization
- Language Modeling
Code Example
| |