AgentDrug: Utilizing Large Language Models in an Agentic Workflow for Zero-Shot Molecular Optimization

Le Huy Khiem, Hua Ting, Nitesh V. Chawla

Abstract

Molecular optimization—modifying a given molecule to improve desired properties—is a fundamental task in drug discovery. While Large Language Models (LLMs) hold the potential to solve this task using natural language to drive the optimization, straightforward prompting achieves limited accuracy. In this work, we propose AgentDrug, an agentic workflow that leverages LLMs in a structured refinement process to achieve significantly higher accuracy. AgentDrug defines a nested refinement loop: the inner loop uses feedback from cheminformatics toolkits to validate molecular structures, while the outer loop guides the LLM with generic feedback and a gradient-based objective to steer the molecule toward property improvement. We evaluate AgentDrug on benchmarks with both single- and multi-property optimization under loose and strict thresholds. Results demonstrate significant performance gains over previous methods. With Qwen-2.5-7B, AgentDrug improves accuracy on single-property objectives by up to 29.0% and on multi-property objectives by 14.9%.

Introduction

In the field of drug discovery, molecular optimization is a critical step where a lead molecule is modified to enhance specific properties, such as solubility (LogP), polar surface area (TPSA), or drug-likeness (QED), while preserving its core structural scaffold. Traditionally, this process relies on expert intuition or data-intensive reinforcement learning (RL) models.

While LLMs have emerged as versatile tools for chemical tasks, they struggle with two primary issues in molecular optimization:

  1. Molecular Hallucination: LLMs frequently generate invalid SMILES strings (textual representations of molecules) that violate chemical rules, such as incorrect valency or unclosed rings.
  2. Vague Guidance: Standard zero-shot or few-shot prompting often lacks the precise feedback necessary to navigate the high-dimensional chemical space effectively.

AgentDrug addresses these challenges by transforming LLMs into precise optimizers through a structured, agentic workflow that requires no specialized training on labeled chemical pairs.

Methods: The AgentDrug Workflow

AgentDrug introduces a nested refinement architecture designed to ensure both structural validity and property improvement.

Comparison of the ChatDrug baseline and the proposed AgentDrug workflow, highlighting the nested refinement loops.

The Inner Loop: Structural Validation

To combat molecular hallucination, AgentDrug employs an inner loop focused on structural integrity. Every SMILES string generated by the LLM is passed to RDKit, a standard cheminformatics toolkit. If the molecule is invalid, RDKit provides a specific ParseError. This error is returned to the LLM as feedback, prompting it to refine the structure until a valid molecule is produced.

The Outer Loop: Property Optimization

Once a valid molecule is obtained, the outer loop focuses on property enhancement. AgentDrug utilizes two key mechanisms:

  • Natural Language Gradient: Instead of generic feedback, the system calculates the numerical difference between the current and target property values. This is translated into a "natural language gradient" (e.g., "Increase LogP by 0.66"), providing the LLM with a clear direction for modification.
  • In-Context Retrieval: The workflow retrieves a similar molecule from a reference database (e.g., ZINC) that already satisfies the target properties. This molecule serves as a structural template, helping the LLM understand successful modifications in a zero-shot manner.

Experimental Setup

The researchers evaluated AgentDrug using 500 molecules sampled from the ZINC database. The optimization targets included LogP, TPSA, and QED, tested in both single-property and multi-property configurations. The workflow was benchmarked using various open-source models, including Qwen-2.5 (3B and 7B) and LLaMA-3.1 (8B and 70B), and compared against the iterative baseline ChatDrug.

Key Results

AgentDrug demonstrates a substantial improvement in optimization success rates while maintaining high structural similarity to the starting molecules.

Performance comparison of AgentDrug vs. ChatDrug, showing higher accuracy across different similarity thresholds.

Key findings include:

  • Significant Accuracy Gains: Using Qwen-2.5-7B, AgentDrug achieved a 28.9% to 29.0% improvement in accuracy for single-property tasks compared to ChatDrug.
  • Multi-Property Success: In complex scenarios requiring the simultaneous optimization of multiple traits, AgentDrug saw gains of up to 14.9%.
  • Zero-Shot Efficiency: Unlike specialized RL methods like REINVENT, AgentDrug achieves these results without any task-specific fine-tuning, making it highly adaptable to new chemical domains.

Conclusion and Future Work

AgentDrug proves that an agentic, feedback-driven workflow can significantly enhance the capabilities of LLMs in specialized scientific domains like chemistry. By decoupling structural validation from property optimization, the system achieves a level of precision previously unattainable with standard prompting.

Future research directions include reducing computational overhead and enhancing the "gradient" signal to include specific chemical instructions (e.g., "add a hydroxyl group") to further bridge the gap between AI and human chemists.

Summary updated

BibTeX
@misc{khiem2024agentdrug,
  author = {Le Huy Khiem and Hua Ting and Nitesh V. Chawla},
  title = {{AgentDrug: Utilizing Large Language Models in an Agentic Workflow for Zero-Shot Molecular Optimization}},
  year = {2024},
  eprint = {2410.13147},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.13147},
}
Figure