arXiv:2606.00124cs.CVcs.LG2026-06

位置编码让视觉Transformer更抗干扰,靠的是稳定的空间参考框架。

Positional Encodings Anchor Spatial Structure in Vision Transformers: A Geometric Perspective on Robustness

  • 用空间相似性相关度衡量注意力图中的空间结构
  • 有位置编码的模型在打乱像素后仍保持空间结构,抗干扰更强
  • 只要具备稳定的位置参照,不同编码方式效果相近

视觉变换器(ViTs)中的位置嵌入(PEs)影响模型性能与鲁棒性,但其如何塑造内部空间表征尚不明确。本文提出一种新度量——空间相似性距离相关性(SSDC),用于量化标记表示中的空间结构。结果表明,无位置编码的ViTs虽能形成非平凡的空间结构,但该结构依赖视觉内容且在标记置换下会崩溃;而所有考虑的位置编码(学习型绝对编码、正弦编码、旋转编码)均促使表示向以索引为锚点的空间组织转变。这类模型在破坏内容的分布偏移下仍保持稳定,鲁棒性显著提升。进一步发现,尽管不同编码方式导致空间结构在深度上轨迹各异,但其鲁棒性表现基本一致(仅存在次要差异),说明鲁棒性更依赖于稳定的定位参考系,而非具体编码机制。研究为位置编码如何塑造内部表示提供了几何解释,对今后编码方案的设计具有指导意义。

原文摘要 · Abstract (English)

Positional embeddings (PEs) in Vision Transformers (ViTs) are known to impact performance and robustness, but their role in shaping internal spatial representations is not well understood. In this work, we study how different forms of PEs influence the representational geometry of ViTs and how these changes relate to robustness under content-disrupting distribution shifts. We introduce a metric, the Spatial Similarity Distance Correlation (SSDC), to quantify spatial structure in token representations. Using this metric, we show that ViTs trained without PEs still develop non-trivial spatial structure, but this structure is driven by visual content and collapses under token permutation. In contrast, we find that all PEs considered (learned absolute, sinusoidal, and rotary) are associated with a consistent shift toward an index-anchored spatial organization. Representations in these models remain stable under perturbations that disrupt content, and exhibit substantially improved robustness to such distributional shifts. We further show that while different PEs produce distinct depth-wise trajectories of spatial structure, their robustness properties are largely similar (with secondary variation across encoding schemes), suggesting that robustness appears to depend on the presence of a stable positional reference frame more than it depends on the specific encoding mechanism. These results offer a geometric account of how positional encodings shape internal representations, with implications for the principled design of future encoding schemes.

视觉Transformer位置编码鲁棒性空间结构

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。