Mantas-it/Chem_Procedure_Prediction

Python

1

17 commits

updated Jan 13, 2025

See the code

README

This is an article repository. It is in the process of being updated while the paper is being reviewed.

Title: Large Language Models for Predicting Organic Synthesis Procedures

Available online: click here

Required: python 3.11; pytorch 2.2; transformers 4.38.1. GPU with support for CUDA 11.8 and cudnn 8.9.2 is recommended. Large models need 24GB Vram GPU's to train. We used vast.ai and RTX4090.

Quickstart; try the molT5-large fine-tuned model.

import torch
from transformers import T5ForConditionalGeneration, AutoTokenizer
torch_device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

tokenizer = AutoTokenizer.from_pretrained('laituan245/molt5-large-smiles2caption',model_max_length=256)
model = T5ForConditionalGeneration.from_pretrained('.../molT5/pre-tok_pre_molT5-large/checkpoint-17000')
model.config.max_length = 512
model.to(torch_device)

#The reactants and products are separated by the bar (|)
input = 'Clc1nc(Cl)c2c(n1)CSC2|C1COCCN1>>Clc1nc2c(c(N3CCOCC3)n1)SCC2'   
input_enc = tokenizer(input, padding=True, truncation=True, return_tensors='pt').to(torch_device)

output = model.generate(**input_enc,max_new_tokens=256, num_beams=3, early_stopping=True)

print(tokenizer.decode(output[0], skip_special_tokens=True))

----------------------------------------

Datasets

The prepared "PRP-931k" dataset can be downloaded click here. (100 MB compressed, .txt files, contains train, test and validation subsets)

Best models

Test via HuggingFace click here

Download "molT5-large-PP" model (best) click here (8GB compressed)

Download "molT5-base-PP" model (faster) click here (2.5GB compressed)

Download "FLAN-T5-base-CC" model (faster) click here (2.6GB compressed)

Download "molT5-large-PP" model (faster) click here (2.8GB compressed)

All other models

Download all mol-T5 models click here (11.4GB compressed)

Download all FLAN-T5 models click here (18.2GB compressed)

Download all BART models click here (9.6GB compressed)

Download all T5 models click here (9GB compressed)

Download all seq2seq transformer models click here (3.9GB compressed)

----------------------------------------

Other files

Download the DRFP pkl files for tmap click here

----------------------------------------

The 'paragraph2actions_updated' files contain code for loading up actions and parsing the formal (coverted) format of the paragraphs. We share the modified version of the IBM RXN's original.

Mantas-it/Chem_Procedure_Prediction

Python

1

17 commits

updated Jan 13, 2025

See the code

README

This is an article repository. It is in the process of being updated while the paper is being reviewed.

Title: Large Language Models for Predicting Organic Synthesis Procedures

Available online: click here

Required: python 3.11; pytorch 2.2; transformers 4.38.1. GPU with support for CUDA 11.8 and cudnn 8.9.2 is recommended. Large models need 24GB Vram GPU's to train. We used vast.ai and RTX4090.

Quickstart; try the molT5-large fine-tuned model.

import torch
from transformers import T5ForConditionalGeneration, AutoTokenizer
torch_device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

tokenizer = AutoTokenizer.from_pretrained('laituan245/molt5-large-smiles2caption',model_max_length=256)
model = T5ForConditionalGeneration.from_pretrained('.../molT5/pre-tok_pre_molT5-large/checkpoint-17000')
model.config.max_length = 512
model.to(torch_device)

#The reactants and products are separated by the bar (|)
input = 'Clc1nc(Cl)c2c(n1)CSC2|C1COCCN1>>Clc1nc2c(c(N3CCOCC3)n1)SCC2'   
input_enc = tokenizer(input, padding=True, truncation=True, return_tensors='pt').to(torch_device)

output = model.generate(**input_enc,max_new_tokens=256, num_beams=3, early_stopping=True)

print(tokenizer.decode(output[0], skip_special_tokens=True))

----------------------------------------

Datasets

The prepared "PRP-931k" dataset can be downloaded click here. (100 MB compressed, .txt files, contains train, test and validation subsets)

Best models

Test via HuggingFace click here

Download "molT5-large-PP" model (best) click here (8GB compressed)

Download "molT5-base-PP" model (faster) click here (2.5GB compressed)

Download "FLAN-T5-base-CC" model (faster) click here (2.6GB compressed)

Download "molT5-large-PP" model (faster) click here (2.8GB compressed)

All other models

Download all mol-T5 models click here (11.4GB compressed)

Download all FLAN-T5 models click here (18.2GB compressed)

Download all BART models click here (9.6GB compressed)

Download all T5 models click here (9GB compressed)

Download all seq2seq transformer models click here (3.9GB compressed)

----------------------------------------

Other files

Download the DRFP pkl files for tmap click here

----------------------------------------

The 'paragraph2actions_updated' files contain code for loading up actions and parsing the formal (coverted) format of the paragraphs. We share the modified version of the IBM RXN's original.