Preference Optimization for Molecular Language Models

Ryan Park, Ryan Theisen, Rayees Rahman, Anna Cichońska, Marcel Patek, Navriti Sahni

TL;DR

This paper demonstrates that Direct Preference Optimization (DPO)—a popular alternative to RLHF in NLP—can effectively align molecular language models with medicinal chemistry goals. By fine-tuning pre-trained generative models (both RNNs and GPTs) on synthetically generated, automatically scored pairs of SMILES strings, the authors achieve dramatic increases in desired molecular properties without training a separate reward model or using complex reinforcement learning.

What Problem Does This Paper Address?

Molecular language models (treating chemical structures as SMILES strings) have become standard tools for de novo molecule generation. However, off-the-shelf generative models simply learn the distribution of their training corpora (e.g., ZINC); they lack a priori awareness of specific downstream constraints that medicinal chemists care about, such as avoiding reactive functional groups, adhering to drug-likeness rules, or exhibiting binding affinity against a target receptor.

While researchers often rely on post-hoc filtering (throwing away invalid molecules after sampling) or complex reinforcement learning (RL) loops, post-hoc filtering is computationally wasteful, and RL algorithms (like PPO) are notoriously brittle and require training explicit reward models. The authors set out to determine whether DPO can directly, stably, and cheaply steer molecular language models toward chemist-preferred chemical spaces.

Methods

The authors adopt Direct Preference Optimization (DPO) to fine-tune two widely used molecular generative architectures:

  • smiles-rnn-base: A 3-layer LSTM with embedding dimension 768 (derived from the MOSES benchmark).
  • smiles-gpt-base: An 8-layer, 8-head causal Transformer with embedding dimension 256 (derived from minGPT).

Instead of requiring an explicit reward model, DPO optimizes the policy directly using the implicit reward formulation: $$\mathcal{L}_{\text{DPO}}(\pi_\theta; \pi_{\text{ref}}) = -\mathbb{E}_{(s_p, s_n)} \left[ \log \sigma \left( \beta \log \frac{\pi_\theta(s_p)}{\pi_{\text{ref}}(s_p)} - \beta \log \frac{\pi_\theta(s_n)}{\pi_{\text{ref}}(s_n)} \right) \right]$$

The workflow proceeds as follows:

  1. Sample: Generate candidate SMILES strings ($N = 100{,}000$) from a pre-trained reference model ($\pi_{\text{ref}}$).
  2. Score & Pair: Automatically evaluate molecules to form pairs $(s_p, s_n)$ where the preferred candidate $s_p$ outperforms $s_n$.
  3. Align: Fine-tune the model with DPO using RMSProp on a single GPU.

The authors evaluate this pipeline on two distinct tasks:

  1. Medicinal Chemistry Filter (MCF) Alignment: A binary pass/fail condition combining 91 SMARTS structural filters (undesirable/reactive moieties), molecular weight limits (300–600 Da), chiral center counts ($<2$), and ring counts ($<8$).
  2. Target Bioactivity Optimization (EGFR): Directing generation toward inhibitors of the cancer-relevant kinase EGFR. The authors first fine-tuned the base models on general kinase inhibitors, then scored 100,000 synthetic molecules using an auxiliary Random Forest classifier trained on experimental $\text{IC}_{50}$ data ($<100\text{ nM}$ active, $>500\text{ nM}$ inactive).

Datasets

  • MOSES Benchmark: 1.9 million lead-like molecules from ZINC Clean Leads used for initial pre-training.
  • ChEMBL:
  • 115,000 kinase inhibitors used for unsupervised domain adaptation prior to EGFR alignment.
  • 3,485 EGFR $\text{IC}_{50}$ bioactivity measurements (2,568 active, 917 inactive) used to train the Random Forest surrogate classifier.
  • Synthetic Preference Sets: For each alignment task, 100,000 candidate SMILES strings sampled directly from the base models and labeled via automated filters or surrogate classifiers.

Key Insights and Ideas

  • Cheap Synthetic Preference Generation: Unlike human-in-the-loop NLP tasks, chemical properties and rule-based structural filters can be computed rapidly in silico. This allows large-scale preference datasets (100k pairs) to be generated on demand at virtually zero marginal data-collection cost.
  • Preservation vs. Collapse Depends on Positive Density:
  • When preferred examples are abundant in the base model's samples (~50% pass rate in the MCF task), DPO drastically boosts the target metric with virtually no drop in molecular validity, uniqueness, or internal diversity.
  • When preferred examples are sparse (~9% active rate in the EGFR task), DPO still produces massive relative gains in active compounds, but causes notable degradation in diversity and uniqueness (mode collapse toward narrow active chemical subspaces).

Key Results

All evaluations were computed over 10,000 sampled molecules:

  • Medicinal Chemistry Filters (MCF):
  • Pass Rate ($\text{FracPassesMCF}$):
  • RNN: increased from 53.2% to 87.2% (+65%).
  • GPT: increased from 51.7% to 92.7% (+79%).
  • Collateral Metrics: Validity remained essentially untouched (0.995 $\rightarrow$ 0.994), while internal diversity decreased by $\le 1.1\%$.
  • EGFR Bioactivity Optimization:
  • Fraction Predicted Active ($\text{FracPredActive}$):
  • RNN: increased from 9.6% to 60.2% (+527%).
  • GPT: increased from 9.0% to 79.0% (+778%).
  • Diversity / Validity Trade-off: Validity dropped from 93.9% to 87.1% (GPT), uniqueness dropped from 92.7% to 76.3% (GPT), and internal diversity fell by 7.5% (GPT) and 4.2% (RNN).

Limitations and Future Work

  • Loss of Chemical Diversity: When training data has few positive examples, DPO tends to shrink the diversity of generated candidates. Developing regularization techniques or sampling strategies to mitigate this remains open.
  • Binarization of Continuous Properties: DPO relies on categorical preference orderings ($s_p \succ s_n$). Binarizing continuous pharmacological metrics (like binding affinities or docking scores) discards valuable magnitude information.
  • Surrogate Classifier Approximations: The bioactivity task relies on a random forest proxy rather than wet-lab validation or full physics-based docking.
  • Human Chemist Feedback: The authors only evaluated automated objective functions; incorporating manual feedback from expert chemists is highlighted as a promising next step.

Summary updated

BibTeX
@inproceedings{park2023preference,
  author = {Ryan Park and Ryan Theisen and Rayees Rahman and Anna Cichońska and Marcel Patek and Navriti Sahni},
  title = {{Preference Optimization for Molecular Language Models}},
  booktitle = {GenBio @ NeurIPS},
  year = {2023},
  url = {https://openreview.net/forum?id=EKt4NQZ47U},
}
Figure