NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Graph Generative Pre-trained Transformer

Xiaohui Chen, Yinkai Wang, Jiaxing He, Yuanqi Du, Soha Hassoun, Xiaolin Xu, Liping Liu

Introduction

The success of Large Language Models (LLMs) has largely been driven by the simplicity and scalability of the "next-token prediction" objective. However, extending this paradigm to graph-structured data has historically been difficult. Graphs are non-Euclidean and permutation invariant, meaning a single graph can be represented by many different adjacency matrices. Traditional approaches have either relied on computationally expensive $O(N^2)$ adjacency matrices or complex diffusion models that require specialized Graph Neural Network (GNN) architectures.

G2PT (Graph Generative Pre-trained Transformer) bridges this gap by representing graphs as efficient sequences of node and edge tokens. By treating graph construction as a sequential process, G2PT leverages the massive learning capacity of standard Transformer decoders to generate complex, sparse structures—from social networks to drug-like molecules—with state-of-the-art accuracy and scalability.

The Challenge of Graph Generation

Generating graphs is notoriously difficult because they do not fit into the standard grids used for text or images. Existing models generally fall into two camps:

  1. Adjacency Matrix Models: These treat graphs as $N \times N$ grids. This is computationally expensive and wasteful for sparse graphs where most entries are zeros.
  2. Diffusion Models: These require many iterative "denoising" steps and often restrict the model architecture to specific GNNs to maintain theoretical permutation invariance.

G2PT asks whether we can skip these complex architectures and $O(N^2)$ overhead by treating a graph simply as a sequence of "actions" (e.g., add node A, add edge A-B) and letting a powerful Transformer learn the underlying patterns.

Methodology

The core innovation of G2PT is its token-based graph representation, which allows a graph $G=(V, E)$ to be flattened into a sequence:

  • Tokenization: Each node is represented by its type and a unique index. Each edge is a triple consisting of a source index, destination index, and edge type. A special separator token ($a_\Delta$) divides the node list from the edge list.
  • Sequential Ordering: Since Transformers are sensitive to sequence order, the authors use a "degree-based edge removal" strategy. They deconstruct the graph by removing edges from low-degree nodes first; reversing this process for generation allows the model to build a dense "core" of the graph before adding peripheral details.
  • Architecture: The model uses a standard GPT-style Transformer decoder. The authors argue that the massive learning capacity of Transformers allows them to learn the "rules" of graph topology from data, effectively bypassing the need for specialized GNN layers.

Fine-Tuning and Alignment

G2PT is designed to be a multi-tasker. Beyond simple generation, it can be adapted for specific goals:

  • Goal-Oriented Generation: To generate molecules with specific properties (e.g., high drug-likeness), the authors use Rejection Sampling Fine-tuning (RFT) with a "Self-Bootstrap" mechanism and Reinforcement Learning (PPO) to steer the model's output.
  • Property Prediction: By taking the final token's activation as a graph embedding, G2PT can be fine-tuned for classification tasks, such as determining if a molecule is toxic.

Key Results

The model was evaluated across diverse benchmarks, including generic graphs (Planar, Tree, SBM) and molecular datasets (MOSES, GuacaMol).

  • State-of-the-Art Generation: On the MOSES molecular dataset, G2PT outperformed existing diffusion and autoregressive models in validity, uniqueness, and Fréchet ChemNet Distance (FCD). In generic graph benchmarks, it achieved the best or second-best scores on 17 out of 24 metrics.
  • Scaling Laws: Much like LLMs, G2PT shows clear scaling benefits. Increasing the model size (from 1M to 1.5B parameters) and the amount of data augmentation consistently improved the quality of the generated graphs.
  • Competitive Prediction: When fine-tuned for property prediction on MoleculeNet, G2PT achieved an average ROC-AUC of 73.3, matching the performance of specialized self-supervised GNNs like GraphMAE.

Limitations and Future Work

While G2PT represents a significant step forward, challenges remain. The model's performance is still tied to the chosen edge ordering, and finding a truly "universal" canonical ordering remains an open challenge. Additionally, G2PT currently operates on 2D graph structures and does not explicitly model 3D spatial coordinates or chirality, which are critical for advanced biological applications. Finally, the authors acknowledge the need for safety frameworks to prevent the dual-use risk of designing harmful compounds.

Summary updated

BibTeX
@inproceedings{chen2025graph,
  author = {Xiaohui Chen and Yinkai Wang and Jiaxing He and Yuanqi Du and Soha Hassoun and Xiaolin Xu and Liping Liu},
  title = {{Graph Generative Pre-trained Transformer}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=FmHnhDLlOX},
}
Figure