Overcoming Order in Autoregressive Graph Generation

Edo Cohen-Karlik, Eyal Rozenberg, Daniel Freedman · DOI

Abstract

Autoregressive models, such as Recurrent Neural Networks (RNNs), have demonstrated remarkable success in sequence generation. However, applying these models to graphs is non-trivial because graphs lack a natural linear order. Standard approaches involve flattening graphs into sequences (e.g., via DFS traversals), but the resulting models often become sensitive to arbitrary ordering choices. This paper presents Orderless Regularization (OLR), a novel training objective designed to make autoregressive models invariant to construction order. By enforcing hidden state consistency across different sequences representing the same graph state, OLR significantly enhances data efficiency and the quality of generated molecular structures.

Introduction: The Sequentialization Problem

In domains like drug discovery, generating novel molecular graphs is a primary goal. While molecules are inherently non-sequential collections of atoms and bonds, autoregressive models require a sequence of tokens. To bridge this gap, researchers typically "flatten" graphs into strings, such as SMILES, or sequences of construction steps, such as Depth-First Search (DFS) paths.

The fundamental issue is that a single graph can be represented by many equally valid sequences. For a complex molecule, dozens of different DFS paths might exist. Standard autoregressive models attempt to learn a specific mapping for a specific path, failing to capture the underlying topological invariance of the graph. This dependency on arbitrary ordering makes the learning process inefficient, particularly when training data is limited.

Methodology: Orderless Regularization (OLR)

To address the ordering problem, the authors propose Orderless Regularization (OLR). The core principle is that the model's internal representation (its hidden state) should reflect the topology of the graph being constructed, rather than the specific history of the sequence used to build it.

Comparison of two different DFS traversals (left and right) for the same graph structure, both terminating at node D.

The OLR Objective

During training, the model is presented with two different DFS traversals of the same subgraph that terminate at the same vertex. The OLR loss is an auxiliary term that minimizes the squared difference between the model's hidden states for these two sequences. By forcing these states to converge, the model learns to ignore the path taken and focus on the resulting graph structure.

Efficient Trajectory Sampling

Identifying all possible DFS paths for a given node is an NP-complete problem. To make OLR computationally feasible, the authors developed a heuristic based on min-cuts. By partitioning graphs and "gluing" different trajectories together, they can efficiently generate valid pairs of sequences for training without exhaustive search.

Experimental Evaluation

The researchers evaluated OLR across two primary tasks to test its impact on data efficiency and generative quality.

Wiener Index Prediction

The Wiener Index is a topological property defined as the sum of distances between all pairs of nodes in a graph. Using a synthetic dataset of 10-node graphs, the authors tested the model in a "data-scarce" regime with only 50 training examples. OLR reduced the Mean Absolute Error (MAE) from 2.24 to 1.32 and improved prediction accuracy from 18% to 28%, demonstrating its strength as an inductive bias.

Molecular Generation (MOSES)

On the MOSES benchmark—a standard for molecular distribution learning—the authors compared OLR against "Canonical" (fixed order) and "Randomized" (shuffled order) baselines. The combination of OLR and Randomized ordering achieved the best overall performance. Notably, OLR improved the Fréchet ChemNet Distance (FCD), indicating that the generated molecules more closely matched the distribution of real chemical structures. It also enhanced Internal Diversity (IntDiv), showing that the model explores a wider range of the chemical space rather than memorizing a few patterns.

Conclusion and Future Directions

Orderless Regularization provides a powerful mechanism for training autoregressive models on non-sequential data. By promoting hidden state invariance, OLR allows models to learn the "essence" of a graph more efficiently than standard sequence-based methods. While the current implementation relies on DFS traversals and min-cut heuristics, future work may extend these principles to other graph-to-sequence mappings like Breadth-First Search (BFS) or apply them to more complex, dense graph structures.

Summary updated

BibTeX
@article{cohenkarlik2024overcoming,
  author = {Edo Cohen-Karlik and Eyal Rozenberg and Daniel Freedman},
  title = {{Overcoming Order in Autoregressive Graph Generation}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=BK6Gc10tRy},
}
Figure