Graphs / Architecture
verifiedGraph Transformer
If message passing is limited by the edges it is given, let every node attend to every other and put the structure back in as a bias on the scores. A graph transformer does that: full attention, with the graph entering through how far apart two nodes are rather than through whether they are connected at all.
Structure arrives as encodings rather than as masking — shortest-path distance added to the attention score, edge features along that path, degree folded into the input. This escapes the WL bound and the oversmoothing ceiling in one move, and pays for both in quadratic cost, which is why it wins on molecules with tens of atoms and struggles on graphs with millions of nodes.
Score(u,v) = (h sub u W sub Q )(h sub v W sub K ) super T /√d + b sub φ(u,v) where φ is the shortest-path distance and b is a learned scalar per distance. Because b is learned rather than fixed at −∞ for non-edges, a pair with no edge is discouraged rather than forbidden — the difference between a bias and a mask, and the whole reason the architecture is more expressive.
12 queries against 12 keys; a brighter cell means more of that query's attention went to that key. Nothing is masked: every position can read every other, itself included. The first key takes 23% of the average row on its own.
Every node against every other, plus one virtual node joined to all of them. Drag the virtual node's pull up to watch traffic route through it — a graph transformer adds exactly such a node, which is how two distant nodes reach each other in a single hop.
Reviewed by opendroid · 2026-08-18
- arXiv:2106.05234 — Do Transformers Really Perform Bad for Graph Representation?