Learned Position Embeddings › Analyzing Real Position Embeddings
Language AI HandbookAll chapters Learned Position Embeddings › Analyzing Real Position EmbeddingsOne section · Sections in this chapter12 / 19 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
When researchers analyze trained position embeddings from models like GPT-2 and BERT, several patterns emerge consistently. Understanding these empirical properties helps build intuition about what learned embeddings represent.
Low-rank structure. The 768-dimensional position embeddings can often be approximated well by a much lower-dimensional subspace. The first 50-100 principal components typically capture most of the variance. This suggests that despite living in a high-dimensional space, the effective information content of position embeddings is much lower. The extra dimensions provide capacity for task-specific adjustments during training, but the core positional structure is low-dimensional.
Smooth interpolation. Adjacent positions have similar embeddings, and this similarity decreases smoothly with distance. The embeddings form a continuous manifold in the embedding space, which is the geometric property that makes position interpolation possible.
Boundary effects. The first few positions (0, 1, 2) and positions near sometimes show different patterns, possibly because they are encountered in distinct contexts during training. Position 0 always corresponds to special tokens like [CLS] in BERT or the beginning of a document in GPT, giving it atypical statistics. Positions near are rare in training data if most documents are shorter than the maximum length.
Similarity to sinusoidal encodings. When you project trained position embeddings onto their principal components, the resulting patterns often look qualitatively similar to sinusoidal encodings at different frequencies. This convergence happens because sinusoidal patterns are efficient at encoding position in a way that supports the training objectives, and gradient descent discovers this even without the patterns being designed in.
Let's visualize the low-rank structure:
from numpy.linalg import svd
def analyze_position_embedding_rank(embeddings):
"""Analyze the effective rank of position embeddings via SVD."""
U, S, Vt = svd(embeddings, full_matrices=False)
# Compute cumulative explained variance
total_var = np.sum(S**2)
cumulative_var = np.cumsum(S**2) / total_var
return S, cumulative_var
# Analyze our simulated trained embeddings
singular_values, cumulative_var = analyze_position_embedding_rank(
trained_embeddings
)

The rapid decay of singular values confirms the low-rank structure. Most of the information in position embeddings can be captured by a handful of principal components. This suggests that positions are fundamentally simple, even though we represent them in high-dimensional space. The extra dimensions provide capacity for task-specific adjustments during training, but the core positional geometry is low-dimensional.