Graph Neural Networks (GNNs) have long been the standard for learning on graph-structured data. However, as Transformers have dominated natural language processing and computer vision, researchers have naturally tried to adapt them for graphs. The challenge is that graphs are inherently non-sequential. To bridge this gap, most existing "Graph Transformers" introduce heavy architectural modifications: they bake in message-passing layers, restrict attention to local neighborhoods, or inject complex graph-specific biases into the attention matrix.
While effective, these modifications come with significant costs. They often inherit GNN-specific problems like "oversmoothing," make the models harder to integrate into multi-modal architectures (like those combining text and graphs), and prevent the use of standard Transformer optimization tricks like linear-time attention.
This raises a compelling question: Can we treat a graph exactly like a sentence or an image and still achieve state-of-the-art results?
This paper demonstrates that a "pure" Transformer—one without any graph-specific architectural modifications—can indeed outperform standard GNNs and compete with specialized Graph Transformers. By treating nodes and edges as independent tokens and augmenting them with smart identifiers, the authors prove that a vanilla Transformer can effectively learn graph structures from scratch.
The TokenGT Approach
The authors introduce TokenGT (Tokenized Graph Transformer). The core idea is to simplify the input representation so a standard Transformer encoder (identical to the one used in BERT or ViT) can understand it without specialized attention masks or graph-specific layers.
The tokenization process works as follows:
- Independent Tokens: Every node $v$ and every edge $(u, v)$ in the graph is treated as an independent token. If a graph has $n$ nodes and $m$ edges, the Transformer receives a flat sequence of $n + m$ tokens.
- Node Identifiers: To help the model "see" the connectivity, each node is assigned a unique, orthonormal vector $P$.
- A node token is augmented with $[P_v, P_v]$.
- An edge token connecting nodes $u$ and $v$ is augmented with $[P_u, P_v]$.
- Type Identifiers: A simple trainable embedding is added to distinguish whether a token represents a node or an edge.
Why This Works: Connectivity via Dot Products
Because the node identifiers are orthonormal (meaning their dot product is $1$ if they are the same and $0$ otherwise), the Transformer's internal dot-product attention can mathematically "reconstruct" the graph. For example, an edge token $[P_u, P_v]$ can easily identify its endpoints by looking for node tokens with matching identifiers.
The authors prove that TokenGT is theoretically at least as expressive as a 2-order Invariant Graph Network (2-IGN). This means it is theoretically more powerful than all standard message-passing GNNs and can pass the 2-dimensional Weisfeiler-Lehman (WL) graph isomorphism test.
Furthermore, the paper argues that while GNNs have a "hard" inductive bias (they are strictly forced to follow the graph structure), a pure Transformer has a "weak" bias but higher capacity. Given enough data, the Transformer learns a "soft" version of the graph structure that is more flexible and often more effective.
Key Results
The primary benchmark used is PCQM4Mv2, a large-scale quantum chemistry dataset containing 3.7 million molecular graphs. This massive scale is crucial because Transformers typically require large amounts of data to overcome their lack of hard inductive biases.
- Outperforming GNNs: TokenGT (using Laplacian eigenvectors as node identifiers) achieved a Mean Absolute Error (MAE) of 0.0910, significantly beating standard GNN baselines like GIN-VN (0.1083) and GCN-VN (0.1153).
- Competitive with Specialized Models: TokenGT performed similarly to highly specialized, graph-aware architectures like Graphormer (0.0864) and EGT (0.0869).
- The Representation Bottleneck: A vanilla Transformer with no identifiers performs terribly (0.2340 MAE). Simply adding the orthonormal identifiers brings the error down to 0.0962, proving that the model's bottleneck wasn't the architecture itself, but how the input was represented.
- Linear Attention Compatibility: Because the architecture is "pure," the authors successfully swapped standard $O(N^2)$ attention for Performer (kernel-based) attention. This achieved linear scaling with only a minor drop in accuracy—a feat much harder to accomplish with models relying on complex attention biases.
Limitations and Future Directions
While TokenGT is a significant step forward for pure graph transformers, it has limitations. Treating both nodes and edges as tokens makes the input sequence quite long ($n+m$). For very dense graphs, the quadratic cost of standard attention becomes a significant computational bottleneck.
Additionally, while Laplacian eigenvectors work well as node identifiers, they are computationally expensive to calculate for massive graphs. Finding more efficient or fully learnable node identifiers remains a key area for future research. Finally, while highly competitive, TokenGT is still slightly behind the absolute state-of-the-art models that utilize "hard" graph biases, though the authors suggest that even larger-scale pre-training might close this remaining gap.
Summary updated