Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3tokenizer = AutoTokenizer.from_pretrained("sagawa/ReactionT5v2-forward", return_tensors="pt")
4model = AutoModelForSeq2SeqLM.from_pretrained("sagawa/ReactionT5v2-forward")
5
6inp = tokenizer('REACTANT:COC(=O)C1=CCCN(C)C1.O.[Al+3].[H-].[Li+].[Na+].[OH-]REAGENT:C1CCOC1', return_tensors='pt')
7output = model.generate(**inp, num_beams=1, num_return_sequences=1, return_dict_in_generate=True, output_scores=True)
8output = tokenizer.decode(output['sequences'][0], skip_special_tokens=True).replace(' ', '').rstrip('.')
9output # 'CN1CCC=C(CO)C1'1cd task_forward
2python train.py \
3 --output_dir='t5' \
4 --epochs=100 \
5 --lr=1e-3 \
6 --batch_size=32 \
7 --input_max_len=150 \
8 --target_max_len=100 \
9 --weight_decay=0.01 \
10 --evaluation_strategy='epoch' \
11 --save_strategy='epoch' \
12 --logging_strategy='epoch' \
13 --train_data_path='../data/preprocessed_ord_train.csv' \
14 --valid_data_path='../data/preprocessed_ord_valid.csv' \
15 --test_data_path='../data/preprocessed_ord_test.csv' \
16 --USPTO_test_data_path='../data/USPTO_MIT/MIT_separated/test.csv' \
17 --disable_tqdm \
18 --pretrained_model_name_or_path='sagawa/CompoundT5'| Model | Training set | Test set | Top-1 [% acc.] | Top-2 [% acc.] | Top-3 [% acc.] | Top-5 [% acc.] |
|---|---|---|---|---|---|---|
| Sequence-to-sequence | USPTO_MIT | USPTO_MIT | 80.3 | 84.7 | 86.2 | 87.5 |
| WLDN | USPTO_MIT | USPTO_MIT | 80.6 (85.6) | 90.5 | 92.8 | 93.4 |
| Molecular Transformer | USPTO_MIT | USPTO_MIT | 88.8 | 92.6 | – | 94.4 |
| T5Chem | USPTO_MIT | USPTO_MIT | 90.4 | 94.2 | – | 96.4 |
| CompoundT5 | USPTO_MIT | USPTO_MIT | 86.6 | 89.5 | 90.4 | 91.2 |
| ReactionT5 (This model) | - | USPTO_MIT | 92.8 | 95.6 | 96.4 | 97.1 |
| ReactionT5 | USPTO_MIT | USPTO_MIT | 97.5 | 98.6 | 98.8 | 99.0 |
@article{Sagawa2025,
title = {ReactionT5: a pre-trained transformer model for accurate chemical reaction prediction with limited data},
author = {Sagawa, Tatsuya and Kojima, Ryosuke},
journal = {Journal of Cheminformatics},
year = {2025},
volume = {17},
number = {1},
pages = {126},
doi = {10.1186/s13321-025-01075-4},
url = {https://doi.org/10.1186/s13321-025-01075-4}
}