Positional Encoding
A mechanism in Transformer models that enables the model to perceive the sequential position of tokens. Principal approaches include fixed sinusoidal encoding, learnable absolute position embeddings, and relative position encodings such as RoPE. These approaches differ substantially in their ability to generalize to sequence lengths beyond those seen during training.
Core Facts
RoPE (Rotary Position Embedding) injects positional information into attention computation in the form of a rotation matrix, preserving relative positional relationships across arbitrary sequence lengths.
Positional encoding was first widely used in the Transformer architecture, and its role is to inject the order information of elements in a sequence into the model, because the pure attention mechanism itself is insensitive to order.
Implementing a Transformer from scratch requires understanding and hand-coding components such as the matrix operations for attention weights, positional encoding, residual connections, and layer normalization.
Timeline (last 90 days)
Sparse attention typically reuses position encodings designed for dense attention directly, ignoring that sparsification itself changes the context range each query attends to.
SkinCast's fused features pass through a shared backbone with local-plus-global day-x positional encoding, then through an N-layer Informer decoder that outputs the forecast sequence in a single non-autoregressive pass.
Since attention itself is insensitive to sequence order, the model relies on positional encodings (such as sinusoidal encodings or rotary position embedding RoPE) to inject order information.
This work bridges the gap between empirical observation and theoretical explanation, providing computable theoretical guidance for the choice of positional encoding.
The paper proposes a "position realizability theory" to explain the dependence of length generalization on positional encoding and derives widely documented empirical patterns.
Hand-computing the 6×512 positional encoding table helps one understand how the combination of sine and cosine lets the model distinguish different positions without learning a separate vector for each position.
For Transformers, mechanisms such as positional encoding and attention masking may fail beyond the training length.
DDPM adopts the sinusoidal positional encoding from the Transformer, converting the time step t into a high-dimensional vector, then mapping it through two fully connected layers to a dimension matching the number of feature map channels, and finally modulating the features of each layer by element-wise addition or FiLM.
In the diffusion model, the time step t is converted into a vector via sine-cosine encoding similar to Transformer positional encoding, and then fused with the image features.
Tiny models like DinoGPT typically use learnable positional embeddings, with the parameter count equal to the maximum sequence length multiplied by the hidden dimension.
11 more timeline events
All Facts (20)
RoPE (Rotary Position Embedding) injects positional information into attention computation in the form of a rotation matrix, preserving relative positional relationships across arbitrary sequence lengths.
80%VerifiedPositional encoding was first widely used in the Transformer architecture, and its role is to inject the order information of elements in a sequence into the model, because the pure attention mechanism itself is insensitive to order.
75%VerifiedImplementing a Transformer from scratch requires understanding and hand-coding components such as the matrix operations for attention weights, positional encoding, residual connections, and layer normalization.
70%VerifiedBecause the Transformer self-attention mechanism exhibits positional bias, earlier input content has a stronger anchoring effect on subsequent generation, which is the underlying reason for the context anchoring effect of system prompts
65%UnverifiedFor Transformers, mechanisms such as positional encoding and attention masking may fail beyond the training length.
70%UnverifiedThe context window is the maximum number of tokens a time-series foundation model (and all Transformer-based models) can process in a single forward computation, jointly determined by the positional encoding in the model architecture and the complexity of the attention mechanism; the window size is a hyperparameter fixed at training time and cannot be extended at inference.
70%UnverifiedPositional encoding is used to inject word order information into the model, because the attention mechanism itself does not distinguish positional order.
60%UnverifiedPositional encoding has evolved from fixed sinusoidal encoding (original paper) to learnable absolute positional encoding (BERT) and then to Rotary Position Embedding RoPE (LLaMA, Qwen).
60%UnverifiedSparse attention typically reuses position encodings designed for dense attention directly, ignoring that sparsification itself changes the context range each query attends to.
50%UnverifiedSkinCast's fused features pass through a shared backbone with local-plus-global day-x positional encoding, then through an N-layer Informer decoder that outputs the forecast sequence in a single non-autoregressive pass.
50%UnverifiedSince attention itself is insensitive to sequence order, the model relies on positional encodings (such as sinusoidal encodings or rotary position embedding RoPE) to inject order information.
50%UnverifiedThe paper proposes a "position realizability theory" to explain the dependence of length generalization on positional encoding and derives widely documented empirical patterns.
50%UnverifiedThis work bridges the gap between empirical observation and theoretical explanation, providing computable theoretical guidance for the choice of positional encoding.
50%UnverifiedHand-computing the 6×512 positional encoding table helps one understand how the combination of sine and cosine lets the model distinguish different positions without learning a separate vector for each position.
50%UnverifiedDDPM adopts the sinusoidal positional encoding from the Transformer, converting the time step t into a high-dimensional vector, then mapping it through two fully connected layers to a dimension matching the number of feature map channels, and finally modulating the features of each layer by element-wise addition or FiLM.
50%UnverifiedIn the diffusion model, the time step t is converted into a vector via sine-cosine encoding similar to Transformer positional encoding, and then fused with the image features.
50%UnverifiedTiny models like DinoGPT typically use learnable positional embeddings, with the parameter count equal to the maximum sequence length multiplied by the hidden dimension.
50%UnverifiedPositional encoding should be added to the embedding, not concatenated.
50%UnverifiedThe performance decline caused by 'lost in the middle' follows a U-shaped curve rather than linear decay; its mechanism may be related to Transformer attention allocation and positional encoding.
50%UnverifiedThe causes of the lost-in-the-middle phenomenon are usually attributed to the decay effect of positional encoding, the fact that beginning and end content in training data is more often associated with answers, and the dilution of the attention softmax over long sequences.
50%