How jiachengxiong/reactseq works
Project Type and Purpose
• ReactSeq is a machine‐learning pipeline for chemical retrosynthesis:
• It converts product SMILES into a “ReactSeq” representation via data preprocessing (RDKit/Indigo).
• It trains and runs a seq2seq model (OpenNMT-py) to predict ReactSeq strings.
• It transforms predicted ReactSeq back to reactant SMILES and evaluates top-k accuracy.
• Key use cases: data augmentation, training, inference, evaluation, and demo via Gradio.
File Structure Analysis
• Top‐level directories/files:
• config/ – YAML files for training/inference settings
• datasets/ – raw and processed data splits (50k_ReactSeq, with/without prompts)
• onmt/ – customized OpenNMT-py library (encoders, decoders, modules, training/inference scripts)
• checkpoints/ & trained_models/ – model checkpoint storage
• scripts: preprocess_data.py, transform.py, train.sh, inference.sh, demo_*.sh
• embedding/ – embedding extraction & analysis notebooks/scripts
• ELN/ – exploratory notebooks for condition/yield prediction
• output/ – inference outputs & evaluation templates
• Two conda environments:
• rdkit2019 for chemistry preprocessing
• opennmt3 for model training/inference
README Insights
• Describes dual‐environment setup, data preprocessing commands, training/inference workflows, transformation steps, and evaluation.
• Points to notebooks for usage examples and accuracy calculations.
• Mentions external demo service (Gradio on Hugging Face).
Main Components & Relationships
A. Data Layer
• Raw USPTO_50K CSVs (datasets/50k_raw)
• Vocabulary files (datasets/vocabs)
B. Preprocessing Layer (rdkit2019 env)
• preprocess_data.py & preprocess_prompt_data.ipynb
• RDKit/Indigo tokenization, reaction mapping
• Outputs: processed src/tgt files in datasets/50k_ReactSeq*
C. Model Training Layer (opennmt3 env)
• Config YAMLs (config/*.yml)
• onmt/bin/train.py wrapper (called by train.sh)
• onmt/core modules: encoders, decoders, training loops
• Checkpoint saving to checkpoints/
D. Inference Layer (opennmt3 env)
• onmt/bin/translate.py via inference.sh / inference_with_prompt.sh
• Generates ReactSeq predictions (output/tgt_*.txt)
E. Postprocessing Layer (rdkit2019 env)
• transform.py converts ReactSeq → SMILES of reactants
• Output: output/pred_reactants_*.txt
F. Evaluation & Analysis
• cal_top_k_accuracy.ipynb for metrics
• embedding/ scripts & notebooks for representation analysis
• ELN/ notebooks for auxiliary exploratory tasks
G. Demo Service
• demo_inference.sh + demo_transform.sh
• Gradio frontend hosted on Hugging Face
Architectural Patterns & Technologies
• Pipeline architecture with distinct environments for chemistry vs. ML
• Modular separation of concerns: data, preprocessing, modeling, postprocessing, evaluation
• Configuration-driven (YAML) orchestration of training/inference
• Reusable library (onmt/) alongside project-specific scripts
• Notebook-driven exploration & demos