HuggingMolecules: An Open-Source Library for Transformer-Based Molecular Property Prediction (Student Abstract)

Piotr Gainski, Lukasz Maziarka, Tomasz Danel, Stanislaw Jastrzebski

Introduction

Predicting chemical properties such as toxicity or solubility is a fundamental challenge in drug discovery. While Transformer-based models have recently achieved state-of-the-art performance in this domain, their implementations remain fragmented across various repositories with inconsistent APIs. This lack of standardization hinders researchers from comparing models or integrating them into existing workflows. HuggingMolecules addresses this by providing an open-source Python library that brings a unified, "HuggingFace-style" experience to molecular property prediction.

Library Architecture

The HuggingMolecules library is designed with a modular architecture to ensure ease of use and extensibility. It consists of two primary modules:

  1. Core Logic (src/): Each model implementation is divided into three classes:
  2. Configuration: Handles hyperparameter management.
  3. Featurization: Converts SMILES strings into numerical features (graphs or text sequences).
  4. Models: Provides the PyTorch implementation of the architecture. A key feature is the from_pretrained() method, which allows users to instantly download and cache pre-trained weights.

  5. Experimental Framework (experiments/): Built on PyTorch Lightning, this module provides standardized scripts for training, hyperparameter tuning via the Optuna package, and benchmarking. It integrates with the Therapeutics Data Commons (TDC) for seamless dataset access.

Benchmarking and Evaluation

The authors evaluated the library's models—MAT, ChemBERTa, GROVER, and MolBERT—across nine datasets covering physical chemistry (FreeSolv, QM7), ADME properties (Caco-2, Clearance, HIA, Bioavailability, PPBR, BBBP), and toxicity (Tox21-NR-AR).

A critical insight from this work is the distinction between graph-based and textual molecular representations. While some models treat molecules as SMILES strings (text), others leverage graph structures (atoms as nodes, bonds as edges). The library provides a standardized benchmarking procedure, using 10 learning rates across 6 data splits, to ensure fair comparisons.

Results and Discussion

The comprehensive benchmarking revealed several key trends in model performance:

  • Superiority of Graph-Based Transformers: Models that incorporate structural graph information, such as GROVER and MAT, generally outperformed textual Transformers like ChemBERTa and MolBERT.
  • Outperforming Baselines: The Transformer models implemented in the library frequently surpassed the non-transformer state-of-the-art baseline, D-MPNN.
  • Impact of Pre-training Scale: For the MAT model, increasing the pre-training dataset from 200k to 20M molecules resulted in significant performance gains, highlighting the importance of large-scale pre-training.
Comparison of model performance ranks across multiple molecular property prediction tasks. Lower rank indicates better performance.

As shown in the figure above, graph-based models like GROVER and MAT variants consistently achieve lower (better) median ranks compared to textual models like ChemBERTa and the D-MPNN baselines across the tested tasks.

Conclusion and Future Work

HuggingMolecules standardizes the workflow for molecular Transformers, lowering the barrier to entry for researchers in chemistry and drug discovery. While the current release includes four major models, the library is designed to be easily extensible. Future developments will focus on adding newer architectures, addressing the high computational costs of large Transformers, and expanding the library's capabilities to include molecular generation.

Summary updated

BibTeX
@inproceedings{gainski2022huggingmolecules,
  author = {Piotr Gainski and Lukasz Maziarka and Tomasz Danel and Stanislaw Jastrzebski},
  title = {{HuggingMolecules: An Open-Source Library for Transformer-Based Molecular Property Prediction (Student Abstract)}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i11.21611},
}
Figure