TL;DR
GraphBPE adapts the popular Byte-Pair Encoding (BPE) algorithm from natural language processing to molecular graphs. By iteratively counting and merging frequent contextualized node pairs into "hypernodes," it creates compressed simple graphs and hypergraphs in a completely model-agnostic, data-driven way. Experiments demonstrate that this tokenization significantly improves Graph Neural Network (GNN) performance on smaller graph classification benchmarks while remaining competitive with hand-crafted, domain-specific chemistry heuristics.
What Problem Does This Paper Address?
While machine learning on molecular graphs has seen rapid progress through expressive GNN architectures and comprehensive benchmarks, graph data preprocessing has received far less attention. In NLP, subword tokenization (such as BPE) is an essential ingredient: words are broken down or merged into informative subword units that make learning easier and more robust.
In molecular machine learning, graphs are typically left at the individual atom/bond level or segmented using rigid, handcrafted rules from chemistry (such as predefined functional groups or motif dictionaries). The authors ask two fundamental questions:
- Can graphs be tokenized using a purely statistical "count-and-merge" paradigm similar to text?
- Does training on these tokenized molecular structures actually improve model performance?
Methods
The authors introduce GraphBPE, an unsupervised, iterative graph tokenization framework:
[Molecule Graph]
│
▼ (Optional Preprocessing: Contract rings / cliques)
[Graph G⁰]
│
├─► 1. Contextualize edges into strings (incorporating 1-hop neighbor context)
├─► 2. Count edge-type frequencies across the corpus (orderless: s₁-s₂ ≡ s₂-s₁)
└─► 3. Contract the most frequent pair into a hypernode
│
▼ (Repeat for T steps)
[Tokenized Graph Gᵀ] ──► Can be viewed as:
• A Coarsened Simple Graph (for standard GNNs)
• A Hypergraph (for HyperGNNs)
- Preprocessing Stage: Optionally contracts known fundamental sub-topologies, such as rings (in organic molecules) or cliques (in proteins).
- Context-Aware Count-and-Merge: Edges are viewed as the graph equivalent of adjacent character pairs. A contextualizer converts node pairs and their 1-hop neighborhoods into identifiable string keys. Because graph edges have no fixed direction, GraphBPE treats pairs as orderless ($s_1\text{-}s_2$ is identical to $s_2\text{-}s_1$). At each step, the most frequent edge type across the entire dataset is contracted into a single hypernode.
- Dual Representation: The contracted graph can be fed directly to standard GNNs (pooling merged node features) or treated as a hypergraph where hypernodes and remaining original edges define hyperedges for HyperGNNs.
- Baselines & Backbones: Evaluated with GCN, GAT, GIN, and GraphSAGE for simple graphs, and HyperConv, HGNN++, and HNHN for hypergraphs. Compared against untokenized graphs and three hypergraph construction schemes: Centroid (ego-nets), Chem (RDKit functional groups), and H2G (heuristic motifs).
Datasets
The authors evaluated GraphBPE across six standard benchmark datasets (split 60/20/20 for $<2000$ graphs, 80/10/10 for larger):
- Graph Classification (TUDataset):
MUTAG(188 molecules, binary mutagenicity),ENZYMES(600 enzymes, 6 classes), andPROTEINS(1,113 proteins, binary enzyme classification). - Graph Regression (MoleculeNet):
FreeSolv(642 molecules, hydration free energy),ESOL(1,128 molecules, aqueous solubility), andLipophilicity(4,200 molecules, octanol/water distribution coefficient).
Key Insights and Ideas
- Substructure contraction works out-of-the-box: A motivating experiment showed that simply contracting aromatic rings into hypernodes boosted classification accuracy on MUTAG substantially across all models (e.g., GCN jumped from 64.9% to 72.4%; GraphSAGE from 56.8% to 69.2%).
- Generalizing prior motif extraction: Prior graph tokenizers (such as Principal Subgraph Extraction) operate without neighborhood awareness. GraphBPE generalizes them by allowing custom contextualization functions that account for local structural context.
- Task and scale sensitivity: Graph tokenization helps classification tasks significantly more than regression tasks. Furthermore, the benefits of a fixed tokenization budget (e.g., 100 steps) decay on larger datasets, where vocabulary diversity is higher and requires more merge rounds.
Key Results
- MUTAG (Classification): GraphBPE achieved consistent improvements over untokenized graphs. Over 100 tokenization steps, GraphBPE was numerically superior to untokenized baselines in 101 out of 101 evaluation steps for GCN and GraphSAGE, with statistical significance ($p < 0.05$) in 93 and 96 steps, respectively.
- ENZYMES & PROTEINS: GraphBPE provided gains during early tokenization iterations (e.g., the first ~20 steps on GAT), though performance degenerated if graphs were over-compressed.
- HyperGNN Comparison: On FreeSolv and MUTAG, GraphBPE matched or outperformed domain-knowledge-heavy methods (Chem, H2G) on models like HNHN without relying on external chemistry toolkits.
Limitations and Future Work
- Static tokenization budget: A fixed number of iterations (e.g., 100 steps) is inadequate for larger, structurally diverse datasets.
- Lack of an early-stopping criterion: There is currently no analytical way to determine the optimal number of merge steps prior to model training.
- Small benchmark scale: The study focuses on smaller datasets ($\sim 10^2$ to $10^3$ molecules); evaluating GraphBPE on modern million-scale pretraining corpuses (e.g., ZINC) remains open.
- Rule flexibility: Tokenization rules are purely frequency-based; exploring differentiable or neural-network-guided tokenization rules is left for future work.
Summary updated