Iambackup/ReactionT5v2-retrosynthesis
011
1---2language:3- en4license: mit5tags:6- chemistry7- SMILES8- retrosynthesis9datasets:10- ORD11metrics:12- accuracy13---14 15# Model Card for ReactionT5v2-retrosynthesis16 17This is a ReactionT5 pre-trained to predict the reactants of reactions. You can use the demo [here](https://huggingface.co/spaces/sagawa/ReactionT5_task_retrosynthesis).18 19 20### Model Sources21 22<!-- Provide the basic links for the model. -->23 24- **Repository:** https://github.com/sagawatatsuya/ReactionT5v225- **Paper:** https://jcheminf.biomedcentral.com/articles/10.1186/s13321-025-01075-426- **Demo:** https://huggingface.co/spaces/sagawa/ReactionT527 28## Uses29 30<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->31You can use this model for retrosynthesis prediction or fine-tune this model with your dataset.32 33 34## How to Get Started with the Model35 36Use the code below to get started with the model.37 38```python39from transformers import AutoTokenizer, AutoModelForSeq2SeqLM40 41tokenizer = AutoTokenizer.from_pretrained("sagawa/ReactionT5v2-retrosynthesis", return_tensors="pt")42model = AutoModelForSeq2SeqLM.from_pretrained("sagawa/ReactionT5v2-retrosynthesis")43 44inp = tokenizer('CCN(CC)CCNC(=S)NC1CCCc2cc(C)cnc21', return_tensors='pt')45output = model.generate(**inp, num_beams=1, num_return_sequences=1, return_dict_in_generate=True, output_scores=True)46output = tokenizer.decode(output['sequences'][0], skip_special_tokens=True).replace(' ', '').rstrip('.')47output # 'CCN(CC)CCN=C=S.Cc1cnc2c(c1)CCCC2N'48```49 50## Training Details51 52### Training Procedure 53 54<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->55We used the [Open Reaction Database (ORD) dataset](https://drive.google.com/file/d/1JozA2OlByfZ-ILt5H5YrTjLJvSvD8xdL/view?usp=drive_link) for model training. In addition, we used [USPTO_50k dataset](https://yzhang.hpc.nyu.edu/T5Chem/index.html)'s test split to prevent data leakage.56The command used for training is the following. For more information about data preprocessing and training, please refer to the paper and GitHub repository.57 58```python59cd task_retrosynthesis60python train.py \61 --output_dir='t5' \62 --epochs=80 \63 --lr=2e-4 \64 --batch_size=32 \65 --input_max_len=100 \66 --target_max_len=150 \67 --weight_decay=0.01 \68 --evaluation_strategy='epoch' \69 --save_strategy='epoch' \70 --logging_strategy='epoch' \71 --train_data_path='../data/preprocessed_ord_train.csv' \72 --valid_data_path='../data/preprocessed_ord_valid.csv' \73 --test_data_path='../data/preprocessed_ord_test.csv' \74 --USPTO_test_data_path='../data/USPTO_50k/test.csv' \75 --pretrained_model_name_or_path='sagawa/CompoundT5'76```77 78### Results79 80| Model | Training set | Test set | Top-1 [% acc.] | Top-2 [% acc.] | Top-3 [% acc.] | Top-5 [% acc.] |81|----------------------|---------------------------|----------|----------------|----------------|----------------|----------------|82| Sequence-to-sequence | USPTO_50k | USPTO_50k | 37.4 | - | 52.4 | 57.0 |83| Molecular Transformer| USPTO_50k | USPTO_50k | 43.5 | - | 60.5 | - |84| SCROP | USPTO_50k | USPTO_50k | 43.7 | - | 60.0 | 65.2 |85| T5Chem | USPTO_50k | USPTO_50k | 46.5 | - | 64.4 | 70.5 |86| CompoundT5 | USPTO_50k | USPTO_50k | 44,2 | 55.2 | 61.4 | 67.3 |87| [ReactionT5 (This model)](https://huggingface.co/sagawa/ReactionT5v2-retrosynthesis) | - | USPTO_50k | 13.8 | 18.6 | 21.4 | 26.2 |88| [ReactionT5](https://huggingface.co/sagawa/ReactionT5v2-retrosynthesis-USPTO_50k) | USPTO_50k | USPTO_50k | 71.2 | 81.4 | 84.9 | 88.2 |89 90Performance comparison of Compound T5, ReactionT5, and other models in product prediction.91 92## Citation93 94<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->95```96@article{Sagawa2025,97 title = {ReactionT5: a pre-trained transformer model for accurate chemical reaction prediction with limited data},98 author = {Sagawa, Tatsuya and Kojima, Ryosuke},99 journal = {Journal of Cheminformatics},100 year = {2025},101 volume = {17},102 number = {1},103 pages = {126},104 doi = {10.1186/s13321-025-01075-4},105 url = {https://doi.org/10.1186/s13321-025-01075-4}106}107```