arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2405.14880cs.CVcs.AI
收藏

剖析视觉Transformer中的查询-键交互

Dissecting Query-Key Interaction in Vision Transformers

University of Miami(迈阿密大学);Harvard University(哈佛大学);Michigan State University(密歇根州立大学);University of Texas Health Science Center at Houston(休斯顿德克萨斯大学健康科学中心)

Xu Pan, Aaron Philip, Ziqian Xie, Odelia Schwartz

AI总结:

本研究通过奇异值分解分析视觉Transformer的查询-键交互,发现早期层侧重相似令牌感知分组、后期层侧重异令牌语境化,且交互具语义可解释性,为注意力机制解读提供新视角。

摘要:

视觉Transformer中的自注意力通常被认为执行感知分组,即令牌会关注嵌入相似的其他令牌,这些令牌可能对应物体的语义相似特征。然而,关注不相似的令牌也能通过提供上下文信息带来益处。我们提出通过交互矩阵(即${\textbf{W}_q}^\top\textbf{W}_k$)的奇异值分解来分析查询-键交互。我们发现,在许多视觉Transformer(ViT)中,尤其是采用分类训练目标的模型,早期层更关注相似令牌,而后期层对不相似令牌的关注度有所提升,这分别为感知分组和语境化提供了对应证据。奇异向量所代表特征之间的许多此类交互具备可解释性和语义性,例如相关物体之间、物体各部分之间或前景与背景之间的注意力。这为解释注意力机制提供了全新视角,有助于理解Transformer模型在处理图像时如何利用上下文和显著特征。

英文摘要:

Self-attention in vision transformers is often thought to perform perceptual grouping where tokens attend to other tokens with similar embeddings, which could correspond to semantically similar features of an object. However, attending to dissimilar tokens can be beneficial by providing contextual information. We propose to analyze the query-key interaction by the singular value decomposition of the interaction matrix (i.e. ${\textbf{W}_q}^\top\textbf{W}_k$). We find that in many ViTs, especially those with classification training objectives, early layers attend more to similar tokens, while late layers show increased attention to dissimilar tokens, providing evidence corresponding to perceptual grouping and contextualization, respectively. Many of these interactions between features represented by singular vectors are interpretable and semantic, such as attention between relevant objects, between parts of an object, or between the foreground and background. This offers a novel perspective on interpreting the attention mechanism, which contributes to understanding how transformer models utilize context and salient features when processing images.

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

↑