Abstract
Graph Neural Networks (GNNs) often struggle with over-smoothing and over-squashing due to the limitations of local message passing. Graph Transformers offer a global receptive field but frequently fail to capture nuanced structural information. We present Tokenphormer, a structure-aware Graph Transformer that represents nodes through a diverse set of fine-grained tokens. By combining multiple random walk strategies, self-supervised pre-training, and local density information, Tokenphormer effectively captures both local motifs and global context. Our model achieves state-of-the-art performance on nine benchmark datasets, showing particular strength in heterogeneous graph environments.
Introduction
Traditional GNNs rely on neighborhood aggregation, which can lead to indistinguishable node features (over-smoothing) or information bottlenecks (over-squashing). While Graph Transformers treat nodes as tokens to provide global connectivity, they often lose the structural "glue" inherent in graphs. Recent attempts to bridge this gap using $k$-hop neighborhood tokens remain too coarse-grained, failing to distinguish between different structural patterns at the same distance. Tokenphormer addresses this by decomposing node representation into a fine-grained "vocabulary" of tokens.
Methodology: The Multi-token Approach
Tokenphormer serializes graph structures into a "graph document" and generates three distinct token types for every node to capture different structural scales:
- Walk-tokens (Structural): These capture fine-grained geometry through four walk strategies: Uniform Random Walk, Non-backtracking Walk, Neighborhood Jump Walk, and Non-backtracking Jump Walk.
- SGPM-tokens (Global): A Self-supervised Graph Pre-train Model (SGPM) uses Masked Language Modeling (MLM) on graph "sentences" (walks) to learn global contextual embeddings, similar to BERT in NLP.
- Hop-tokens (Local): These maintain coverage of traditional $k$-hop neighborhood density.
These tokens are processed by a Transformer encoder, followed by an attention-based readout function that dynamically weighs the importance of structural, global, and local information for the final classification task.
Experimental Results
We evaluated Tokenphormer on six homogeneous graphs (e.g., Cora, Pubmed) and three heterogeneous graphs (e.g., Wisconsin, Actor).
Performance on Homogeneous Graphs
Tokenphormer consistently outperformed existing GNNs and Graph Transformers. For instance, it achieved 91.20% accuracy on Cora and 89.94% on Pubmed, setting new benchmarks for these datasets.
Performance on Heterogeneous Graphs
The model showed even more significant gains on heterogeneous graphs, where connected nodes often belong to different classes. On the Wisconsin dataset, Tokenphormer reached 86.17% accuracy, a substantial improvement over previous token-based models like NAGphormer (63.51%).
Discussion and Conclusion
The success of Tokenphormer lies in its granularity. By moving beyond simple hop-based aggregation to a diverse set of walk-based tokens, the model captures the "motifs" and specific structural relationships that define a node's role. Furthermore, the stability of the model as token counts increase suggests that these fine-grained tokens provide a high signal-to-noise ratio, avoiding the performance degradation seen in coarser models. While the pre-training phase adds computational overhead, the resulting performance gains across diverse graph types establish Tokenphormer as a powerful new paradigm for graph representation learning.
Summary updated