Transformer models are revolutionizing machine learning, but their inner workings remain mysterious. In this work, we present a new visualization technique designed to help researchers understand the self-attention mechanism in transformers that allows these models to learn rich, contextual relationships between elements of a sequence. The main idea behind our method is to visualize a joint embedding of the query and key vectors used by transformer models to compute attention. Unlike previous attention visualization techniques, our approach enables the analysis of global patterns across multiple input sequences. We create an interactive visualization tool, AttentionViz, based on these joint query-key embeddings, and use it to study attention mechanisms in both language and vision transformers. We demonstrate the utility of our approach in improving model understanding and offering new insights about query-key interactions through several application scenarios and expert feedback.
翻译:Transformer模型正在革新机器学习领域,但其内部工作机制依然神秘。本文提出一种新型可视化技术,旨在帮助研究人员理解Transformer中的自注意力机制——该机制使模型能够学习序列元素之间丰富的上下文关联关系。该方法的核心思想是对Transformer模型用于计算注意力的查询向量和键向量进行联合嵌入可视化。与现有注意力可视化技术不同,我们的方法支持跨多个输入序列的全局模式分析。基于上述查询-键联合嵌入,我们开发了交互式可视化工具AttentionViz,并借助该工具研究语言与视觉Transformer中的注意力机制。通过多个应用场景和专家反馈,我们论证了该方法在提升模型理解深度、揭示查询-键交互新认知方面的实用价值。