Towards Mechanistic Interpretability of Graph Transformers via Attention Graphs

Batu El, Deepro Choudhury, Pietro Liò, Chaitanya K. Joshi
2/17/2025
cs.LGcs.AI

Official code: batu-el/understanding-inductive-biases-of-gnns (30 stars, last commit 2025-03-02).

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

View on arXivView PDF

Code Implementations(1)

Geometric Deep Learning @ University of Cambridge

305Jupyter NotebookDec 18, 20231 years ago

Similar Papers

Cite this paper

@article{el2025towards,
  title  = {Towards Mechanistic Interpretability of Graph Transformers via Attention Graphs},
  author = {Batu El and Deepro Choudhury and Pietro Liò and Chaitanya K. Joshi},
  year   = {2025},
  eprint = {2502.12352},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.12352v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.12352.svg)](https://codeofpaper.com/paper/2502.12352)

Discussion