A new way to encode molecules lets AI chemistry models generate compounds that are always chemically valid, while also getting better at predicting molecular properties.
Researchers built a representation called Higher-order Grammar Representation, or HGR, that turns a molecule's structure, including rings and repeating motifs, into a sequence of production rules, the same way a grammar generates valid sentences from a fixed set of rules. Because every output must follow those rules, the resulting molecules are chemically valid by construction, something standard sequence-based or graph-based models cannot guarantee. The team also built a new benchmark, RingDiv, with 1.18 million molecules and a curated 300,000-molecule subset, specifically to test ring diversity, since older benchmarks lean too heavily on simple ring systems. Across five generation benchmarks, HGR-based models hit 100% validity while also ranking first on FCD, a score for how closely generated molecules match real-world chemical distributions.
Most generative chemistry models force a tradeoff between speed and chemical correctness, often producing molecules that look plausible but break basic valence rules. HGR's grammar-based approach avoids that tradeoff without the heavy computational cost of other higher-order representations that encode ring structure directly. The same representation also improved property prediction: HGR-FM lifted accuracy by 8.3 and 3.3 points on a standard accuracy score called AUC, depending on how much fine-tuning the model received, across seven MoleculeNet benchmarks.
Whether a grammar tuned on known ring chemistry generalizes to the stranger molecules drug discovery is actually hunting for remains untested.