Improving Chemical Understanding of LLMs via SMILES Parsing

Yunhui Jang, Jaehyung Kim, Sungsoo Ahn

TL;DR

Large Language Models (LLMs) are powerful but struggle to understand molecular structures encoded in SMILES strings, hindering their application in chemistry. This paper introduces CLEANMOL, a framework that trains LLMs on a suite of deterministic SMILES parsing tasks, significantly improving their structural comprehension and leading to state-of-the-art performance on downstream chemical tasks.

What Problem Does This Paper Address?

LLMs have shown immense promise in scientific discovery, particularly in chemistry. However, a fundamental hurdle is their ability to accurately interpret molecular structures, which are often represented as SMILES (Simplified Molecular Input Line Entry System) strings. SMILES, while syntactically compatible with LLMs, encodes complex structural information, including rings and branches, using non-contiguous tokens. Current LLMs often fail at basic tasks like counting rings or even understanding that different SMILES strings can represent the same molecule. This "structural bottleneck" limits their effectiveness in chemical applications. Furthermore, acquiring high-quality, large-scale chemical datasets for training is challenging and expensive, unlike readily available text or image data.

Methods

The core of this work is the CLEANMOL framework, which tackles the SMILES parsing problem through a novel approach:

  • Deterministic SMILES Parsing Tasks: The authors define five specific, deterministic tasks designed to extract structural information from SMILES strings. These tasks fall into two categories:
  • Subgraph Matching: Focuses on local structural features like identifying functional groups, counting rings of specific sizes, and measuring the length of the longest carbon chain.
  • Global Graph Matching: Addresses overall molecular structure by tasks like SMILES canonicalization (generating a unique, standardized SMILES for a molecule) and fragment assembly (combining two SMILES fragments into a valid molecule).
  • CLEANMOL Dataset: A new dataset is constructed, comprising 250,000 molecules annotated with answers for these five parsing tasks. These annotations are automatically generated using cheminformatics tools like RDKit, ensuring scalability and avoiding costly experiments.
  • Two-Stage Training Framework:
    1. Pre-training: LLMs are first pre-trained on the CLEANMOL dataset using the defined parsing tasks. This stage aims to instill a fundamental understanding of molecular structure.
  • Fine-tuning: The pre-trained models are then fine-tuned on downstream chemical applications.
  • Task-Adaptive Data Pruning and Curriculum Learning: To enhance training efficiency, the authors employ a strategy that selects informative molecules and organizes them from easy to difficult, guiding the model's learning process.

Datasets

  • CLEANMOL Dataset: A newly introduced dataset consisting of 250,000 molecules, each annotated for five SMILES parsing tasks (functional group matching, ring counting, chain length measurement, SMILES canonicalization, and fragment assembly).
  • Mol-Instructions Dataset: Used for evaluating downstream tasks, including retrosynthesis, reagent prediction, and forward reaction prediction.
  • MoleculeNet Dataset: Used for evaluating molecular property prediction tasks (classification and regression).
  • ZINC250k Dataset: The source for molecules used in the CLEANMOL benchmark.

Key Insights and Ideas

  • The "Structural Bottleneck" is Real: The paper strongly validates that LLMs' limitations in chemistry stem not from a lack of general knowledge, but from a fundamental inability to parse and understand molecular structures encoded in strings like SMILES.
  • Determinism is Key: Unlike traditional NLP objectives (like masked language modeling) which can have ambiguous outputs, the deterministic nature of SMILES parsing tasks provides clear, unambiguous supervision, crucial for robust learning.
  • Structure-Aware Pre-training Pays Off: Pre-training LLMs on these explicit structural tasks significantly boosts their performance on downstream chemical applications, even without direct exposure to generation-specific data during pre-training.
  • Scalability is Achievable: The automated generation of annotations for SMILES parsing tasks makes the CLEANMOL dataset highly scalable, allowing for the creation of vast training resources without expensive experimental efforts.

Key Results

  • Improved SMILES Parsing: LLMs fine-tuned with CLEANMOL achieve significantly higher accuracy on SMILES parsing tasks compared to baseline LLMs (e.g., GPT-40, Deepseek-V3-Chat) which perform poorly even with 5-shot prompting. For instance, Llama3.1-8B and Qwen2.5-7B models fine-tuned with CLEANMOL achieve accuracies above 0.90 for most tasks, while baselines struggle to reach 0.60.
  • State-of-the-Art Downstream Performance: CLEANMOL pre-training leads to state-of-the-art or competitive results on various downstream tasks, including molecular generation (retrosynthesis, reagent prediction, forward reaction prediction) and molecular property prediction (classification and regression). For example, Llama3.1-8B + CLEANMOL achieved a 0.998 validity score in molecular generation and outperformed other models in several metrics.
  • Effectiveness of Data Pruning and Curriculum Learning: The proposed data pruning strategy and curriculum learning approach further enhance the performance of the CLEANMOL framework.

Limitations and Future Work

  • Limited Structural Information: The current SMILES parsing tasks do not incorporate 3D conformational information, which is vital for many biological and physicochemical applications. They also don't capture more nuanced chemical features like stereochemistry or electronic effects.
  • Language-Specific Scope: The current work is limited to English and doesn't explore applicability across other languages.
  • Model and Dataset Scale: Experiments were conducted on LLMs up to 8B parameters. Scaling the framework to larger models (e.g., 70B+) and larger datasets requires further investigation.
  • Future Work: The authors suggest extending the framework to incorporate 3D information and more complex chemical features, exploring multilingual applications, and scaling to larger models and datasets.

Summary updated

BibTeX
@inproceedings{jang2025improving,
  author = {Yunhui Jang and Jaehyung Kim and Sungsoo Ahn},
  title = {{Improving Chemical Understanding of LLMs via SMILES Parsing}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure