arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2610.13992cs.CVcs.LG
收藏

视觉Transformer如何表示位置:绝对与旋转位置编码的机制对比

How Vision Transformers Represent Position: A Mechanistic Comparison of Absolute and Rotary Positional Encodings

ESSTHS;DJSCE;Lotte Innovate(乐天创新);New York University(纽约大学)

Mahmoud Mannes, Nikhil Maturi, Parva Mehta, Jiwon Jeong, Aravind Singaram Kannappan

AI总结:

本研究对比了视觉Transformer中绝对位置编码(APE)与旋转位置编码(RoPE)的位置表征机制,发现二者编码方式不同,且均对分类准确率有关键作用,为视觉模型的针对性干预提供了基础。

摘要:

位置编码对视觉Transformer(ViT)中每个图像块的空间位置进行编码,使模型能够区分视觉内容的不同空间排列。然而,我们对编码方式的选择如何影响视觉Transformer的内部表征知之甚少。本研究表明,绝对位置编码(APE)和旋转位置编码(RoPE)通过不同的内部机制对空间位置进行编码:APE将位置存储在显式特征中,而RoPE则在注意力机制内部构建位置,并在位置被隐藏时重建它。具体而言,在APE模型中,稀疏自编码器可恢复特定于行和列的因果特征;而对RoPE的干预则会揭示出分别编码行和列信息的不同旋转分量。此外,通过因果干预选择性禁用RoPE的行或列旋转,结果显示可独立移除可解码的行和列信息,且在旋转恢复后,部分信息可通过轴专用注意力头重建。两种机制对分类均具有因果重要性:对图像块间APE的位置特征进行置换会使Top-1准确率降低24至31个百分点,而对RoPE主要重建头的旋转进行消融,其准确率下降幅度超过对其他任何头的消融。本研究结果表明,位置编码的选择从根本上改变了视觉Transformer内部空间信息的组织与处理方式。更广泛而言,本研究证明了机制分析如何揭示模型如何构建、重建和维持结构化表征,为视觉模型的针对性干预提供了基础。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑