Published April 3, 2025 | Version v1
Software Open

Code for Reinforcement Learning-Based Tuning of Transformer Models for Chemical Reaction Prediction

Description

Code base to replicate all the results and conclusions from the paper "Negative Chemical Data Boosts Language Models in Reaction Outcome Prediction". 

This repository contains the code used in our study on extending reinforcement learning-based tuning of language models to the chemistry domain. Specifically, we train a Transformer model for chemical reaction prediction using a rigorously controlled dataset and a high-throughput dataset with extensive reaction screenings across diverse catalyst sets and experimental conditions. Our approach demonstrates state-of-the-art performance, even when successful reactions are significantly underrepresented, by leveraging as few as twenty positive data points alongside a substantially larger negative dataset. This repository includes instructions for dataset extraction, preprocessing, and splitting, covering both controlled and high-throughput reaction datasets. The repository also details the steps for pretraining, fine-tuning with maximum likelihood estimation (MLE), training a reward model, and reinforcement learning optimization. Additionally, it explains how to generate appropriate training splits, create a joint vocabulary, and implement baseline lookup tables for RL training.

 

The provided framework enables effective model training even with a limited number of successful reactions, highlighting the importance of optimization strategies and negative data inclusion.

Files

negative_learning-main.zip

Files (195.7 kB)

Name Size Download all
md5:2bb28d485c3ccc4985f73c467907cb8f
195.7 kB Preview Download

Additional details

Funding

Swiss National Science Foundation
NCCR Catalysis 180544
Swiss National Science Foundation
NCCR Catalysis 225147

Dates

Available
2025-04

Software

Repository URL
https://github.com/rxn4chemistry/negative_learning
Programming language
Python