[Paper Review] Graph Tokenization for Bridging Graphs and Transformers
This paper introduces GraphTokenizer, a framework that converts graphs into reversible, structure-guided sequences and then learns a BPE-based tokenizer to enable standard Transformers to process graphs without architectural changes, achieving state-of-the-art results on 14 benchmarks.
The success of large pretrained Transformers is closely tied to tokenizers, which convert raw input into discrete symbols. Extending these models to graph-structured data remains a significant challenge. In this work, we introduce a graph tokenization framework that generates sequential representations of graphs by combining reversible graph serialization, which preserves graph information, with Byte Pair Encoding (BPE), a widely adopted tokenizer in large language models (LLMs). To better capture structural information, the graph serialization process is guided by global statistics of graph substructures, ensuring that frequently occurring substructures appear more often in the sequence and can be merged by BPE into meaningful tokens. Empirical results demonstrate that the proposed tokenizer enables Transformers such as BERT to be directly applied to graph benchmarks without architectural modifications. The proposed approach achieves state-of-the-art results on 14 benchmark datasets and frequently outperforms both graph neural networks and specialized graph transformers. This work bridges the gap between graph-structured data and the ecosystem of sequence models. Our code is available at \href{https://github.com/BUPT-GAMMA/Graph-Tokenization-for-Bridging-Graphs-and-Transformers}{\color{blue}here}.
Motivation & Objective
- Motivate a principled graph tokenizer that preserves structure for sequence models without changing Transformer architectures.
- Develop a reversible, deterministic graph serialization guided by global substructure frequencies.
- Couple serialization with Byte Pair Encoding to learn a meaningful, compressive vocabulary for graphs.
- Demonstrate state-of-the-art performance on 14 graph benchmarks using standard Transformer backbones.
Proposed method
- Define a graph tokenizer as the composition Phi = T o f, where f is a reversible, structure-guided graph serialization and T is a BPE-based sequence tokenizer.
- Compute dataset-level local substructure frequencies F(p) from training graphs to deterministically guide the serialization f_g via a Frequency-Guided Eulerian circuit.
- Extend Hierholzer’s Eulerian traversal with a frequency-based priority to obtain a reversible and deterministic graph serialization.
- Train a BPE vocabulary on the serialized corpus to obtain discrete graph tokens V_T and merge rules R, enabling efficient tokenization of graphs.
- Provide encode/decode procedures to map between graphs and token sequences using the learned F and codebook C (V_T, R) and the inverse serialization f^{-1}.
- Evaluate GT with two Transformer backbones (GT+BERT and GT+GTE) across 14 graph benchmarks, analyzing compression, speed, and predictive accuracy.

Experimental results
Research questions
- RQ1Can a graph serialization guided by global graph-substructure statistics enable a deterministic, reversible mapping from graphs to sequences?
- RQ2Does combining reversible structure-guided serialization with BPE yield informative, compact graph tokens suitable for standard Transformers?
- RQ3How does the GraphTokenizer framework compare to state-of-the-art graph learning methods across classification and regression benchmarks?
- RQ4What is the impact of different serialization strategies and the use of BPE on performance and stability?
Key findings
- BPE compression reduces serialized sequence length to about 10% of original for Feuler, improving efficiency.
- GT+GTE achieves state-of-the-art results on most benchmarks, e.g., ogbg-molhiv ROC-AUC of 0.876 (val 0.903).
- Frequency-guided Eulerian circuit (Feuler) outperforms unguided Eulerian methods and improves stability.
- BPE substantially improves performance and stability across configurations.
- Reversible, structure-guided serialization paired with Transformer backbones can surpass specialized Graph Neural Networks and graph transformers on multiple datasets.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.