How Vision Transformers Represent Position: A Mechanistic Comparison of Absolute and Rotary Positional Encodings
Mahmoud Mannes, Nikhil Maturi, Parva Mehta, Jiwon Jeong, Aravind Singaram Kannappan
Abstract
Positional embeddings encode the spatial position of each image patch in a Vision Transformer (ViT), allowing the model to distinguish different spatial arrangements of visual content. However, we know little about how the choice of embedding shapes a vision transformer's internal representation. In this work, we show that Absolute Positional Embeddings (APE) and Rotary Positional Embeddings (RoPE) encode spatial position through different internal mechanisms: APE stores position in explicit features, while RoPE builds it inside attention and rebuilds it when it is withheld. Specifically, in APE models, sparse autoencoders recover causal row- and column-specific features, whereas interventions on RoPE reveal distinct rotary components that separately encode row and column information. Additionally, causal interventions selectively disabling RoPE's row or column rotations show that decodable row and column information can be independently removed and, once rotations are restored, partly reconstructed, in part by axis-specialized attention heads. Both mechanisms are causally important for classification: permuting APE's positional features across patches reduces top-1 accuracy by 24--31 points, and ablating the rotations of RoPE's primary rebuilding head reduces it more than ablating those of any other head. Our findings show that the choice of positional encoding fundamentally changes how spatial information is organized and processed inside Vision Transformers. More broadly, our work demonstrates how mechanistic analysis can reveal how models construct, reconstruct, and maintain structured representations, providing a basis for targeted interventions in vision models.
Create a lesson
Metadata
- Categories
- cs.CV, cs.LG
Related papers
Focus Only on What's Important: Training-Free Focus Maps for Frozen Vision Transformers in Long-Video Object Segmentation
Shared title terminologycs.CVHarsha Karipineni, Rajesh Reddy Chintha
Geometric Encoding for Spatial Reasoning in Vision-Language Models
Shared title terminologycs.CVAntonio Jun, Haoshui Yu, Zhengyi Lu et al.
Position Aware Layer Queries for Test Time Training in Vision Language Models
Shared title terminologycs.CVRajat Modi, Priyank Pathak, Xin Liang et al.
Focus and Supplement: Dual-Enhanced Vision Transformer for Multi-Class Anomaly Classification
Shared title terminologycs.CVXurui Li, Enjie Xu, Chenzhou Li et al.
FOCUS: Benchmarking Retinal Model Generalization from Foundation Vision Encoders to Multimodal LLMs
Shared title terminologycs.CVDavid Restrepo, Chenwei Wu, Luis Filipe Nakayama et al.
Rethinking the Fully Hyperbolic Vision Transformer in Polar Coordinates
Shared title terminologycs.CVAhmad Bdeir, Niels Landwehr