用可解释的结构掩码让Transformer更好处理图数据
X-LogSMask: Expand Transformer for Graph-Structured Data

- 引入对数结构掩码,直接将图拓扑注入注意力权重
- 20个基准上13个达顶尖性能,单层配置也表现优异
- 方法简单可解释,适合想提升图神经网络效果的研究者
Transformer已成为通用架构,但其全连接自注意力机制与图数据稀疏、结构化和多尺度的特性不匹配。现有图Transformer通过结构编码、混合消息传递模块或学习注意力约束来缓解此问题,常引入额外复杂性且可解释性差。本文提出X-LogSMask,一种可解释的多头对数结构掩码,将对称归一化的图拓扑直接注入注意力得分。对数变换将结构连通性转化为拓扑感知门控信号,抑制无效节点交互同时保留特征依赖注意力。通过为不同注意力头分配归一化邻接矩阵的不同幂次,每个头具有明确的结构半径,支持单层内多跳信息传播。我们进一步表明,标准Transformer编码器可视为在完全图上的一步消息传递,从而将X-LogSMask作为无约束自注意力的拓扑约束替代方案。在20个节点级、边级和图级基准上,配备X-LogSMask的Transformer在13个数据集上达到最先进性能,在轻量单层配置下仍具竞争力。结果表明,简单的可解释结构掩码可在不修改Transformer架构的前提下,使自注意力成为有效的图学习算子。代码已开源。
原文摘要 · Abstract (English)
Transformers have become general-purpose architectures, but their all-to-all self-attention is poorly matched to graph data, whose interactions are sparse, structured and multi-scale. Existing Graph Transformers address this mismatch through structural encodings, hybrid message-passing modules or learned attention constraints, often introducing additional complexity and limited interpretability. Here we introduce X-LogSMask, an explainable multi-head logarithmic structural mask that injects symmetrically normalized graph topology directly into attention logits. The logarithmic transform converts structural connectivity into a topology-aware gating signal, suppressing unsupported node interactions while preserving feature-dependent attention. By assigning different powers of the normalized adjacency matrix to different attention heads, X-LogSMask gives each head a defined structural radius and supports multi-hop information propagation within a single layer. We further show that a standard Transformer encoder can be interpreted as one-step message passing on a complete graph, motivating X-LogSMask as a topology-constrained alternative to unrestricted self-attention. Across 20 node-, edge- and graph-level benchmarks, Transformers equipped with X-LogSMask achieve state-of-the-art performance on 13 datasets and remain competitive in a lightweight one-layer configuration. These results show that simple, interpretable structural masks can make self-attention an effective graph-learning operator without changing the Transformer architecture. The code is available at https://github.com/LiLeyan-0120/X-LogSMask.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。