Saved in:
Bibliographic Details
Main Authors: Tao, Wen, Tang, Jing, Chan, Alvin, Hooi, Bryan, Bi, Baolong, Peng, Nanyun, Liu, Yuansheng, Wang, Yiwei
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2509.23099
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866914060747931648
author Tao, Wen
Tang, Jing
Chan, Alvin
Hooi, Bryan
Bi, Baolong
Peng, Nanyun
Liu, Yuansheng
Wang, Yiwei
author_facet Tao, Wen
Tang, Jing
Chan, Alvin
Hooi, Bryan
Bi, Baolong
Peng, Nanyun
Liu, Yuansheng
Wang, Yiwei
contents Molecule generation is key to drug discovery and materials science, enabling the design of novel compounds with specific properties. Large language models (LLMs) can learn to perform a wide range of tasks from just a few examples. However, generating valid molecules using representations like SMILES is challenging for LLMs in few-shot settings. In this work, we explore how LLMs can generate 100% valid molecules. We evaluate whether LLMs can use SELFIES, a representation where every string corresponds to a valid molecule, for valid molecule generation but find that LLMs perform worse with SELFIES than with SMILES. We then examine LLMs' ability to correct invalid SMILES and find their capacity limited. Finally, we introduce SmiSelf, a cross-chemical language framework for invalid SMILES correction. SmiSelf converts invalid SMILES to SELFIES using grammatical rules, leveraging SELFIES' mechanisms to correct the invalid SMILES. Experiments show that SmiSelf ensures 100% validity while preserving molecular characteristics and maintaining or even enhancing performance on other metrics. SmiSelf helps expand LLMs' practical applications in biomedicine and is compatible with all SMILES-based generative models. Code is available at https://github.com/wentao228/SmiSelf.
format Preprint
id arxiv_https___arxiv_org_abs_2509_23099
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle How to Make Large Language Models Generate 100% Valid Molecules?
Tao, Wen
Tang, Jing
Chan, Alvin
Hooi, Bryan
Bi, Baolong
Peng, Nanyun
Liu, Yuansheng
Wang, Yiwei
Computation and Language
Machine Learning
Molecule generation is key to drug discovery and materials science, enabling the design of novel compounds with specific properties. Large language models (LLMs) can learn to perform a wide range of tasks from just a few examples. However, generating valid molecules using representations like SMILES is challenging for LLMs in few-shot settings. In this work, we explore how LLMs can generate 100% valid molecules. We evaluate whether LLMs can use SELFIES, a representation where every string corresponds to a valid molecule, for valid molecule generation but find that LLMs perform worse with SELFIES than with SMILES. We then examine LLMs' ability to correct invalid SMILES and find their capacity limited. Finally, we introduce SmiSelf, a cross-chemical language framework for invalid SMILES correction. SmiSelf converts invalid SMILES to SELFIES using grammatical rules, leveraging SELFIES' mechanisms to correct the invalid SMILES. Experiments show that SmiSelf ensures 100% validity while preserving molecular characteristics and maintaining or even enhancing performance on other metrics. SmiSelf helps expand LLMs' practical applications in biomedicine and is compatible with all SMILES-based generative models. Code is available at https://github.com/wentao228/SmiSelf.
title How to Make Large Language Models Generate 100% Valid Molecules?
topic Computation and Language
Machine Learning
url https://arxiv.org/abs/2509.23099