Skip to main content
QUICK REVIEW

[论文解读] Towards Mechanistic Interpretability of Graph Transformers via Attention Graphs

Batu El, Deepankar Choudhury|ArXiv.org|Feb 17, 2025
Advanced Graph Neural NetworksComputer Science被引用 3
一句话总结

提出 Attention Graphs 将注意力矩阵汇聚成统一的信息流图,以机械性地解释 Graph Neural Networks 和 Graph Transformers;分析学习到的注意力模式如何随同质性和异质性图的输入图拓扑而变化。

ABSTRACT

We introduce Attention Graphs, a new tool for mechanistic interpretability of Graph Neural Networks (GNNs) and Graph Transformers based on the mathematical equivalence between message passing in GNNs and the self-attention mechanism in Transformers. Attention Graphs aggregate attention matrices across Transformer layers and heads to describe how information flows among input nodes. Through experiments on homophilous and heterophilous node classification tasks, we analyze Attention Graphs from a network science perspective and find that: (1) When Graph Transformers are allowed to learn the optimal graph structure using all-to-all attention among input nodes, the Attention Graphs learned by the model do not tend to correlate with the input/original graph structure; and (2) For heterophilous graphs, different Graph Transformer variants can achieve similar performance while utilising distinct information flow patterns. Open source code: https://github.com/batu-el/understanding-inductive-biases-of-gnns

研究动机与目标

  • 用注意力作为信息流的代理,推动并形式化对 GNNs 与 Graph Transformers 的机械性可解释性。
  • 开发 Attention Graphs,将多头/多层注意力聚合为一个单一、可解释的表示。
  • 研究不同的图感应偏置(稀疏/密集、固定/学习的注意力)如何影响信息流及对输入图结构的依赖,在具有不同同质性的数据集上进行分析。

提出的方法

  • 将 GNN/GT 的信息传递映射到自注意力机制,并为每层/每头定义注意力矩阵。
  • 在注意力的稀疏性(稀疏 vs 稠密)和参数化(常数 vs 学习)的设计空间中,为图变换器定义注意力的设计维度(SC, SL, DLB, DL)。
  • 通过简单平均在头之间聚合得到层级的 A_l。
  • 通过矩阵乘法在层之间聚合 A_Agg = A_L2 A_L1,以捕捉多跳的信息流。
  • 通过阈值化构建并分析 Attention Graphs,将其近似为准邻接矩阵,并使用 F1 分数与输入图比较以评估结构恢复能力。
  • 在七个节点分类数据集上进行实验,覆盖同质性与异质性图,采用 1–2 层、1–2 头,使用 PyTorch TransformerEncoder 实现架构。

实验结果

研究问题

  • RQ1如何将来自多个头和多层的注意力矩阵聚合成一个单一的 Attention Graph,以捕捉 GNNs/GTs 中的信息流?
  • RQ2不同的图变换器感应偏置(SC、SL、DLB、DL)如何影响对输入图结构的依赖以及在同质性与异质性图上的信息流模式?
  • RQ3图变换器是否通过学习的注意力恢复输入图结构,深度对这一过程有何影响?

主要发现

  • 当注意力不受限于输入图时,学习到的信息流在同质性和异质性图上都偏离输入拓扑。
  • 在异质性图上,不同的 GT 变体 achieving 相似的性能但使用不同的信息流模式,表明底层算法多样。
  • DL 模型倾向于将注意力分布到所有节点(密集注意力)并呈现参考节点模式,而 DLB 模型显示出强局部性和自注意力,提示不同的计算策略。
  • DL 模型在恢复输入图结构方面的 F1-score 较低(<4%),而 DLB 模型在中等到较高的 F1-score(28-86%),深度增加时呈现下降。
  • 通过简单平均在头之间聚合有效捕捉整体信息流且不丢失主要信号。
  • 通过矩阵乘法在层之间聚合捕捉间接的多跳信息流,展示信息如何通过连续层传播。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。