Data-Efficient Molecular Generation with Hierarchical Textual Inversion

Seojin Kim, Jaehyun Nam, Sihyun Yu, Younghoon Shin, Jinwoo Shin

Introduction

Deep generative models have revolutionized molecular design, but they typically have an insatiable appetite for data, requiring hundreds of thousands of examples to learn the underlying distribution of chemical space. In real-world drug discovery, researchers rarely have this luxury. Often, they only have access to a handful of "active" molecules for a specific biological target—a strictly "low-shot" regime.

Existing methods struggle in these scenarios. Adapting "Textual Inversion"—a technique popularized by personalized image generation (e.g., learning a new concept like a specific dog from 3-5 images)—directly to molecules fails. While all photos of a specific dog look similar, two molecules with the same biological function might have completely different structures. A single "concept token" simply isn't expressive enough to capture the structural diversity of a chemical class.

To address this, researchers introduce HI-Mol (Hierarchical textual Inversion for Molecular generation), a novel framework that brings the power of textual inversion to drug discovery by representing molecules through a hierarchy of shared, cluster-wise, and molecule-specific token embeddings.

The HI-Mol Framework

Instead of trying to map a broad chemical concept to a single new word or token, HI-Mol utilizes a multi-level embedding strategy paired with a frozen foundation model.

Overview of the HI-Mol framework, illustrating hierarchical textual inversion and embedding interpolation.
  1. Hierarchical Textual Inversion: The model defines three distinct levels of tokens:
  2. Shared Token ($[S^*]$): Captures overarching features common to the entire dataset.
  3. Intermediate Tokens ($\{[I^*_k]\}$): Learns cluster-wise features (e.g., "molecules with long carbon chains"). The model assigns molecules to these clusters in an unsupervised manner during training.
  4. Detail Tokens ($\{[D^*_n]\}$): Captures the unique, fine-grained structural features of each individual molecule.
  5. Frozen Foundation: HI-Mol leverages a pre-trained, frozen text-to-molecule model (MolT5). Only the new hierarchical embeddings are optimized to reconstruct the training molecules' SMILES strings, preventing catastrophic forgetting and reducing computational overhead during training.
  6. Embedding Interpolation-based Sampling: To generate new molecules, the system does not simply prompt the model with text. Instead, it takes the learned embeddings of two different molecules and interpolates between them at the intermediate and detail levels. This allows the model to smoothly explore the latent "manifold" between known data points.
  7. SMILES Modification Algorithm: Because string-based generation can occasionally produce chemically invalid outputs, a simple post-processing algorithm is included to fix common syntax errors like unclosed rings or branches.

Key Insights: Chemical Priors in Latent Space

One of the most striking findings of HI-Mol is that the unsupervised intermediate tokens naturally learn chemically meaningful clusters. Without any explicit chemical knowledge provided during training, the model groups molecules by structural motifs.

Examples of chemical clusters automatically learned by the intermediate tokens.

By splitting the representation into shared, cluster, and detail levels, the model avoids the "mode collapse" typically seen in single-token inversion. It successfully learns that a group of molecules shares a broad function (via the shared token) while acknowledging and preserving their distinct structural differences (via the detail tokens). Furthermore, the study found that interpolating in this structured embedding space is far more effective for generating structurally valid and novel molecules than standard text prompting.

Experimental Results and Data Efficiency

The researchers evaluated HI-Mol across several standard benchmarks, including MoleculeNet (HIV, BBBP, BACE) for low-shot generation, QM9 for data efficiency, and GuacaMol for complex multi-property optimization.

  • Extreme Data Efficiency: On the QM9 dataset, HI-Mol trained on just 2% of the data outperformed the previous state-of-the-art model (STGG) trained on 100% of the data in terms of Frechet ChemNet Distance (FCD). This represents a 50x reduction in required training data.
  • Boosting Property Prediction: Molecules generated by HI-Mol can serve as high-quality "synthetic data" to train better property predictors. In a 16-shot classification task on the BACE dataset, augmenting the training set with HI-Mol generated molecules improved the ROC-AUC by 3.53 points.
  • Validity and Novelty: Across MoleculeNet datasets, HI-Mol consistently achieved near 100% validity (aided by the modification algorithm) and 100% novelty. This proves the model does not merely memorize the training set but actively creates entirely new, chemically plausible structures.

Limitations and Future Directions

While highly data-efficient, HI-Mol relies on large language models (like MolT5-Large), which require significant GPU VRAM (approximately 4.8GB) for sampling. Additionally, when optimizing for specific properties like PLogP, the model can occasionally fall victim to "reward hacking," generating very large molecules that are theoretically optimal but practically difficult to synthesize.

Finally, the method currently relies on 1D SMILES strings. Moving toward 3D molecular graphs or point clouds within this hierarchical framework could capture even more nuanced structural information, representing a promising avenue for future research.

Summary updated

BibTeX
@inproceedings{kim2024data,
  author = {Seojin Kim and Jaehyun Nam and Sihyun Yu and Younghoon Shin and Jinwoo Shin},
  title = {{Data-Efficient Molecular Generation with Hierarchical Textual Inversion}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=8KeD4mEh3j},
}
Figure