Enhancing chemical reaction search through contrastive representation learning and human-in-the-loop

Seokho Kang, Youngchun Kwon, Hyunjeong Jeon, Joonhyuk Choi, Youn-Suk Choi, Seokho Kang 0001

Abstract

Traditional chemical reaction search engines rely on explicit substructure queries, creating a "knowledge catch-22" for researchers exploring novel synthetic pathways. This paper presents an intelligent search system that leverages contrastive representation learning and a human-in-the-loop (HITL) feedback mechanism. By utilizing Graph Neural Networks (GNNs) to embed reactions into a vector space and refining these embeddings based on binary user feedback, the system aligns its search results with implicit chemist intuition. Evaluation on the USPTO-479k dataset demonstrates a state-of-the-art Hit@1 of 96.7% and a 10x retrieval speedup via PCA-based dimensionality reduction, making it a viable tool for real-time interactive discovery.

Introduction

Navigating massive chemical reaction databases like Reaxys or SciFinder is a cornerstone of modern drug discovery and materials science. However, traditional search engines rely on "explicit queries"—chemists must define exact substructures or specific reaction conditions. This creates a significant barrier: if a chemist is searching for a new synthetic pathway, they might not yet know the exact rules or constraints they need to find it.

Currently, there is no automated way for a search engine to learn from a user’s intuition. If a chemist sees a result and thinks, "This is almost right, but the catalyst is wrong," they must manually reformulate a complex query. This research addresses the need for a search system that acts more like a recommender system, learning from implicit feedback to navigate the vast "chemical space."

Methodology

The proposed system utilizes a three-pronged technical approach to bridge the gap between human intuition and database retrieval.

Contrastive Representation Learning

The system uses a Graph Neural Network (GNN)—specifically a variant of the Graph Isomorphism Network (GIN)—to transform chemical reactions into numerical vectors (embeddings). It is trained using a contrastive loss function (NT-Xent) that forces the "prediction vector" (derived from reactants and reagents) to be close to the "target vector" (the product) in the embedding space. To preserve quantitative aspects of the input, the researchers employed "sum pooling" in the encoder, ensuring the model understands stoichiometry.

Dimensionality Reduction

To ensure search speeds are viable for real-world use, the authors applied Principal Component Analysis (PCA). They found they could compress 512-dimensional vectors down to just 26 dimensions while retaining 95% of the variance. This drastically speeds up the distance calculations needed for retrieval without sacrificing significant accuracy.

Human-in-the-Loop (HITL) Fine-tuning

This is the core innovation of the study. When a user provides binary ratings (+1 for relevant, -1 for irrelevant) on search results, the system uses a margin ranking loss to fine-tune the GNN in real-time. This process mathematically "pulls" the query vector closer to the positive results and "pushes" it away from the negative ones, refining the search results iteratively.

Initial search results before query refinement
Updated search results after human-in-the-loop feedback

Experimental Setup and Datasets

The study utilized the USPTO-479k dataset, a standard benchmark in cheminformatics containing approximately 478,612 chemical reactions extracted from U.S. patents. The data was split into ~438,000 reactions for training/validation and ~40,000 for testing. While the model architecture supports reagents (catalysts, solvents, etc.), the evaluation focused primarily on reactant-to-product relationships due to inconsistent reagent data in the USPTO set.

Key Results

  • Superior Product Prediction: In a task to predict the ground-truth product from a pool of ~40,000 candidates, the proposed model achieved a Hit@1 of 96.7%, outperforming existing state-of-the-art models like MolR and ReaKE.
  • Massive Speedup: Applying PCA reduced the retrieval time from 0.64 seconds to 0.07 seconds per query on a single CPU core—a nearly 10x improvement that makes the system viable for interactive use.
  • Effective Personalization: The HITL mechanism was tested against five different "user preference scenarios." In all cases, the hit ratio of relevant results improved significantly over three update cycles. Notably, the largest jump in search accuracy occurred after the very first round of user feedback, suggesting the model is highly sensitive to human intuition.

Conclusion and Future Work

By reframing "searching" as an iterative optimization problem where the human and the AI collaborate, this system moves beyond exact matches to find "semantically" similar reactions. Future work will focus on reducing the computational overhead of re-calculating embeddings for entire databases in real-time and improving the explainability of the model's similarity logic. Additionally, integrating richer reagent and condition data (temperature, pressure) will be essential for a holistic search experience.

Summary updated

Abstract

In synthesis planning, identifying and optimizing chemical reactions are important for the successful design of synthetic pathways to target substances. Chemical reaction databases assist chemists in gaining insights into this process. Traditionally, searching for relevant records from a reaction database has relied on the manual formulation of queries by chemists based on their search purposes, which is challenging without explicit knowledge of what they are searching for. In this study, we propose an intelligent chemical reaction search system that simplifies the process of enhancing the search results. When a user submits a query, a list of relevant records is retrieved from the reaction database. Users can express their preferences and requirements by providing binary ratings for the individual retrieved records. The search results are refined based on the user feedback. To implement this system effectively, we incorporate and adapt contrastive representation learning, dimensionality reduction, and human-in-the-loop techniques. Contrastive learning is used to train a representation model that embeds records in the reaction database as numerical vectors suitable for chemical reaction searches. Dimensionality reduction is applied to compress these vectors, thereby enhancing the search efficiency. Human-in-the-loop is integrated to iteratively update the representation model by reflecting user feedback. Through experimental investigations, we demonstrate that the proposed method effectively improves the chemical reaction search towards better alignment with user preferences and requirements. Scientific contribution This study seeks to enhance the search functionality of chemical reaction databases by drawing inspiration from recommender systems. The proposed method simplifies the search process, offering an alternative to the complexity of formulating explicit query rules. We believe that the proposed method can assist users in efficiently discovering records relevant to target reactions, especially when they encounter difficulties in crafting detailed queries due to limited knowledge.
BibTeX
@article{kang2025enhancing,
  author = {Seokho Kang and Youngchun Kwon and Hyunjeong Jeon and Joonhyuk Choi and Youn-Suk Choi and Seokho Kang},
  title = {{Enhancing chemical reaction search through contrastive representation learning and human-in-the-loop}},
  journal = {J. Cheminformatics},
  year = {2025},
  doi = {10.1186/s13321-025-00987-5},
}
Figure