研究大模型如何用注意力处理图数据,发现其对拓扑关系建模有局限。
Attention Mechanisms Perspective: Exploring LLM Processing of Graph-Structured Data
- 从注意力机制视角分析LLM处理图数据的行为模式。
- 模型难以捕捉节点间拓扑关系,注意力分布不匹配理想结构。
- 中间状态注意力窗口比全连接或固定连接更优,适合训练与推理。
注意力机制是大型语言模型(LLMs)成功的关键,推动了多个领域的进步。然而,对于依赖拓扑连接的图结构数据,注意力机制相较于图神经网络(GNNs)所采用的固定链接消息传递机制表现不足。这引发疑问:‘在自然语言场景中,注意力机制是否对图数据失效?’ 基于此,我们从注意力机制角度展开实证研究,探索LLM如何处理图结构数据,以深入理解其注意力行为。研究发现:1)尽管LLM能识别图数据并捕捉文本-节点交互,但受架构限制,难以建模节点间的内部关系;2)LLM在图节点间的注意力分布与理想结构模式不一致,表明其未能适应图拓扑细节;3)全连接注意力与固定连接均非最优,中间状态注意力窗口在训练中提升性能,并可在推理时平滑过渡至全连接形式。代码开源:LLM4Exploration。
原文摘要 · Abstract (English)
Attention mechanisms are critical to the success of large language models (LLMs), driving significant advancements in multiple fields. However, for graph-structured data, which requires emphasis on topological connections, they fall short compared to message-passing mechanisms on fixed links, such as those employed by Graph Neural Networks (GNNs). This raises a question: ``Does attention fail for graphs in natural language settings?'' Motivated by these observations, we embarked on an empirical study from the perspective of attention mechanisms to explore how LLMs process graph-structured data. The goal is to gain deeper insights into the attention behavior of LLMs over graph structures. We uncovered unique phenomena regarding how LLMs apply attention to graph-structured data and analyzed these findings to improve the modeling of such data by LLMs. The primary findings of our research are: 1) While LLMs can recognize graph data and capture text-node interactions, they struggle to model inter-node relationships within graph structures due to inherent architectural constraints. 2) The attention distribution of LLMs across graph nodes does not align with ideal structural patterns, indicating a failure to adapt to graph topology nuances. 3) Neither fully connected attention nor fixed connectivity is optimal; each has specific limitations in its application scenarios. Instead, intermediate-state attention windows improve LLM training performance and seamlessly transition to fully connected windows during inference. Source code: \href{https://github.com/millioniron/LLM_exploration}{LLM4Exploration}
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。