Graph Neural Networks in Chemistry: Reading Molecules as Math

Photo: Rui Dias / Pexels
A molecule is already a graph. Atoms are nodes. Chemical bonds are edges. The way those atoms connect determines almost everything a chemist cares about: how the molecule will interact with a biological target, how it absorbs light, whether it dissolves in water, and how it will behave in a reaction. For decades, chemists translated that graph structure into flat numerical descriptors—Morgan fingerprints, physicochemical property tables—and fed them into conventional machine learning models. The results were useful but limited. Graph neural networks (GNNs) changed the equation by operating directly on the molecular graph itself, letting the network decide which structural features matter most for each prediction task, rather than forcing a chemist to guess in advance.
This matters because molecular property prediction sits at a genuine bottleneck in science. Testing a single drug candidate for toxicity, solubility, and bioactivity in a wet lab can take weeks and cost thousands of dollars per compound. A pharmaceutical pipeline might need to screen tens of thousands of candidates before finding one worth advancing. If a computational model can flag likely failures before synthesis even begins, it does not just save money — it changes which molecules get made at all.
Key takeaways
- GNNs for chemistry treat atoms as nodes and bonds as edges, passing information iteratively to aggregate local chemical environments into whole-molecule representations.
- Message-passing neural networks (MPNNs) introduced a unified mathematical framework that describes most GNN architectures used in chemistry today.
- Benchmark results on MoleculeNet show GNNs outperforming classical machine learning methods on molecular property prediction across toxicity, solubility, and bioactivity tasks.
- The most powerful current methods combine GNNs with three-dimensional atomic coordinates and equivariant architectures that respect the physical symmetries of molecules.
- GNN-guided screening has already found a working antibiotic candidate (halicin) that human chemists had not flagged, published in Cell in 2020.
Why Graph Structure Matters in Chemistry
The standard way to encode a molecule for machine learning before GNNs became practical was a fingerprint: a fixed-length binary vector where each bit flags whether a particular substructure appears somewhere within a certain radius of any atom. Morgan fingerprints, also called extended-connectivity fingerprints (ECFP), have been used since the mid-2000s and remain a competitive, fast baseline even today (Wu et al., MoleculeNet, 2018).
The limitation is information loss. A fingerprint records the presence of local substructures but discards the topological relationships between them, in the same way a bag of ingredients tells you nothing about how a recipe combines them. Two molecules can share identical local environments but differ in global connectivity, ring topology, or three-dimensional shape, producing the same fingerprint bits while behaving completely differently in the body. Geometric isomers and some stereoisomers are the classic failure case.
A GNN operating on the molecular graph does not have this ceiling. By propagating information along bonds for several rounds, a GNN can, in principle, capture correlations between any two atoms in the molecule, with the effective "receptive field" set by how many message-passing steps the network runs. Think of it like a rumor spreading through a group of people connected by handshakes: after one round, only your direct contacts know something about you; after several rounds, information about you has rippled out to people three or four handshakes away, weighted by how directly connected they are.
Message-Passing Neural Networks: The Unified Framework
The message-passing neural network (MPNN) framework, introduced by Justin Gilmer and colleagues at Google Brain in 2017, unified a scattering of earlier GNN variants under one mathematical abstraction (Gilmer et al., "Neural Message Passing for Quantum Chemistry," ICML 2017). During each message-passing step, every atom-node gathers messages from its bonded neighbors, folds them into an updated internal representation, and passes that updated state forward into the next round. Repeat this a handful of times and every atom's representation encodes not just its own identity but the shape of the neighborhood around it, several bonds deep.
Formally, at each step k, the hidden state of atom v is updated as h_v^(k+1) = U(h_v^(k), Σ_{u∈N(v)} M(h_v^(k), h_u^(k), e_vu)), where M is a learned message function, U is a learned update function, N(v) is the set of atoms bonded to v, and e_vu encodes the bond between them (single, double, aromatic, and so on). After K rounds, a readout function pools all the atom-level states into one molecule-level vector, which a final layer converts into a property prediction — a toxicity score, a solubility value, a binding affinity estimate.
The original MPNN paper tested this architecture against the QM9 dataset, a collection of 134,000 small organic molecules with 12 quantum-chemical properties each computed via density functional theory (DFT), a computationally expensive quantum simulation method. The MPNN's predictions came close to DFT-level accuracy for several properties while running orders of magnitude faster, which suggested the network had learned a compressed, reusable approximation of quantum chemistry itself rather than memorizing the training set.
Why message passing beats a flat feature vector
A flat feature vector treats a molecule as an unordered list of counted substructures, with no sense of how those substructures connect. Message passing instead lets each atom "ask its neighbors" what they look like, several times over, building a representation shaped by the molecule's actual wiring diagram — closer in spirit to how a chemist reasons about electron delocalization across a ring system than to a checklist of parts.
Practical Applications: Toxicity, Solubility, Bioactivity
MoleculeNet, a benchmarking platform introduced by Zhenqin Wu and colleagues at Stanford in 2018, established standardized comparison protocols across a range of molecular machine learning datasets (Wu et al., Chemical Science, 2018). GNNs consistently outperform classical fingerprint-based methods on most of the tasks it covers.
Toxicity prediction. The Tox21 dataset, compiled by the US National Institutes of Health and Environmental Protection Agency, contains experimental toxicity measurements for roughly 8,000 compounds across 12 assays covering nuclear receptor and stress-response pathways (Tox21 Data Challenge, NIH). GNN-based models reported in the MoleculeNet benchmark and follow-up work achieve ROC-AUC scores in the 0.82–0.88 range across assays, compared to roughly 0.75 for ECFP-plus-random-forest baselines. For a pharmaceutical team, that gap translates into more compounds correctly filtered out before expensive animal or cell-based toxicity testing begins.
Solubility prediction. Aqueous solubility is a make-or-break ADMET (absorption, distribution, metabolism, excretion, toxicity) property — a compound that will not dissolve cannot be formulated into a usable drug, no matter how well it binds its target. GNNs trained on the ESOL dataset (1,128 molecules with measured solubility, compiled by Delaney) achieve root-mean-square error around 0.5–0.6 log-solubility units, which is close to the noise level in the underlying experimental measurements themselves.
Bioactivity. The PubChem BioAssay (PCBA) collection used in MoleculeNet contains results from roughly 440,000 compounds tested across dozens of biological assays. GNNs show their largest advantage here, particularly on assays where binding depends on a molecule's overall three-dimensional pharmacophore rather than any single local substructure a fingerprint could flag.
| Task | Dataset | Molecules | Classical baseline (ECFP + RF) | GNN performance |
|---|---|---|---|---|
| Toxicity | Tox21 | ~8,000 | ~0.75 ROC-AUC | 0.82–0.88 ROC-AUC |
| Solubility | ESOL | 1,128 | ~0.7–0.9 RMSE (log units) | ~0.5–0.6 RMSE (log units) |
| Bioactivity | PCBA | ~440,000 | Lower on complex pharmacophores | Consistently higher |
| Quantum properties | QM9 | 134,000 | Not applicable (needs DFT) | Near-DFT accuracy, far faster |
Table: representative benchmark ranges reported across MoleculeNet and related GNN literature. Exact figures vary by architecture and split; see MoleculeNet, Wu et al. 2018.
Do GNNs replace lab testing entirely?
No. GNN predictions are used to prioritize which compounds get synthesized and tested, not to replace the tests. A model with a 0.85 ROC-AUC still makes wrong calls often enough that regulators and internal safety teams require confirmatory wet-lab data before a compound advances toward clinical trials.
3D-Aware GNNs and Equivariant Architectures
The molecular graph captures connectivity — which atom is bonded to which — but not three-dimensional geometry. A molecule sitting inside a protein binding pocket adopts a specific 3D conformation, and binding affinity depends heavily on the shape of that particular conformation. Two molecules with identical bond graphs but different 3D shapes, whether different conformers of the same molecule or different candidate docking poses, can bind a target with very different strengths.
3D-aware GNNs fold interatomic distances and angles into the edge features the network learns from. SchNet, developed by Kristof Schütt and colleagues working with Klaus-Robert Müller at TU Berlin, encodes interatomic distances using continuous-filter convolutions (Schütt et al., Journal of Chemical Physics, 2018). DimeNet extends that idea to include bond angles between triples of atoms; SphereNet adds dihedral angles, capturing how substituents twist around a bond axis. Each extension buys more geometric fidelity at the cost of requiring an accurate 3D input structure to begin with, which is itself not always easy to obtain for a flexible molecule.
Equivariant GNNs push this further by baking physical symmetry directly into the architecture. Rotate a molecule in space, and its predicted scalar properties — total energy, dipole magnitude — should not change at all (this is called invariance). But vector properties, like the direction of the dipole moment or the force on each atom, should rotate along with the molecule (this is equivariance). NequIP, from Nathaniel Thomas and colleagues at MIT and collaborators, and MACE, from Ilyes Batatia and colleagues at the University of Cambridge, are equivariant GNNs that achieve strong accuracy on molecular dynamics force fields — the energy and force calculations that drive simulations of how atoms move over time — while respecting these symmetries by construction rather than learning them approximately from data (Batatia et al., "MACE," NeurIPS 2022).
Reaction Prediction and Synthesis Planning
GNNs are not confined to predicting static properties of a fixed molecule. Chemical reactions transform molecular graphs — bonds break, new bonds form — and GNNs can model that transformation directly, treating a reaction as a graph-to-graph mapping problem.
Reaction outcome prediction asks: given a set of reactants, reagents, and conditions, what product forms? Connor Coley's group at MIT built the USPTO datasets, extracted from millions of patent-filed reactions, and used them to train and benchmark models that predict major reaction products. Graph-based and graph-to-graph transformer models trained on these datasets report top-1 accuracy in the high-80s to low-90s percent range on relatively well-behaved reaction types, in the same ballpark as an expert organic chemist working from the same starting materials.
Retrosynthetic analysis works in the opposite direction: given a target molecule, work backward through a tree of possible reactions to find a feasible synthesis route, typically starting from cheap, commercially available starting materials. This is central to medicinal chemistry, where a promising drug candidate is useless if nobody can make enough of it economically. ASKCOS (Automated System for Knowledge-based Continuous Organic Synthesis), developed at MIT, and AiZynthFinder, developed at AstraZeneca and released as open source, both use GNN-based scoring models to rank candidate retrosynthetic disconnections and prune an otherwise combinatorially explosive search tree.
IBM's RXN for Chemistry platform, deployed as a commercial and research tool, offers both forward reaction prediction and retrosynthetic route planning, built on transformer and graph-based models trained on tens of millions of reactions extracted from the patent literature. Its continued deployment is one signal that these methods have moved past academic benchmarks into everyday industrial use, alongside academic groups' open releases.
How accurate is AI-predicted retrosynthesis compared to a human chemist?
On well-represented reaction classes, top GNN and transformer-based retrosynthesis models propose a viable route in a majority of cases and often match or beat a chemist working from memory alone. They struggle more on novel reaction types poorly represented in the patent-literature training data, where a chemist's broader intuition and access to primary literature still wins out.
Materials Science: Beyond Small Organic Molecules
Chemistry is not only about drug-like organic molecules. GNN methods developed for molecular property prediction transfer, with modification, to crystalline materials, catalysts, and battery electrolytes, where the same "atoms as nodes, bonds or contacts as edges" logic applies to a periodic crystal lattice instead of a single discrete molecule.
The Materials Project and the Open Catalyst Project, both large public datasets built to accelerate materials discovery, use GNN architectures adapted for periodic boundary conditions — the mathematical trick that lets a network represent an infinitely repeating crystal using only one unit cell as input. CGCNN (Crystal Graph Convolutional Neural Network), from Tian Xie and Jeffrey Grossman at MIT, was an early and influential example, predicting formation energies and other properties of inorganic crystals directly from crystal structure with accuracy competitive with DFT calculations that would otherwise take hours per material (Xie & Grossman, Physical Review Letters, 2018).
Battery electrolyte and catalyst screening follows the same pattern as drug discovery: a GNN model narrows millions of candidate compositions down to a shortlist worth simulating in more detail or synthesizing in the lab, compressing a search that would otherwise take years of trial-and-error lab work.
Protein Structure and Protein-Ligand Interaction
GNN thinking also underlies parts of modern protein structure prediction, where the "graph" is the network of spatial relationships between amino acid residues rather than atoms in a small molecule. DeepMind's AlphaFold, whose second version was validated in the CASP14 (Critical Assessment of Structure Prediction) competition in 2020, produced predictions with a median backbone accuracy around 0.96 Å root-mean-square deviation and Global Distance Test (GDT_TS) scores that, above roughly 90, are considered comparable to experimentally determined structures (Jumper et al., "Highly accurate protein structure prediction with AlphaFold," Nature, 2021). By CASP16 in 2024, predictors building on AlphaFold's approach averaged a TM-score of 0.902 for top-1 predictions among the strongest performers.
That matters for GNN-based drug discovery because knowing a target protein's 3D structure sharply narrows the search for small molecules that will bind it. A GNN trained on a small molecule's graph can be paired with a predicted protein pocket structure to score how well a candidate compound is likely to fit, closing the loop between "what molecules exist" and "what shape do they need to have."
Where GNNs Still Fall Short
It would be misleading to present GNNs as a solved problem. Three limitations recur across the literature and in industrial deployments.
- Data scarcity for rare properties. Common benchmark datasets like Tox21 and ESOL have thousands of labeled examples; many properties chemists actually care about, such as a specific off-target toxicity or a rare metabolic pathway interaction, have only dozens of labeled compounds, far too few to train a GNN from scratch.
- Extrapolation beyond training chemistry. A GNN trained mostly on drug-like small molecules tends to degrade when asked to predict properties of chemical classes it rarely saw, such as unusual heterocycles or organometallic compounds.
- Stereochemistry and conformational flexibility. Basic graph representations struggle to capture which 3D shape a flexible molecule will actually adopt in solution or in a binding pocket, since a single 2D graph can correspond to many distinct 3D conformations.
Pre-training strategies partly address the first limitation: a model pre-trained via self-supervised learning on millions of unlabeled PubChem molecules, then fine-tuned on a small labeled dataset, generally outperforms training a GNN from scratch on the small dataset alone, in the same way a language model pre-trained on general text adapts faster to a narrow specialized task than one trained only on that narrow dataset.
What People Get Wrong About GNNs in Chemistry
A common misconception is that a GNN "understands chemistry" the way a chemist does, reasoning about electron pushing arrows and orbital interactions. It does not. A GNN learns statistical correlations between graph structure and labeled outcomes in its training data; it has no explicit representation of quantum mechanics unless that structure is engineered into the architecture, as equivariant models attempt to do. When a GNN's predictions align with known chemical principles, that is because the training data itself encodes those principles implicitly, not because the network derived them from first principles.
Another frequent confusion is treating GNN accuracy figures as if they applied universally across chemical space. A model reporting 0.88 ROC-AUC on Tox21 was evaluated on molecules similar in distribution to Tox21's training set. Push the same model toward a chemically novel scaffold and accuracy typically drops, sometimes sharply, a phenomenon called domain shift that active research in uncertainty quantification tries to flag before a bad prediction reaches a chemist's synthesis queue.
Finally, GNNs and large language models trained on SMILES strings are sometimes described as competitors, when in practice the leading systems increasingly combine both. A GNN captures explicit graph topology, while a language model pre-trained on millions of SMILES strings, like ChemBERTa, captures statistical patterns across chemical "language" that a strict graph representation can miss, such as common synthetic motifs. Hybrid architectures that fuse both signal types currently sit at or near the top of most MoleculeNet leaderboards.
FAQ
Q: What is the difference between a GNN and a transformer for molecules? A GNN explicitly uses molecular graph topology, passing messages along the bonds that actually exist. A transformer can operate on SMILES-string sequences or sets of atoms with learned pairwise attention, implicitly inferring which connections matter. Hybrid architectures that combine both approaches currently achieve the strongest results on most molecular property benchmarks.
Q: What is a SMILES string? SMILES (Simplified Molecular Input Line Entry System) is a text notation for molecular structure — aspirin, for example, is written as CC(=O)Oc1ccccc1C(=O)O. Many early molecular machine learning models used SMILES strings as input and applied natural-language-processing techniques like LSTMs or transformers to them. GNNs bypass the SMILES string entirely and operate directly on the underlying graph.
Q: Do GNNs understand stereochemistry? Basic GNNs treat bonds as undirected edges and miss stereochemical information such as R/S configuration or E/Z double-bond geometry. Stereo-aware GNN variants encode this information explicitly as additional edge or node features. For biological activity prediction this matters a great deal, since enantiomers (mirror-image versions) of the same molecule can have opposite pharmacological effects.
Q: How large are the training datasets for molecular GNNs? Academic benchmark datasets typically range from about 1,000 to 500,000 labeled molecules. ChEMBL, the European Bioinformatics Institute's bioactivity database, contains roughly two million bioactivity measurements. Proprietary pharmaceutical datasets can be considerably larger. Pre-training on unlabeled molecular data, then fine-tuning on a smaller labeled dataset, has become a standard strategy for tasks where labeled data alone would be insufficient.
Q: What is ChemBERTa? ChemBERTa is a BERT-style language model pre-trained on SMILES strings drawn from PubChem, treating SMILES text as a molecular "language." It reaches competitive performance on MoleculeNet tasks through transfer learning, the same way BERT-based language models often outperform narrowly task-specific architectures in natural language processing.
Q: What was halicin and how did a GNN find it? Halicin is a broad-spectrum antibiotic candidate identified in 2020 by a directed message-passing GNN called Chemprop, developed at MIT. Researchers trained the model to predict antibacterial activity, screened a library of roughly 6,000 molecules from the Drug Repurposing Hub, and flagged a compound structurally unlike any existing antibiotic class. It later showed activity against drug-resistant bacteria strains, including some resistant to nearly all approved antibiotics, in Cell-published lab tests (Stokes et al., Cell, 2020).
Q: Can GNNs predict drug side effects before human trials? GNNs trained on toxicity and off-target interaction datasets like Tox21 can flag compounds statistically likely to cause certain adverse effects, helping prioritize which candidates get deprioritized early. They cannot reliably predict rare or idiosyncratic side effects that emerge only in large, diverse human populations, which is why regulatory clinical trials remain mandatory regardless of how strong a model's early predictions look.
Q: Are GNNs used outside drug discovery, in materials science? Yes. GNN architectures adapted for periodic crystal structures, such as CGCNN, predict properties like formation energy for inorganic crystals directly from structure, supporting large-scale materials screening efforts like the Materials Project and the Open Catalyst Project for battery and catalyst design.
Q: Why can't a single 2D molecular graph fully capture a drug's real-world behavior? A 2D graph records which atoms bond to which but not the 3D shape the molecule actually adopts in solution or inside a binding pocket, and a flexible molecule can adopt many distinct 3D conformations from one graph. This is why 3D-aware and equivariant GNNs, which take atomic coordinates as additional input, tend to outperform 2D-only models on tasks where binding geometry drives the outcome.
The takeaway
Graph neural networks succeed in chemistry for a simple structural reason: they stop forcing molecules into a format built for other kinds of data and instead operate on the graph a molecule already is. That shift has produced measurable, benchmarked gains in toxicity, solubility, and bioactivity prediction, and it has already contributed to a real antibiotic candidate that human screening missed. The methods are not a replacement for wet-lab chemistry, and they degrade when pushed outside the chemical space they were trained on, but as a filter that decides which of thousands of candidate molecules deserve a chemist's time, they have moved from research curiosity to standard industrial tool in under a decade.
Read next:
Follow new articles
Add SciHub101 to your feed reader to see new science and technology stories.
About the Author
SciHub101 is an independent science and technology publication founded and edited by Buğra Sözeri, a software engineer and app developer based in Türkiye. AI tools assist with drafting and research. Source documentation in the existing archive is uneven, and articles are being reviewed and corrected. The Editorial Team byline identifies editorial responsibility; it does not certify specialist or independent human review. Where we compare products, anything built by our own team is labelled as such — see the editorial guidelines and About page for how corrections and disclosures work.
Related Articles

History of Medicine: From Hippocrates to Genomics
Medicine has gone from bloodletting and prayer to gene editing in just a few centuries. Here's how we got there.

André-Marie Ampère: Electromagnetism's Mathematician
Ampère discovered that electric currents create magnetic fields and developed the mathematical framework of electromagnetism. His laws still govern electrical engineering.

AI in Chemistry: Molecular Simulation and the Future of Drug Design
AI is transforming how chemists simulate molecules and design drugs, from AlphaFold's structure predictions to generative pipelines that trim years off discovery timelines.

How Machine Learning Is Accelerating Materials Discovery
AI is compressing decades of trial-and-error chemistry into weeks, helping scientists discover new compounds with unprecedented precision.

AI-Driven Scientific Discovery: Can Machines Generate Hypotheses?
Beyond automating experiments, AI systems are beginning to propose novel scientific hypotheses—a capability that could fundamentally change how science is done.

Deep Learning and Microscopy: Seeing Materials at the Atomic Scale
AI is giving electron microscopes superhuman vision—resolving atomic structures, identifying defects, and automating analyses that once took weeks.