Higher-Order Molecular Grammars for Generative and Foundation Models in Chemistry
Organizations: Department of Computing, Imperial College London, London, UK · School of Electronic Engineering and Computer Science, Queen Mary University of London, London, UK · Department of Computer Science, Stanford University, Stanford, CA, USA · Department of Integrative Biotechnology, Yonsei University, Incheon, Korea
Abstract
Molecular learning models are strongly shaped by their underlying representations. Yet standard sequential and graph formalisms struggle to explicitly encode higher-order topology, such as ring systems and recurring motifs. Existing higher-order representations can capture these structures directly, but they are often computationally demanding and difficult to decode into valid molecules. Here, we introduce Higher-order Grammar Representation (HGR), a principled, topology-aware framework that lifts molecules to combinatorial complexes and parses each complex into a compact sequence of production rules under a context-free higher-order grammar. By serialising higher-order topology into rule sequences, HGR makes these structures directly compatible with standard sequence models, avoiding the computational overhead of explicit higher-order encodings while preserving topological expressiveness. To reduce benchmark bias towards simple ring systems, we construct RingDiv, a ring-enriched benchmark containing 1.18 million molecules, including the curated RingDiv300k subset, and introduce the ring diversity index (RDI) to quantify ring-system coverage. In molecular generation, HGR-based models uniquely combine 100% validity by construction with leading distributional alignment, ranking first in FCD on all five generation benchmarks. In representation learning, HGR-FM achieves the highest mean AUC across seven MoleculeNet benchmarks under both transfer protocols, improving on the strongest baseline by 8.3 and 3.3 AUC points under probing and full fine-tuning, respectively. Collectively, these results establish HGR as an efficient higher-order representation for molecular generation and transferable representation learning.
Figures & tables
| GuacaMol | Method | Val. | Unique. | Nov. | FCD score | KL score |
|---|---|---|---|---|---|---|
| DiGress [ 42 ] | 85.2 | 100.0 | 99.9 | 68.0 | 92.9 | |
| DeFoG [ 43 ] | 99.0 | 99.0 | – | 73.8 | 97.7 | |
| HoG-Diff [ 23 ] | 99.1 | 100.0 | 97.0 | 78.3 | 96.9 | |
| SELFIES-VAE [ 14 ] | 100.0 | 100.0 | 99.7 | 39.9 | 88.0 | |
| HGR-VAE | 100.0 | 100.0 | 99.4 | 83.7 | 93.8 | |
| HGR-LDF | 100.0 | 100.0 | 98.9 | 84.4 | 95.7 |
| Symbol | Description |
|---|---|
| Molecular graph with vertex set (atoms) and edge set (bonds). | |
| Adjacency between vertex subsets: with and . | |
| Combinatorial complex with cell family (atom and lifted motif cells) and rank function ; the lifting variant is written , , and dropped when clear. | |
| Motif vocabulary mined from the molecule library to score merge candidates in lifting. | |
| Higher-order grammar with terminal set , non-terminal set , start symbol , and production-rule corpus . | |
| A generic non-terminal symbol marking replaceable sites; denotes the site marked by and created at parsing step . |
| Variant | SRing | NRing | MRing | Spiro | Fused | Condensed | Bridged | |
|---|---|---|---|---|---|---|---|---|
| RingDiv | 1,183,434 | 157,542 | 1,160,912 | 69,061 | 104,198 | 522,461 | 582,747 | 113,423 |
| RingDiv300k | 299,819 | 42,703 | 290,985 | 33,591 | 32,026 | 147,500 | 164,171 | 37,660 |
| Category | Metrics |
|---|---|
| Basic metrics | Validity, Uniqueness, Novelty, V.U.N. |
| Chemistry-based metrics | FCD, KL score and SA distribution |
| Topology-based metrics | NSPDK, SNN, Scaffold, and curvature-filtration descriptors ( , ) |
| QM9 | ZINC250k | RingDiv300k | MOSES | GuacaMol | |
| Architecture | |||||
| Max rule-sequence length | 17 | 72 | 137 | 52 | 175 |
| Production rules | 280 | 403 | 6,205 | 320 | 2,385 |
| Motif vocabulary | 500 | 500 | 1,000 | 1,000 | 1,000 |
| Latent dimension | 32 | 256 | 256 | 256 | 768 |
| Rule-token dimension | 64 | 256 | 768 | 512 | 768 |
| ZINC250k | RingDiv300k | MOSES | GuacaMol | |
| Architecture | ||||
| Latent dimension | 256 | 256 | 256 | 768 |
| Tokens | 8 | 16 | 32 | 8 |
| Patch dimension | 32 | 16 | 8 | 96 |
| Hidden width | 768 | 512 | 512 | 1,024 |
| Layers | 8 | 8 | 8 | 6 |
| Setting | Value |
|---|---|
| Pretraining | |
| Corpus (size) | ZINC2m |
| Grammar / production rules | RSG / 825 |
| Backbone (Grammar Transformer) | width 512, 4 layers, 8 heads |
| Dropout | 0.1 |
| Max grammar-tree path distance | 3 |
| Model | Val. | Unique. | Nov. | V.U.N. | KL score | FCD | NSPDK | SA dist. | ||
|---|---|---|---|---|---|---|---|---|---|---|
| Training | 100.0 0.0 | 100.0 0.0 | N/A | N/A | 99.8 0.0 | 0.1737 0.0024 | 0.0001 0.0000 | 0.0123 0.0040 | 0.1312 0.0577 | 0.1203 0.0644 |
| DiGress | 98.9 0.0 | 100.0 0.0 | 100.0 0.0 | 98.90 0.04 | 98.2 0.1 | 0.6300 0.0110 | 0.00041 0.00006 | 0.4171 0.0247 | 0.1021 0.0316 | 0.2656 0.0582 |
| DeFoG | 98.3 0.0 | 100.0 0.0 | 100.0 0.0 | 98.27 0.04 | 98.7 0.1 | 0.8575 0.0087 | 0.00109 0.00002 | 0.1298 0.0081 | 0.4735 0.0373 | 0.4045 0.0088 |
| HoG-Diff | 100.0 0.0 | 99.9 0.0 | 99.6 0.1 | 99.57 0.1 | 98.2 0.1 | 0.9250 0.0236 | 0.00134 0.00026 | 0.1435 0.0333 | 0.1810 0.0326 | 0.1729 0.03247 |
| SMILES-VAE | 88.1 0.1 | 100.0 0.0 | 100.0 0.0 | 88.1 0.1 | 97.6 0.0 | 0.6642 0.0156 | 0.00072 0.00005 | 0.1653 0.0117 | 0.1556 0.0061 | 0.2375 0.0502 |
| SELFIES-VAE | 100.0 0.0 | 100.0 0.0 | 100.0 0.0 | 100.0 0.0 | 92.8 0.4 | 2.4266 0.0526 | 0.00286 0.00005 | 0.6077 0.0071 | 0.6891 0.0687 | 0.3874 0.0738 |
| Model | Val. | Unique. | Nov. | V.U.N. | FCD score | KL score | ||
|---|---|---|---|---|---|---|---|---|
| Training | 100.0 0.0 | 100.0 0.0 | N/A | N/A | 96.12 0.09 | 99.71 0.00 | 0.1276 0.0819 | 0.0573 0.0304 |
| DiGress | 85.2 | 100.0 | 99.9 | - | 68.0 | 92.9 | - | - |
| Disco | 86.6 | 86.6 | 86.5 | - | 59.7 | 92.6 | - | - |
| Cometh | 98.9 | 98.9 | 97.6 | - | 72.7 | 96.7 | - | - |
| DeFoG | 99.0 | 99.0 | - | 97.9 | 73.8 | 97.7 | - | - |
| HoG-Diff | 99.1 0.1 | 100.0 0.0 | 97.0 0.3 | 95.9 0.2 | 78.3 0.3 | 96.9 0.3 | 0.1726 0.0937 | 0.0944 0.0423 |
| Method | Val. | Unique. | Nov. | V.U.N. | FCD | NSPDK | ||
|---|---|---|---|---|---|---|---|---|
| Training | 100.00 0.00 | 99.99 0.00 | N/A | N/A | 0.074 0.004 | 0.0002 0.0000 | 0.1337 0.0560 | 0.2380 0.0762 |
| MiCaM | 99.93 | 93.89 | 83.25 | – | 1.045 | 0.001 | – | – |
| MoFlow | 91.36 1.23 | 98.65 0.57 | 94.72 0.77 | – | 4.467 0.595 | 0.017 0.003 | – | – |
| EDP-GNN | 47.52 3.60 | 99.25 0.05 | 86.58 1.85 | – | 2.680 0.221 | 0.005 0.001 | – | – |
| GraphEBM | 8.22 2.24 | 97.90 0.05 | 97.01 0.17 | – | 6.143 0.411 | 0.030 0.004 | – | – |
| GDSS | 95.72 1.94 | 98.46 0.61 | 86.27 2.29 | 86.48 | 2.900 0.282 | 0.003 0.000 | 0.9252 | 0.6012 |
| Method | Val. | Unique. | Nov. | V.U.N. | FCD | NSPDK | ||
|---|---|---|---|---|---|---|---|---|
| Training | 100.00 0.00 | 99.98 0.01 | N/A | N/A | 0.201 0.005 | 0.0001 0.0000 | 0.1007 0.0563 | 0.0478 0.0190 |
| MiCaM | 100.00 | 88.48 | 99.98 | – | 32.395 | 0.166 | – | – |
| MoFlow | 63.11 5.17 | 99.99 0.01 | 100.00 0.00 | – | 20.931 0.184 | 0.046 0.002 | – | – |
| EDP-GNN | 82.97 2.73 | 99.79 0.08 | 100.00 0.00 | – | 16.737 1.300 | 0.049 0.006 | – | – |
| GraphEBM | 5.29 3.83 | 98.79 0.15 | 100.00 0.00 | – | 35.471 5.331 | 0.212 0.075 | – | – |
| GDSS | 97.01 0.77 | 99.64 0.13 | 100.00 0.00 | – | 14.656 0.680 | 0.019 0.001 | – | – |
| Method | Val. | Unique. | Nov. | V.U.N. | FCD | Filters | SNN | Scaf. | ||
|---|---|---|---|---|---|---|---|---|---|---|
| Training | 100.0 0.0 | 100.0 0.0 | - | - | 0.518 0.007 | 100.0 0.1 | 0.586 0.000 | - | 0.1138 0.0303 | 0.1365 0.01592 |
| GraphINVENT | 96.4 | 99.8 | - | - | 1.22 | 95.0 | 0.54 | 12.7 | - | - |
| DiGress | 85.7 | 100.0 | 95.0 | - | 1.19 | 97.1 | 0.52 | 14.8 | - | - |
| DisCo | 88.3 | 100.0 | 97.7 | - | 1.44 | 95.6 | 0.50 | 15.1 | - | - |
| Cometh | 90.5 | 99.9 | 92.6 | - | 1.27 | 99.1 | 0.54 | 16.0 | - | - |
| DeFoG | 92.8 | 99.9 | 92.1 | - | 1.95 | 98.9 | 0.55 | 14.4 | - | - |
| Method BBBP Tox21 ToxCast SIDER ClinTox HIV BACE avg a. Probing with frozen encoder Infomax 60.8 0.38 67.0 0.40 58.3 0.24 58.2 0.76 62.6 0.28 71.3 1.36 65.1 0.67 63.33 EdgePred 52.7 1.45 63.0 0.77 54.1 0.39 51.7 0.99 48.2 5.46 65.2 1.06 58.6 1.76 56.21 AttrMasking 51.8 0.23 69.3 0.04 57.7 0.08 51.3 0.09 54.5 0.44 60.5 0.31 61.8 0.62 58.13 ContextPred 58.8 0.57 68.3 0.24 58.8 0.36 59.2 0.19 40.0 1.51 67.0 0.62 59.6 2.53 58.81 GraphCL 63.0 0.29 67.6 0.39 57.4 0.48 52.8 0.95 54.7 5.10 64.8 1.69 66.3 0.29 60.94 GraphLoG 54.5 0.30 66.8 0.17 57.4 0.17 58.0 0.58 57.6 1.29 65.2 0.54 72.4 0.65 61.70 GraphMAE 56.5 0.41 66.7 0.45 57.6 0.10 52.0 0.82 44.3 0.57 60.5 0.54 61.8 5.53 57.06 GraphMVP 57.9 0.68 66.9 0.17 58.5 0.09 56.0 1.16 42.7 1.99 67.1 0.83 65.3 0.20 59.20 MORE 67.9 0.28 70.6 0.33 62.2 0.16 60.7 0.28 63.5 1.26 72.8 0.32 80.0 0.62 68.24 HGR-FM 74.4 0.96 78.5 0.57 68.9 0.11 63.0 0.58 89.7 1.59 76.9 1.02 84.1 0.56 76.51 b. Full fine-tuning Infomax 68.0 1.05 75.0 0.55 62.4 0.57 59.7 0.47 71.1 3.88 76.8 1.38 76.8 1.32 69.97 EdgePred 65.3 1.96 76.3 0.26 63.6 0.28 61.3 0.54 64.5 2.67 75.7 1.05 79.9 1.27 69.51 AttrMasking 63.4 1.45 76.4 0.19 63.4 0.52 60.0 0.87 71.1 2.46 76.3 0.28 79.7 0.47 70.04 ContextPred 67.1 0.81 74.4 0.12 63.7 0.12 60.9 0.78 59.0 1.99 76.6 0.45 79.1 2.13 68.69 GraphCL 68.0 2.05 74.5 0.12 62.4 0.59 59.2 1.12 75.3 3.67 76.3 1.09 76.8 0.36 70.36 GraphLoG 66.8 2.55 74.7 0.25 62.4 0.55 59.6 0.67 64.2 1.27 76.6 0.77 82.3 0.42 69.51 GraphMAE 68.0 2.54 75.6 0.27 63.4 0.14 60.2 0.49 70.8 4.15 76.6 0.87 82.1 1.40 70.96 GraphMVP 71.3 1.13 75.0 0.37 63.4 0.26 62.9 0.29 68.2 5.95 75.8 1.44 78.8 4.61 70.77 MORE 71.9 0.94 75.6 0.54 64.6 0.58 60.9 0.62 81.0 0.65 77.0 0.74 82.8 1.33 73.40 HGR-FM 74.3 1.08 79.0 0.41 70.8 0.12 62.1 1.05 89.4 1.00 77.5 0.21 84.0 0.43 76.73 |
| Method | QM9 | ZINC250k | MOSES | GuacaMol | RingDiv300k |
|---|---|---|---|---|---|
| Training time (h) | |||||
| DiGress | - | - | - | - | 63.0 |
| DeFoG | - | - | - | - | 53.1 |
| HoG-Diff | 3.1 | 6.5 | 7.8 | 30.0 | 8.1 |
| HGR-VAE (RSG) | 0.3 | 3.1 | 1.4 | 8.4 | 3.0 |
| Inference time (min) | |||||