Modern Hopfield Networks for Few- and Zero-Shot Reaction Prediction

Philipp Seidl, Philipp Renz, Natalia Dyubankova, Paulo Neves, Jonas Verhoeven, Jörg K. Wegner, Sepp Hochreiter, Günter KlambauerarXiv 2021

TL;DR

This paper introduces a novel approach to predicting chemical reaction templates for retrosynthesis using Modern Hopfield Networks (MHNs). By adapting MHNs to associate molecules and reaction templates, the model effectively leverages structural information within templates, leading to significantly improved performance, especially for rare or unseen templates, and achieving faster inference speeds compared to existing methods.

What Problem Does This Paper Address?

The discovery of new drugs and materials hinges on efficiently finding synthesis routes for target molecules. Computer-assisted synthesis planning (CASP) methods aim to automate this process, with template-based approaches being a popular strategy. These methods rely on pre-defined reaction "templates" that describe how molecules transform. A key challenge is "template relevance prediction": determining which templates are likely to yield a viable reaction for a given product molecule. Existing methods often treat templates as distinct categories, which struggles with the vast number of rare or unique templates found in chemical reaction datasets. This leads to poor performance, particularly in "few-shot" or "zero-shot" learning scenarios where templates have few or no training examples. Furthermore, many template-based methods are computationally expensive due to complex subgraph matching.

Methods

The core innovation of this paper is the application of Modern Hopfield Networks (MHNs) to the problem of reaction template prediction. Unlike traditional methods that treat templates as independent classes, MHNs are used to learn associations between molecules and reaction templates by treating them as different modalities.

Here's a breakdown of their approach:

  • Molecule and Template Encoders: Both input molecules and reaction templates are first encoded into vector representations using neural networks (e.g., fully-connected networks with fingerprints).
  • Hopfield Layers for Association: The encoded molecule representation acts as a "state pattern" in the Hopfield network, while the encoded template representations form the "stored patterns" in a memory matrix. The Hopfield layer then learns to associate the molecule state with the relevant template patterns. This allows the model to leverage the structural information within the templates themselves, enabling generalization across similar templates.
  • Static Memory: A key feature of MHNs, as adapted here, is their use of a static memory. This means the learned associations are independent of the specific input molecule, allowing for efficient retrieval and generalization.
  • Fingerprint Filter (FPF): A computationally cheap substructure screen is used as a post-processing step to filter out non-applicable templates, further improving efficiency.

Datasets

The authors utilize publicly available chemical reaction datasets:

  • USPTO-sm and USPTO-lg: These datasets are derived from the USPTO dataset and are used for evaluating template relevance prediction. USPTO-sm is a smaller subset (approx. 40k samples), while USPTO-lg is larger (approx. 443k samples). The preprocessing involves extracting reaction templates using rdchiral.
  • USPTO-50k: This dataset is used for evaluating single-step retrosynthesis. It's a preprocessed version of the USPTO dataset, with a different splitting procedure and without a filtering step that excludes samples where template application doesn't yield the reactants.

Key Insights and Ideas

  • Templates are not just classes: The most significant insight is that treating reaction templates as distinct categories is a bottleneck. By using MHNs, the model can learn to associate molecules with templates based on their structural similarities, enabling generalization and improving performance on rare templates.
  • Leveraging template structure is key: The MHN architecture allows the model to learn from the internal structure of reaction templates, not just their occurrence frequency. This is crucial for handling the long-tail distribution of templates in real-world datasets.
  • Few-shot and zero-shot learning are achievable: The ability to generalize across templates means the model performs well even on templates with very few or no training examples, a critical advantage for real-world chemical discovery.
  • Efficiency gains are substantial: The MHN approach, combined with the fingerprint filter, achieves significantly faster inference speeds compared to transformer-based methods, making it more practical for large-scale applications.

Key Results

  • Template Relevance Prediction: The proposed MHN model achieves state-of-the-art performance on USPTO-sm and USPTO-lg datasets for template relevance prediction, particularly outperforming baseline methods for rare and unseen templates. For instance, on samples with templates not seen during training, the MHN model achieves far above random accuracy, while DNN models perform very poorly.
  • Single-Step Retrosynthesis: On the USPTO-50k benchmark, the MHN-based method (MHNreact) achieves state-of-the-art performance for top-k accuracy for k ≥ 5.
  • Inference Speed: The MHN approach demonstrates inference speeds up to two orders of magnitude faster than Transformer-based methods while achieving comparable or better performance. This is a significant practical advantage.

Limitations and Future Work

  • Radius of Reaction Center: The authors acknowledge that the importance of the radius around the reaction center used for template extraction was not investigated.
  • Secondary Models: The current approach does not re-rank reactants using secondary models (e.g., in-scope filters or dual models), which could potentially further improve performance.
  • Scalability: The scalability of the MHN method for extremely large datasets remains to be investigated.
  • Implementation Optimization: Inference speed, while significantly improved, could potentially be further enhanced through more optimized implementations.
  • Future Directions: The authors envision their approach being used to improve CASP systems and synthesis-aware generative models. They also suggest that this multi-modal learning approach might be relevant in other domains where associating different data modalities with limited data is crucial.

Summary updated

BibTeX
@misc{seidl2021modern,
  author = {Philipp Seidl and Philipp Renz and Natalia Dyubankova and Paulo Neves and Jonas Verhoeven and Jörg K. Wegner and Sepp Hochreiter and Günter Klambauer},
  title = {{Modern Hopfield Networks for Few- and Zero-Shot Reaction Prediction}},
  year = {2021},
  eprint = {2104.03279},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2104.03279},
}
Figure