NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Graph Diffusion Transformers are In-Context Molecular Designers

Gang Liu, Jie Chen, Yihan Zhu, Michael Sun, Tengfei Luo, Nitesh V Chawla, Meng Jiang

TL;DR

DemoDiff is a novel foundation model that brings the "in-context learning" (ICL) capabilities of large language models to the world of molecular design. By using a specialized graph diffusion transformer and a new motif-level tokenizer, it can design high-performing molecules for entirely new tasks simply by looking at a few examples, outperforming models 100x its size.

The "Cold Start" Problem in Molecular Design

In the world of drug discovery and materials science, researchers are often faced with a "cold start" problem. There are millions of possible biological assays and material properties to optimize for, but for any specific new task, we might only have a handful of labeled examples.

Traditional specialized models require massive datasets to train from scratch, while Large Language Models (LLMs) often struggle with the complex, non-linear nature of molecular graphs. Furthermore, existing molecular design methods often rely on thousands of "Oracle calls"—expensive simulations or lab tests—to find a single good candidate.

In-context molecular design using molecule-score pairs as demonstrations.

The authors sought to create a molecular foundation model that can generalize to new tasks using only a few demonstrations, much like how GPT-4 can learn a new linguistic task from a few examples in a prompt. Instead of relying on text prompts, this model learns the desired chemical properties directly from a small set of molecule-score pairs.

Methods: Introducing DemoDiff

The authors introduce DemoDiff (Demonstration-conditioned Diffusion models). Its architecture and training involve several key innovations designed specifically for the complexities of chemistry:

The DemoDiff architecture featuring the Graph Diffusion Transformer and motif-level tokenizer.
  1. In-Context Molecular Design: DemoDiff uses a set of "demonstrations" consisting of molecule-score pairs. The model treats the property scores (normalized between 0 and 1) as "relative positions," allowing the Transformer to understand which molecules are "good" or "bad" for the specific task.
  2. Graph Diffusion Transformer (Graph DiT): The backbone is a denoising transformer that operates directly on graph structures. It attends to the context molecules to guide the generative process, essentially performing implicit Bayesian inference to figure out the "target" concept.
  3. Node Pair Encoding (NPE): To make pretraining scalable, the authors developed a new tokenizer inspired by Byte Pair Encoding (BPE) used in text. NPE iteratively merges frequent neighboring atoms into "motifs." This reduces the number of nodes in a molecule by an average of 5.5x, allowing the model to fit many more examples into its context window.
  4. Consistency Scoring: During inference, the model uses a "consistency score" to filter its own generations. It checks if a generated molecule’s structural similarity to the "positive" examples in the prompt is higher than its similarity to the "negative" ones, effectively self-correcting for false positives.

Datasets and Evaluation

To build a robust foundation model, the authors constructed a massive pretraining dataset of 1.6 million tasks derived from the ChEMBL database (for drugs) and several polymer databases (for materials). This covered 155,000 unique properties and over 1 million unique molecules.

The model was then rigorously tested on 33 design tasks across six diverse categories: Drug Rediscovery, Multi-Objective Optimization (MPO), Structure-Constrained Design, Drug Design, Target-Based Design, and Material Design.

Key Insights

  • Scores as "Positions": In language, word order provides context. In molecular design, the authors realized that the property score provides the context. By encoding these scores using Rotary Position Embeddings (RoPE), the model learns to navigate the chemical space relative to the "good" and "bad" examples provided.
  • The Power of Negative Examples: A surprising finding was that "negative" demonstrations (molecules that perform poorly) are just as important as positive ones. They help the model define the boundaries of the task, preventing it from generating molecules that are structurally similar to known failures.
  • Motifs over Atoms: Representing molecules at the atom level is like reading a book letter-by-letter. By moving to a motif-level representation (NPE), the model captures chemical "semantics" (like functional groups) more effectively and processes information much faster.

Key Results

  • Superior Ranking: Across 33 tasks, DemoDiff achieved an average rank of 4.10, significantly better than 19 other baselines (which ranked between 6.56 and 17.95).
  • Efficiency: Despite having only 0.7 billion parameters, DemoDiff matched or surpassed the performance of closed-source LLMs (like GPT-4o and DeepSeek-V3) that are 100–1000x larger.
  • Zero-Shot Generalization: The model successfully designed molecules for material properties (like gas permeability) and complex biological targets (like PARP1 docking) that it had never seen during training, purely by learning from the provided context.
  • Compression: The NPE tokenizer reduced the median node count from 30 atoms to just 5 motifs, drastically increasing the efficiency of the Transformer's attention mechanism.

Limitations and Future Work

While Node Pair Encoding helps significantly, there is still a limit to how many demonstrations can fit in the model's context window. Future work could explore "long-context" architectures for even more complex tasks. Additionally, the model currently performs slightly better on property-driven tasks (where the goal is a specific score) than on purely structure-constrained tasks (where the goal is a specific shape).

Ultimately, the authors suggest that further scaling the model size and the diversity of the pretraining data—such as including 3D conformations—could unlock even greater design capabilities, solidifying DemoDiff's place as a true foundation model for chemistry.

Summary updated

BibTeX
@inproceedings{liu2026graph,
  author = {Gang Liu and Jie Chen and Yihan Zhu and Michael Sun and Tengfei Luo and Nitesh V Chawla and Meng Jiang},
  title = {{Graph Diffusion Transformers are In-Context Molecular Designers}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=lJ87GN5zJc},
}
Figure