Abstract
This report introduces $G^2N^2$ (Grammatical Graph Neural Network), a framework that utilizes Context-Free Grammars (CFG) to systematically design Graph Neural Networks (GNNs) with guaranteed expressive power. By translating algebraic language fragments into reduced grammar rules, the authors derive a model that is provably as powerful as the 3-WL isomorphism test while maintaining computational efficiency. $G^2N^2$ bridges the gap between formal algebraic languages and neural architectures, outperforming existing high-order GNNs on key benchmarks like QM9 and TUDatasets.
Introduction
The primary challenge in Graph Neural Network (GNN) design is achieving high expressive power, typically measured against the Weisfeiler-Lehman (WL) hierarchy. Standard Message Passing Neural Networks (MPNNs) are generally limited to the 1-WL test, failing to distinguish simple non-isomorphic structures like two triangles versus one hexagon. While "provably powerful" models like 3-IGN or PPGN reach the 3-WL level, they often suffer from high memory requirements and lack a systematic design principle.
This work addresses the gap between formal algebraic languages (e.g., MATLANG) and neural architectures by treating GNN design as a formal translation of an algebraic language into a neural network.
Methodology
The authors propose a three-step "grammatical" pipeline to construct the $G^2N^2$ architecture:
- Exhaustive CFG Definition: A fragment of the matrix language MATLANG ($\mathcal{L}_3$, equivalent to 3-WL) is used to define a grammar where variables represent matrices, vectors, or scalars, and rules represent algebraic operations.
- Grammar Reduction: Redundant rules are identified and removed to maintain expressive power while significantly reducing parameter count.
- Translation to GNN Layers: The reduced grammar rules are mapped directly to GNN layer components.
The resulting $G^2N^2$ architecture utilizes "memory tensors" to store intermediate variables. Each layer functions as a rule-selection mechanism, employing MLPs to learn optimal algebraic combinations of stored matrices and vectors.
Key Architectural Insights
- GNNs as Compiled Languages: Viewing a GNN layer as a physical implementation of a formal grammar allows for formal verification of expressive power.
- Memory Tensors: $G^2N^2$ maintains a "stack" of matrices and vectors, enabling complex, multi-step algebraic operations beyond standard message-passing schemes.
- Spectral Versatility: Unlike some 3-WL models, $G^2N^2$ can learn band-pass filters, which are essential for various physical and chemical graph tasks.
Experimental Evaluation
The model was evaluated on QM9 (small molecule regression), TUDatasets (graph classification), and a synthetic Spectral Dataset (grid filter learning).
Key Results
- QM9 Regression: $G^2N^2$ significantly outperformed PPGN, achieving an MAE of 0.342 on the difficult $R^2$ target compared to PPGN's 3.78.
- TUDatasets Classification: $G^2N^2$ achieved state-of-the-art results on MUTAG (92.5%), PTC (72.3%), and Proteins (80.1%).
- Efficiency and Generalization: Grammar reduction halved the parameter count without losing theoretical power, leading to better generalization.
- Spectral Success: $G^2N^2$ successfully learned band-pass filters ($R^2$ of 0.8206), whereas PPGN failed (0.1041).
Discussion and Future Work
While $G^2N^2$ provides a systematic approach to 3-WL expressive power, scaling to higher-order $k$-WL (where $k > 3$) remains a challenge due to the potential combinatorial explosion in memory usage for higher-order tensors. Future research will explore more sophisticated memory management and the application of this "grammatical" approach to other learning paradigms beyond GNNs.
Summary updated