SparseChem: Fast and accurate machine learning model for small molecules

Adam Arany, Jaak Simm, Martijn Oldenhof, Yves MoreauarXiv 2022

TL;DR

SparseChem is an open-source, highly scalable multi-task learning library designed specifically for biochemical applications like drug discovery. By natively supporting ultra-high-dimensional sparse inputs and outputs, it allows researchers to train hybrid classification and regression models on millions of compounds and tens of thousands of tasks in just minutes.

What Problem Does This Paper Address?

Predicting the bioactivity and toxicity of small molecules is a cornerstone of modern drug discovery. However, high-quality experimental data for any single biological target is often scarce. Multi-task learning (MTL) addresses this by training a single model to predict multiple tasks simultaneously, allowing the model to share learned representations across related assays.

The challenge lies in scale. Standard molecular descriptors, such as Extended-Connectivity Fingerprints (ECFP), generate ultra-high-dimensional sparse vectors containing millions of potential features. When multiplied by millions of compounds and tens of thousands of biological tasks, standard deep learning frameworks hit severe memory and computational bottlenecks. SparseChem was developed to bridge this gap, providing a fast, memory-efficient tool tailored for industry-scale QSAR (Quantitative Structure-Activity Relationship) modeling.

Methods

SparseChem introduces a flexible multi-task neural network architecture implemented both as a command-line tool and a PyTorch module. Its core innovations include:

  • Sparse Input Layer: A specialized sparse linear layer that natively handles million-dimensional sparse chemical descriptors without blowing up GPU memory.
  • Sparse Training Loss: The loss function is computed only on observed data points. This allows the system to scale to massive multi-task setups (up to 30,000 tasks) where the task matrix itself is highly incomplete.
  • Censored Regression Support: Real-world biochemical data often includes bounded values (e.g., "activity concentration is greater than $X$"). SparseChem introduces one-sided square loss functions to handle upper and lower censoring natively via a censoring mask matrix.
  • Hybrid Architectures: It allows classification (e.g., active/inactive) and regression (e.g., exact binding affinity) tasks to be trained together within the same network, improving training speed and representation accuracy.
  • Internal Mini-Batching: This technique accumulates gradients over smaller sub-batches, enabling the use of larger effective mini-batch sizes than would normally fit into GPU memory.

Datasets

The package was benchmarked using a filtered subset of ChEMBL 29, a standard open-source database of bioactive molecules.

  • Scale: 424,000 compounds and 888 assays.
  • Sparsity: Over 666,299 total measurements, resulting in a matrix sparsity of 0.18%.
  • Features: ECFP radius 3 fingerprints computed via RDKit.
  • Validation: A 5-fold cross-validation split based on chemical clusters to ensure robust generalization testing.

Key Insights and Ideas

  • Embracing Sparsity Natively: Instead of trying to compress or densify molecular fingerprints, SparseChem proves that keeping the data sparse throughout the input and loss layers yields massive computational advantages without sacrificing accuracy.
  • The Power of Hybrid Training: By allowing classification, standard regression, and censored regression to coexist in one network, the model leverages the symbiotic relationship between different data types of the same biological target.
  • Censoring Matters (In Theory): Integrating censored data prevents researchers from having to throw away bounded experimental results, though its practical impact depends heavily on the dataset composition.

Key Results

  • High Speed and Scalability: SparseChem can complete a full training run of 420,000 compounds and 3,500 tasks in 2 minutes on a modern NVIDIA V100 GPU. On an older NVIDIA TITAN Xp, it achieved training speeds of 11 to 15 epochs per minute.
  • Classification Performance: Achieved an AUC-ROC of 0.794 and an AUC-PR of 0.717 on the ChEMBL 29 benchmark.
  • Regression Performance: Achieved an $R^2$ score of 0.358 and a Pearson correlation of 0.620.
  • Censored Regression Performance: Achieved an $R^2$ of 0.356 and a Pearson correlation of 0.621.

Limitations and Future Work

While SparseChem introduces robust support for censored regression, the authors noted that using censored values did not result in a significant performance difference on this specific ChEMBL 29 dataset. Future work could explore datasets where censored data plays a more critical role. Additionally, the paper focuses primarily on sparse linear layers and multi-task MLPs; extending these sparse optimization techniques to graph neural networks (GNNs) or transformers for molecular data remains an open avenue.

Summary updated

Abstract

SparseChem provides fast and accurate machine learning models for biochemical applications. Especially, the package supports very high-dimensional sparse inputs, e.g., millions of features and millions of compounds. It is possible to train classification, regression and censored regression models, or combination of them from command line. Additionally, the library can be accessed directly from Python. Source code and documentation is freely available under MIT License on GitHub.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
full training run (420,000 compounds and 3,500 tasks)SparseChemtraining time2 minutestasks=3,500 · hardware=NVIDIA V100 · compounds=420,000
Source quote
L14: SparseChem was built with industry scale data sets in mind, and for example, can complete a full training run of 420,000 compounds and 3,500 tasks in 2 minutes on a modern GPU, e.g., NVIDIA V100.
BibTeX
@misc{arany2022sparsechem,
  author = {Adam Arany and Jaak Simm and Martijn Oldenhof and Yves Moreau},
  title = {{SparseChem: Fast and accurate machine learning model for small molecules}},
  year = {2022},
  eprint = {2203.04676},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.04676},
}
Figure