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 (demo: http://attentionviz.com), 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(演示地址:http://attentionviz.com),并利用它研究语言和视觉Transformer中的注意力机制。通过多个应用场景及专家反馈,我们验证了该方法在提升模型理解深度、揭示查询-键交互新见解方面的实用价值。