Controllable molecule generation is crucial for diverse scientific applications, such as drug discovery and materials design. While large language models (LLMs) show great promise, their dense and entangled representations impede precise control over the generation of molecules with bespoke substructures or properties. To address this, we propose Sparse Representation Editing (SpaRE), an interpretability-driven framework for fine-grained and precise control in LLM-based molecule generation. The crux of SpaRE is to learn an overcomplete sparse feature space that disentangles LLM representations into a compact set of latent features corresponding to chemically meaningful concepts. Within this space, we can directly manipulate these concept-aligned latent features to achieve (1) local control, by generating target atoms and functional groups at specified positions; and (2) global control, by customizing the overall structural and physicochemical properties within defined ranges. In this way, our framework advances interpretability from post-hoc analysis to actionable generative control. Experiments show that SpaRE can generate chemically desirable molecules under complex constraints in real-world scenarios, while offering mechanistic insights for quantitative structure-property analysis. The code and demo are available at https://github.com/WanyuGroup/ICML2026_SpaRE.
Figures & tables
Figure 1: SpaRE learns concept-specific activation patterns that connect dense LLM representations to chemically meaningful concepts in latent space. By modulating concept activation strengths, SpaRE steers the corresponding LLM representations toward molecules with desired substructures and properties (dashed boxes denote skipped computations).
Figure 2: Activation patterns for concepts are derived using two schemes: ( Left ) local substructure control of carbon atom and ( Right ) global property control of solubility. For each concept, we select only latent features that are consistently activated ( i.e., activation value >0.5 ) in every sample of that concept and concatenate them to form the concept representation used for its control.
Quality ( ↑ )
Control ( ↑ )
Synthesis ( ↓ )
Efficiency ( ↓ )
Model
Valid
Uniqueness
Novelty
Atom Sta
Completeness
Success Rate
SA score
Time
GNN-Based
MARS
87.24
82.53
84.62
89.82
98.24
50.37
4.12
384.24
MolEvol
88.73
80.96
84.82
94.17
98.92
37.25
4.26
231.27
Diffusion-Based
LDMol
90.23
80.42
80.32
89.57
98.48
26.36
3.96
290.52
Table 1: Site-specific molecule generation on the ChEBI-20 dataset ( Edwards et al., 2021 ) . Quality and controllability are percentages, while synthesizability and efficiency are reported as numerical values. Best and second-best results are marked in bold and underlined.
Figure 3: Distribution of molecules generated under global control of solubility: ( Left ) amplification, ( Middle ) suppression, and ( Right ) controllable tuning by varying activation strength.
Figure 4: ( Top ) The edited molecules optimize lipophilicity while maintaining high scaffold and pharmacophore similarity. ( Bottom ) After optimizing the editing routes, the generated molecules exhibit improved water solubility and synthetic accessibility.
Method
Success
Valid
Novelty
Diversity
MolEvol
88.9
95.1
81.4
67.9
RetMol
93.8
98.7
87.2
71.6
TGM-DLM
94.5
99.7
78.1
67.4
Atomas
95.2
97.6
85.3
72.2
Llamole
90.3
97.3
90.6
68.2
SpaRE ( Ours )
98.1
100.0
96.2
74.9
Table 2: Generation quality (%) for molecules optimized for QED, SA score, and predicted binding affinities to GSK3 β and JNK3, as estimated by the pretrained models ( Jin et al., 2020 ) .
Figure 5: ( Top ) Distribution of generated molecules for oral drugs, showing that three key constraints are precisely optimized within their defined ranges, with SpaRE outperforming all baselines. ( Bottom ) The optimization objectives are achieved in only eight iterations.
Figure 6: The property constraints employed for GSK3 β and JNK3 inhibitor discovery are precisely optimized within target ranges. SpaRE achieves stronger overall performance than the baselines.
Figure 7: Trajectories of iterative property optimization.
Feature ID
Category
Concept
Detailed Interpretation
2107 , 5036 , 10626 , 14729
Functional Group
N-oxide
Recognizes the N-oxide feature for tuning the electronics and solubility of heterocycles.
10113 , 14412
Structural Class
Saturated carbocyclic systems
Generates saturated carbocyclic systems ( e.g., cyclohexane), focusing on sp 3 -rich structures.
2839 , 2872 , 13586
Stereochemistry
Helical chirality
Models helical chirality, a stereochemical feature arising from a molecule’s screw-shaped structure.
14381 , 14624
Chemical Interaction
Hydrogen bond donor/acceptor arrays
Specifies a defined pattern of hydrogen bond donors/acceptors to guide intermolecular interactions.
7 , 77 , 12777
Topology
Branched vs linear chain isomerism
Differentiates between branched and linear topologies of an aliphatic chain.
1601 , 8808 , 11765
Conformation
Acyclic conformation: gauche/trans preference
Understands the energetic preference for gauche vs. trans conformations in acyclic chains.
Table 3: LLM-derived interpretations of latent features, summarizing representational commonalities and reporting each feature’s category, concept, and detailed interpretation. More examples are presented in Table 17 .
Figure 8: The Left Panel: Ablation study on the number of features. The Right Panel: Feature importance based on p -values.
Expansion Factor
Valid
Uniqueness
Novelty
Atom Sta
Completeness
Success Rate
SA Score
10
100.00
78.37
85.93
89.85
99.41
93.52
3.87
20
100.00
77.25
89.98
87.29
99.39
91.43
3.89
40
100.00
81.60
92.10
97.24
99.66
98.92
3.78
80
100.00
76.95
84.23
87.82
99.25
96.47
3.56
100
100.00
74.67
89.51
91.71
98.92
85.74
3.91
Table 4: Ablation study on expansion factor for site-specific molecule generation on the ChEBI-20 dataset ( Edwards et al., 2021 ) . The first six columns report percentages, and the last column reports numerical values.
Layer Choice
Valid
Uniqueness
Novelty
Atom Sta
Completeness
Success Rate
SA Score
0
100.00
79.88
84.31
86.11
98.57
0.92
3.82
4
100.00
75.85
86.02
87.93
99.37
1.46
3.78
8
100.00
78.72
86.74
86.81
98.64
4.02
3.57
12
100.00
73.75
85.38
91.56
99.69
10.52
3.62
16
100.00
79.91
82.47
86.13
99.72
56.61
3.86
20
100.00
80.34
83.04
89.71
99.53
93.59
3.69
Table 5: Ablation study on LLM layer choice for site-specific molecule generation on the ChEBI-20 dataset ( Edwards et al., 2021 ) . The first six columns report percentages, and the last column reports numerical values.
Appendix figures & tables51 assets
Supplementary material from the paper’s appendix.
Appendix
Hyperparameter
Value
Base Model
MolXPT ( Liu et al., 2023b )
Transformer Layers
24
Attention Heads
16
Hidden Dimension
1024
Data Format
Group SELFIES
Max Sequence Length
1024
Appendix
Table 6: Hyperparameters for Fine-Tuning
Hyperparameter
Value
Input Dimension
1024
Expansion Factor
40 ×
Hidden (Sparse) Dimension
40,960
Encoder Activation
ReLU + L2 norm
Reconstruction Loss
MSE
Sparsity Penalty
L1
Appendix
Table 7: Hyperparameters for SAE Training
Figure 9: Distribution of molecules generated under solubility control with LLM layer 4 : ( Left ) amplification, ( Middle ) suppression, and ( Right ) controllable tuning by varying activation strength.
Figure 10: Distribution of molecules generated under solubility control with LLM layer 16 : ( Left ) amplification, ( Middle ) suppression, and ( Right ) controllable tuning by varying activation strength.
Quality ( ↑ )
Control ( ↑ )
Synthesis ( ↓ )
Efficiency ( ↓ )
Model
Valid
Uniqueness
Novelty
Atom Sta
Completeness
Success Rate
SA score
Time
GNN-Based
MARS
87.62
81.62
80.47
89.88
97.83
32.86
4.26
371.28
MolEvol
86.24
78.86
82.81
91.47
96.82
38.43
4.24
252.62
Diffusion-Based
LDMol
86.49
83.01
80.09
89.16
95.24
31.74
3.80
346.19
Appendix
Table 8: Local molecule generation on the GEOM-DRUGS dataset ( Axelrod and Gomez-Bombarelli, 2022 ) . Quality and controllability are reported as percentages, while synthesizability and efficiency are reported as numerical values. Best and second-best results are indicated in bold and underlined, respectively.
Quality ( ↑ )
Control ( ↑ )
Synthesis ( ↓ )
Efficiency ( ↓ )
Dataset
Validity
Uniqueness
Novelty
Atom Stability
Completeness
Success Rate
SA score
Time
ChEBI-20
100.00
99.53
98.38
63.94
82.29
-
7.55
1.82
GEOM-DRUGS
100.00
97.29
96.97
41.51
92.35
-
7.85
1.56
Appendix
Table 9: The results of MCTS-based naive string substitution on two datasets. Quality and controllability are reported as percentages, while synthesizability and efficiency are reported as numerical values.
Model
Valid
Uniqueness
Novelty
Atom Sta
Completeness
Success
SA Score
GPT-5.4
88.60
80.83
83.79
92.11
95.41
56.98
3.97
Claude Opus 4.6
91.02
79.60
84.77
89.74
95.46
66.82
4.02
Gemini 3.0 Pro
92.05
77.53
84.07
91.52
96.91
57.27
3.86
SpaRE ( Ours )
100.00
81.60
92.10
97.24
99.66
98.92
3.78
Appendix
Table 10: Evaluation of recent general-purpose LLMs on local control on the ChEBI-20 ( Edwards et al., 2021 ) . All models are prompted with the same task instructions and decoded under the same post-processing and evaluation pipeline.
Figure 11: Distribution of molecules generated under aromaticity amplification. Aromaticity is evaluated by ASE ( Left ), HOMA ( Middle ), and NICS ( Right ): higher ASE and HOMA, and lower NICS, indicate increased aromaticity.
Figure 12: Distribution of molecules generated under aromaticity suppression. Aromaticity is evaluated by ASE ( Left ), HOMA ( Middle ), and NICS ( Right ): lower ASE and HOMA, and higher NICS, indicate reduced aromaticity.
Figure 13: Tuning activation strength enables adjustment of aromaticity, as measured by ASE ( Left ), HOMA ( Middle ), and NICS ( Right ).
Figure 14: Distribution of molecules generated under global control of rings: amplification ( Left ) and suppression ( Middle ) with smooth tunability via changes in activation strength ( Right ).
Figure 15: Distribution of molecules generated under hydrogen bond acceptor amplification. Hydrogen bonding is evaluated by the count of HBA ( Left ) and HBD ( Right ).
Figure 16: Distribution of molecules generated under hydrogen bond acceptor suppression. Hydrogen bonding is evaluated by the count of HBA ( Left ) and HBD ( Right ).
Figure 17: Tuning activation strength enables adjustment of hydrogen bonding, as measured by the count of HBA ( Left ) and HBD ( Right ).
Figure 18: Distribution of molecules generated under ortho-disubstituted position amplification. Ortho-disubstituted positions are evaluated by their count ( Left ) and steric value ( Right ), with larger steric value indicating more ortho-disubstituted positions.
Figure 19: Distribution of molecules generated under ortho-disubstituted position suppression. Ortho-disubstituted positions are evaluated by their count ( Left ) and steric value ( Right ), with lower steric value indicating less ortho-disubstituted positions.
Figure 20: Tuning activation strength enables adjustment of ortho-disubstituted positions, as measured by their count ( Left ) and steric value ( Right ).
Figure 21: The edited molecules optimize ( Top ) water solubility while maintaining ( Bottom ) high scaffold and pharmacophore similarity, showing SpaRE’s precision in the optimization.
Figure 22: Quantitative estimate of drug-likeness for lipophilicity improvement. Two of the four routes achieve favorable drug-like properties ( i.e., QED ≥ 0.6).
Figure 23: Quantitative estimate of drug-likeness for water solubility improvement. Three of the four routes achieve favorable drug-like properties ( i.e., QED ≥ 0.6).
Figure 24: Visualization of four stepwise bioisosteric editing routes for lipophilicity improvement (Routes 1–4, top to bottom).
Figure 25: Visualization of four stepwise bioisosteric editing routes for water solubility improvement (Routes 1–4, top to bottom).
ID
Original
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Avg.
1_1
2.18
1.55
2.36
3.40
1.70
–
–
–
–
2.24
1_2
2.05
1.60
2.21
3.35
3.80
1.96
–
–
–
2.50
1_3
1.66
1.29
1.85
3.07
1.53
–
–
–
–
1.88
2_1
2.02
2.20
2.17
2.86
3.61
3.42
–
–
–
2.71
2_2
2.02
2.20
2.17
2.86
3.61
3.74
3.55
3.55
3.60
3.03
2_3
2.02
2.20
2.17
2.86
3.61
3.72
3.90
4.25
3.66
3.15
Appendix
Table 11: SA score for 15 representative molecular editing routes. The ID is formatted as “GroupID_RouteID” ( i.e., route #1 from group 1 is denoted as 1_1).
ID
Original
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Avg.
1_1
0.99
0.99
0.96
0.54
0.98
–
–
–
–
0.89
1_2
0.99
0.99
0.91
0.76
0.45
0.99
–
–
–
0.85
1_3
0.99
0.99
0.98
0.78
0.97
–
–
–
–
0.94
2_1
0.99
0.99
0.99
0.95
0.92
0.60
–
–
–
0.91
2_2
0.99
0.99
0.99
0.95
0.92
0.88
0.40
0.40
0.37
0.76
2_3
0.99
0.99
0.99
0.95
0.92
0.71
0.28
0.05
0.26
0.68
Appendix
Table 12: RA score for 15 representative molecular editing routes. The ID is formatted as “GroupID_RouteID” ( i.e., route #1 from group 1 is denoted as 1_1).
Figure 26: The distribution of generated molecules following editing route optimization to increase the number of rotatable bonds.
Figure 27: The distribution of generated molecules following editing route optimization to increase the number of sp3 carbon atoms.
Figure 28: Visualization of molecules with favorable synthetic accessibility and improved water solubility. Introducing carboxylate anion, nitro group, and primary amide at specific sites leads to improved water solubility.
Figure 29: Visualization of molecules with favorable synthetic accessibility and increased rotatable bonds. Introducing benzyl, methyl, or ethyl groups at specific sites increases the number of rotatable bonds.
Figure 30: Visualization of molecules with favorable synthetic accessibility and increased sp3 carbon count. Introducing a cyclohexyl group, an allyl-cyclohexyl group, or disulfide linkages at specific sites increases the number of sp3 carbon atoms.
Figure 31: Distribution of generated molecules for Perindopril. The hard constraints on target molecular weight and LogP are precisely satisfied, while the soft constraints, QED and SA score, are optimized more effectively than baseline models.
Figure 32: Iterative convergence of molecular properties during the optimization process for Perindopril.
Figure 33: Distribution of generated molecules for Aripiprazole. The hard constraints on target molecular weight and LogP are precisely satisfied, while the soft constraints, QED and SA score, are optimized more effectively than baseline models.
Figure 34: Iterative convergence of molecular properties during the optimization process for Aripiprazole.
Figure 35: Distribution of generated molecules for oral drug optimization, showing that five property constraints (with the other three illustrated in Figure 5 ) are precisely optimized within their defined ranges, with SpaRE surpassing all baselines.
Figure 36: Distribution of generated molecules under Lipinski’s Rule of Five, showing that six property constraints are precisely optimized within their defined ranges, with SpaRE surpassing all baselines.
Figure 37: Iterative convergence of molecular properties during the optimization process under Lipinski’s Rule of Five.
Figure 38: Distribution of generated molecules for sublingual drug optimization, showing that eight property constraints are steered toward their target ranges, with SpaRE outperforming all baselines.
Figure 39: Iterative convergence of molecular properties during the optimization process for sublingual drug design.
Constraint Satisfaction Rate
Generation Quality
Method
GSK3 β≥0.5
JNK3 ≥0.5
QED >0.6
SA <4
All
Success
Validity
Novelty
Diversity
TGM-DLM
72.4
69.2
90.6
98.4
44.7
96.1
98.4
77.2
66.9
MolEvol
57.1
61.3
65.6
73.9
17.0
90.1
93.5
82.4
67.3
RetMol
74.1
86.6
92.3
93.3
55.3
95.9
97.2
87.6
72.6
Atomas
72.2
80.8
90.7
93.4
49.5
94.1
97.7
85.2
70.9
Llamole
70.3
73.7
89.0
93.5
43.1
88.2
98.3
91.1
67.1
Appendix
Table 13: Additional multi-target drug discovery results on constraint satisfaction rate (%, ↑ ) and generation quality (%, ↑ ). Best and second-best results are marked in bold and underlined, respectively.
Method
LogP ([1,3])
MW ( <500 )
TPSA ( ≤140 )
HBD ( ≤5 )
HBA ( ≤10 )
Arom. Rings ( ≤3 )
SA ( <5 )
QED ( >0.7 )
All
Original
57.2
74.8
75.0
63.9
68.1
60.5
60.6
32.8
1.9
MolEvol
65.4
84.1
88.4
91.3
92.1
79.0
62.1
22.6
1.6
Llamole
88.3
98.3
96.9
91.9
91.5
77.8
78.8
56.8
21.7
Atomas
90.3
97.6
95.8
96.3
96.0
99.1
91.5
98.4
67.4
RetMol
95.8
98.9
100.0
89.6
93.7
93.9
96.2
0.5
0.2
TGM-DLM
100.0
96.5
94.2
97.1
96.6
94.8
95.4
97.9
78.5
Appendix
Table 14: Quantitative success rate (%, ↑ ) for oral drug design. Best and second-best results are indicated in bold and underlined, respectively.
Model
Oral Drug Design
Sublingual Drug Optimization
Multi-Target Drug Discovery
TGM-DLM
4.43
7.07
17.84
MolEvol
2.40
3.61
8.98
RetMol
10.12
15.99
40.12
Llamole
43.11
64.02
161.77
Atomas
1.92
2.83
7.01
SpaRE ( Ours )
2.18
3.50
6.67
Appendix
Table 15: Runtime for each method (seconds per molecule satisfying the specified constraints, ↓ ). Best and second-best results are indicated in bold and underlined, respectively.
Feature ID
Interpretation
1592
Polarity
7329
Hydrophilic Groups
38472
Ionic Nature
29104
Nonpolar
12945
Amphiphilic
23847
Lattice Energy
Appendix
Table 16: Feature interpretations from the fitted linear model indicate that these features are statistically significant for the prediction of solubility.
Figure 40: The activations for input–output patterns (from LLM layer 10), where the X - and Y -axes represent the input and output of the LLM, respectively. We focus on the most frequently generated output token and identify the input tokens that most strongly activate it.
Feature ID
Category
Concept
Interpretation
21 , 2737 , 10881 , 13815
Functional Group
Peroxide (R-O-O-R’) bond
Recognizes the peroxide (R-O-O-R’) bond, a feature implying reactivity or instability.
1883 , 4374 , 10168 , 13616 , 14625
Structural Class
Scaffold: Piperidine ring
Identifies the piperidine ring as a common saturated heterocyclic scaffold.
6643 , 6749 , 7729 , 9916 , 14095
Structural Class
Scaffold: Oxazole/Thiazole ring
Recognizes oxazole or thiazole rings as key five-membered aromatic scaffolds.
4580 , 12785
Structural Class
Scaffold: Thiophene ring
Identifies the thiophene ring as a sulfur-containing, core aromatic scaffold.
327 , 5576 , 11937 , 12190 , 12674
Functional Group
Sulfone (R-S(=O) 2 -R’)
Recognizes the sulfone group (R-S(=O) 2 -R’), a stable and often electron-withdrawing moiety.
1478 , 5676 , 13132
Stereochemistry
Center of symmetry/meso compounds
Understands the concept of meso compounds: molecules with chiral centers that are achiral overall.
Appendix
Table 17: LLM-derived interpretations of latent features, summarizing commonalities and reporting each feature’s category, concept, and detailed interpretation. Feature groups are not necessarily mutually exclusive, and a latent feature may contribute to multiple higher-level concepts.
Model
Valid
Uniqueness
Novelty
Atom Sta
Completeness
Success Rate
SA Score
MolEvol
92.96
79.61
84.82
81.04
97.89
31.53
4.79
LDMol
95.02
82.27
91.14
94.96
98.62
21.62
3.91
TGM-DLM
97.30
82.78
84.26
93.52
96.39
24.63
4.19
RetMol
93.58
78.03
73.84
82.75
98.23
28.34
4.92
Llamole
94.17
78.59
75.71
89.25
94.71
19.49
4.39
SpaRE ( Ours )
100.00
78.87
90.16
89.85
99.21
96.77
3.98
Appendix
Table 18: Local molecule generation on the PubChemSTM dataset ( Liu et al., 2023a ) . Quality and controllability are reported as percentages, while synthesizability and efficiency are reported as numerical values. Best and second-best results are indicated in bold and underlined, respectively.
Model
Valid
Uniqueness
Novelty
Atom Sta
Completeness
Success Rate
SA Score
MolEvol
91.19
72.48
93.62
89.59
92.92
42.57
4.78
LDMol
96.48
70.48
88.52
86.38
99.64
33.49
3.79
TGM-DLM
95.15
75.91
94.92
84.92
97.44
36.84
4.08
RetMol
96.31
73.65
82.42
87.78
94.50
22.30
4.22
Llamole
96.87
69.70
90.76
91.13
91.58
43.76
4.49
SpaRE ( Ours )
100.00
77.25
96.70
93.98
99.85
91.43
3.85
Appendix
Table 19: Local molecule generation on the MolTextNet dataset ( Zhu et al., 2025 ) . Quality and controllability are reported as percentages, while synthesizability and efficiency are reported as numerical values. Best and second-best results are indicated in bold and underlined, respectively.
Figure 41: Distribution of molecules generated under solubility control on the PubChemSTM dataset ( Liu et al., 2023a ) : ( Left ) amplification, ( Middle ) suppression, and ( Right ) controllable tuning by varying activation strength.
Figure 42: Distribution of molecules generated under solubility control on the MolTextNet dataset ( Zhu et al., 2025 ) : ( Left ) amplification, ( Middle ) suppression, and ( Right ) controllable tuning by varying activation strength.
Method
Accuracy (%, ↑ )
AUC (%, ↑ )
Random 1
53
47
Random 2
54
48
Random 3
50
52
Random 4
52
49
Random 5
48
55
Ours
88
92
Appendix
Table 20: Solubility prediction using ten randomly selected latent features, matched to the dimensionality of the linear probe in Figure 8 ).
Setting
# Removed
Accuracy (%, ↑ )
AUC (%, ↑ )
w/o x1
1
85
88
w/o x1-x2
2
78
83
w/o x1-x3
3
76
79
w/o x1-x4
4
72
75
w/o x1-x5
5
70
72
w/o x1-x6
6
67
64
Appendix
Table 21: Ablation study on solubility prediction features via leave-one-out removal.
Direction
Δ LogP ( ↓ )
Δ Ring Count ( ↑ )
LogP Success Rate (%, ↑ )
Ring Success Rate (%, ↑ )
Random 1
- 0.13
+ 0.03
44.81
47.16
Random 2
+ 0.10
- 0.05
38.97
47.70
Random 3
- 0.02
- 0.19
39.14
39.97
Random 4
- 0.07
- 0.18
47.29
42.54
Random 5
+ 0.07
- 0.20
44.01
41.56
Ours
- 0.99
+ 1.12
92.43
91.60
Appendix
Table 22: Random directions matched in norm for increasing solubility ( i.e., measured by LogP) and the number of rings. Δ indicates the change in value.
Molecular generation develops computational methods to create chemical structures and conformations for discovery, optimization, and structure elucidation.
Large language models possess strong chemical reasoning capabilities, making them effective molecular editors. However, property-relevant information is implicitly entangled across their dense hidden states, providing no explicit handle for property control: a substantial fraction of edits fail to improve or even degrade target properties. To address these issues, we propose SLIM (Sparse Latent Interpretable Molecular editing), a plug-and-play framework that decomposes the editor's hidden states into sparse, property-aligned features via a Sparse Autoencoder with learnable importance gates. Steering in this sparse feature space precisely activates property-relevant dimensions, improving editing success rate without modifying model parameters. The same sparse basis further supports interpretable analysis of editing behavior. Experiments on the MolEditRL benchmark across four model architectures and eight molecular properties show consistent gains over baselines, with improvements of up to 42.4 points.
Mingxu Zhang, Yuhan Li, Lujundong Li +3
The Hong Kong University of Science and Technology (Guangzhou) · Nanjing University of Aeronautics and Astronautics · The 63rd Research Institute, National University of Defense Technology, Nanjing
Molecular design is a central task in drug discovery that requires precise structural reasoning and domain knowledge. While large language models (LLMs) have shown promise in generating high-level editing intentions in natural language, they often struggle to faithfully execute these modifications, particularly when operating on non-intuitive representations like SMILES. We introduce MECo, a framework that bridges reasoning and execution by translating editing actions into executable code. MECo reformulates molecular modification for LLMs as a cascaded framework: generating human-interpretable editing intentions from a molecule and design objective, followed by translating those intentions into executable structural edits via code generation. Our approach achieves over 98% accuracy in reproducing held-out realistic edits derived from chemical reactions and target-specific compound pairs. On downstream benchmarks spanning physicochemical properties and target activities, MECo substantially improves consistency by 38-86 percentage points to 90%+ and achieves higher success rates over SMILES-based baselines while preserving structural similarity. By aligning intention with execution, MECo enables consistent, controllable and interpretable molecular design, laying the foundation for high-fidelity feedback loops and collaborative human-AI workflows in drug discovery.
Wenyu Zhu, Chengzhu Li, Xiaohe Tian +8
Institute for AI Industry Research, Tsinghua University · Department of Computer Science and Technology, Tsinghua University · School of Pharmaceutical Sciences, Peking University +1
Leveraging large language models (LLMs) for molecular generation has shown remarkable potential in chemical and drug design. Current methods primarily rely on supervised training or fine-tuning with limited datasets, which are insufficient to capture complex molecular design objectives. While some approaches attempt to guide generation toward specific goals, they often lack direct optimization mechanisms, making it difficult to align generated molecules with desired properties. To tackle these challenges, we propose LLMol, a principled reinforcement learning framework that directly incorporates verifiable rewards for targeted molecule generation. The key insight is to formulate molecular design as a goal-conditioned sequence prediction task, where verifiable rewards serve as explicit supervision to drive generation toward desired objectives. LLMol follows a two-stage training paradigm combining supervised learning and reinforcement learning. In the first stage, large language models are supervised fine-tuned to capture chemical syntax and molecular distributions. In the second stage, we introduce Reinforcement Learning with Verifiable Rewards (RLVR), which directly integrates property-based reward signals to guide molecular generation toward task-specific objectives. To address the high variance and instability common in discrete sequence optimization, we adopt Group Relative Policy Optimization (GRPO), a stable on-policy algorithm that smooths reward signals and improves training robustness. This framework enables LLMol to effectively handle a range of molecular design tasks, including single-property targeting (e.g., penalized logP, QED) and structure-constrained optimization. Experimental results demonstrate that LLMol consistently outperforms existing methods, achieving higher success rates and improved efficiency across diverse molecular benchmarks.