Controllable Molecule Generation via Sparse Representation Editing: An Interpretability-Driven Perspective
Organizations: Department of Computing, The Hong Kong Polytechnic University, Hong Kong SAR, China
Abstract
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
| 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 |
| 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 |
| 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. |
| 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 |
| 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 |
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 |
| Hyperparameter | Value |
|---|---|
| Input Dimension | 1024 |
| Expansion Factor | 40 |
| Hidden (Sparse) Dimension | 40,960 |
| Encoder Activation | ReLU + norm |
| Reconstruction Loss | MSE |
| Sparsity Penalty |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| Constraint Satisfaction Rate | Generation Quality | ||||||||
| Method | GSK3 | JNK3 | QED | SA | 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 |
| Method | LogP ([1,3]) | MW ( ) | TPSA ( ) | HBD ( ) | HBA ( ) | Arom. Rings ( ) | SA ( ) | QED ( ) | 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 |
| 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 |
| Feature ID | Interpretation |
|---|---|
| 1592 | Polarity |
| 7329 | Hydrophilic Groups |
| 38472 | Ionic Nature |
| 29104 | Nonpolar |
| 12945 | Amphiphilic |
| 23847 | Lattice Energy |
| 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. |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
Molecular Generation
Molecular generation develops computational methods to create chemical structures and conformations for discovery, optimization, and structure elucidation.
See all 245 papers