{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/arxiv-2509-23099","title":"How to Make Large Language Models Generate 100% Valid Molecules?","arxiv_id":"2509.23099","date":"2025-09-27","proceeding":"EMNLP","authors":["Wen Tao","Jing Tang","Alvin Chan","Bryan Hooi","Baolong Bi","Nanyun Peng","Yuansheng Liu","Yiwei Wang"],"abstract":"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.","url_abs":"https://arxiv.org/abs/2509.23099","url_pdf":"https://arxiv.org/pdf/2509.23099","source":{"archive":null,"snapshot":"2025-07-28","note":"not in the Papers with Code archive (frozen at the snapshot)","row_kind":"graph","title_abstract_authors_date":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2509.23099","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2509.23099"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"mentioned_in_github":null,"is_official":null,"provenance":"deterministic:regex_extraction","mentioned_in_paper":null,"url":"https://github.com/wentao228/SmiSelf","reach":null}],"summary":{"ran":5,"ran_honours":7,"ran_draft_wrong":4,"unverified":18},"by_repo_kind":{"found_in_text":{"samples":34,"ran":16,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":34,"samples":[{"code_sha256_prefix":"81b048dbf36c3a27","entry":"Atom","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"81b048dbf36c3a27"}},{"code_sha256_prefix":"dc08b2c505155615","entry":"_build_branch_cache","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"dc08b2c505155615"}},{"code_sha256_prefix":"add60b6dc9899eb1","entry":"_build_ring_cache","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"add60b6dc9899eb1"}},{"code_sha256_prefix":"10b4141ed789febc","entry":"_build_update_table","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"10b4141ed789febc"}},{"code_sha256_prefix":"9708695a44e8dd43","entry":"_read_index_from_selfies","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9708695a44e8dd43"}},{"code_sha256_prefix":"b6a16c1dfa930c32","entry":"_strlen","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b6a16c1dfa930c32"}},{"code_sha256_prefix":"4732c4c562dda1a7","entry":"atom_to_smiles","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4732c4c562dda1a7"}},{"code_sha256_prefix":"64f1a0674514e76a","entry":"bond_to_smiles","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"64f1a0674514e76a"}},{"code_sha256_prefix":"32fb62b6dcc59a99","entry":"get_bonding_capacity","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"32fb62b6dcc59a99"}},{"code_sha256_prefix":"99349bade0657ad1","entry":"next_atom_state","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"99349bade0657ad1"}},{"code_sha256_prefix":"9cc50e5d5b436b5a","entry":"next_branch_state","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9cc50e5d5b436b5a"}},{"code_sha256_prefix":"0365f5c8a7ed29d2","entry":"next_ring_state","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0365f5c8a7ed29d2"}},{"code_sha256_prefix":"73356d9638a506bb","entry":"process_branch_symbol","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"73356d9638a506bb"}},{"code_sha256_prefix":"f29a60a9be07632e","entry":"process_ring_symbol","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f29a60a9be07632e"}},{"code_sha256_prefix":"5c6ee0f3e533ee08","entry":"smiles_to_bond","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5c6ee0f3e533ee08"}},{"code_sha256_prefix":"dc75e852fcc0ba0f","entry":"split_selfies","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"dc75e852fcc0ba0f"}},{"code_sha256_prefix":"f2550f1417a99a0a","entry":"Attribution","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f2550f1417a99a0a"}},{"code_sha256_prefix":"882fe047aa89c912","entry":"AttributionMap","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"882fe047aa89c912"}},{"code_sha256_prefix":"1192ef9fe327df5b","entry":"DecoderError","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1192ef9fe327df5b"}},{"code_sha256_prefix":"7aca720417a84830","entry":"DirectedBond","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7aca720417a84830"}},{"code_sha256_prefix":"10f38da4a2db9228","entry":"MolecularGraph","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"10f38da4a2db9228"}},{"code_sha256_prefix":"be668ede7fc5787a","entry":"_build_atom_cache","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"be668ede7fc5787a"}},{"code_sha256_prefix":"d11e5ac8cbe6b3a8","entry":"_derive_mol_from_symbols","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d11e5ac8cbe6b3a8"}},{"code_sha256_prefix":"c4aafd5b6356f5fb","entry":"_derive_smiles_from_fragment","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c4aafd5b6356f5fb"}},{"code_sha256_prefix":"d62276a8a9743437","entry":"_form_rings_bilocally","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d62276a8a9743437"}},{"code_sha256_prefix":"dfb074f8eafbdc02","entry":"_process_atom_selfies_no_cache","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"dfb074f8eafbdc02"}},{"code_sha256_prefix":"c4b81be1f7a91ba1","entry":"_raise_decoder_error","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c4b81be1f7a91ba1"}},{"code_sha256_prefix":"1b1ec6c6cee4f0ed","entry":"_tokenize_selfies","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1b1ec6c6cee4f0ed"}},{"code_sha256_prefix":"45f1bef14e59d6da","entry":"decoder","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"45f1bef14e59d6da"}},{"code_sha256_prefix":"f847c03c18ef8150","entry":"get_index_from_selfies","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f847c03c18ef8150"}},{"code_sha256_prefix":"fccd219f72b04e86","entry":"modernize_symbol","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"fccd219f72b04e86"}},{"code_sha256_prefix":"50e2e5ca727694f5","entry":"mol_to_smiles","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"50e2e5ca727694f5"}},{"code_sha256_prefix":"d3c26747c47c25c4","entry":"process_atom_symbol","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d3c26747c47c25c4"}},{"code_sha256_prefix":"22339558285650e2","entry":"smiles_to_atom","repo":"wentao228/SmiSelf","repo_kind":"found_in_text","path":"smiself/decoder.py","file_url":"https://github.com/wentao228/SmiSelf/blob/HEAD/smiself/decoder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"22339558285650e2"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.CL","source":"arxiv_api"},"syntology_extracted_results":null}