Skip to content

luost26/prexsyn

Repository files navigation

PrexSyn

arXiv readthedocs data

PrexSyn is an efficient, accurate, and programmable framework for exploring synthesizable chemical space.

PrexSyn is based on a decoder-only transformer architecture that autoregressively generates postfix notations of synthesis (a molecular representation based on chemical reactions and purchasable building blocks) conditioned on molecular descriptors.

PrexSyn is trained on a billion-scale datastream of postfix notations paired with molecular descriptors using only two GPUs and 32 CPU cores in two days. This is made possible by PrexSyn Engine, a real-time, high-throughput C++-based data generation pipeline.

Note: features described in the original paper (e.g. property-based queries) are not supported in the current version (v1) of PrexSyn for now. If you need these features, please switch to the v0 branch.

[Documentation] [Paper] [PrexSyn Engine] [Data and Model Weights]

Capabilities

Capability Input Output Performance
Chemical space projection Image Image Image
Fingerprint/descriptor based generation Image Image Image
Molecular sampling Image Image Image

Usage

Documentation

Please refer to the documentation for detailed usage instructions on installation, data setup, reproducibility, and customization.

Quick example

To run a quick example, make sure uv is installed, then clone this repository. The command below is all you need to get started. No need to manually configure or download anything! On the first run, the preprocessed chemical space and model checkpoints will be downloaded automatically.

uv run python scripts/examples/projection.py \
    --smiles "COc1ccc(-c2ccnc(Nc3ccccc3)n2)cc1" \
    --draw-output-dir ./draw

The diagrams of the synthesis pathways will be saved in the ./draw directory.

examples

If you need to customize the environment (e.g., specific PyTorch/CUDA versions), please refer to the installation instructions for guidance.

Use PrexSyn in your own project

PrexSyn is designed to be modular and easy to integrate into your own projects. To get started, install PrexSyn directly from this repository (a PyPI release is planned), which will automatically install all required dependencies:

pip install git+https://github.com/luost26/prexsyn.git

The example below demonstrates how to use PrexSyn to generate synthesis pathways for a target SMILES string:

from prexsyn.shortcuts import AllInOneLoader, MoleculeProjector

config_path = "./data/trained_models/enamine2310_rxn115_202511.yml"

loader = AllInOneLoader(config_path)
projector = MoleculeProjector(
    model=loader.model().to("cuda").eval(),
    detokenizer=loader.detokenizer(),
    descriptor="ecfp4",
    num_samples=16,
)

result = projector.one("COc1ccc(-c2ccnc(Nc3ccccc3)n2)cc1")
for i, item in enumerate(result.items):
    print(item.get_tree())  # print the synthesis tree in python dict format

    img = item.get_image()
    img.save(f"output_{i}.png")  # save the synthesis tree diagram as a PNG image
    img.close()

More examples can be found in the scripts/examples directory.

Upgrade to PrexSyn v1

We have substantially refactored both the PrexSyn codebase and the PrexSyn Engine to improve usability, performance, and extensibility. Key updates include:

  • Improved usability: PrexSyn Engine is now available via PyPI.
  • Higher performance and stability: Data generation is now approximately 2× faster than reported in the paper, with improved robustness thanks to a more reliable compilation pipeline.
  • Greater flexibility: Chemical space definitions and training workflows are now easier to customize for new use cases.
  • Cleaner interfaces: Simplified and more consistent APIs for projection, fingerprint/descriptor-based generation, and sampling.
  • 🚧 Migrate molecular sampling benchmarks to the new codebase.
  • ⚠️ Some features described in the original paper (mostly property-based queries) are no longer supported in the current version of PrexSyn. If you need these features, please use the v0 branch.

Citation

@article{luo2025prexsyn,
  title   = {Efficient and Programmable Exploration of Synthesizable Chemical Space},
  author  = {Shitong Luo and Connor W. Coley},
  year    = {2025},
  journal = {arXiv preprint arXiv: 2512.00384}
}

@inproceedings{luo2024chemprojector,
  title={Projecting Molecules into Synthesizable Chemical Spaces},
  author={Shitong Luo and Wenhao Gao and Zuofan Wu and Jian Peng and Connor W. Coley and Jianzhu Ma},
  booktitle={Forty-first International Conference on Machine Learning},
  year={2024}
}

About

⛰️ PrexSyn: Efficient and Programmable Exploration of Synthesizable Chemical Space

Resources

License

Stars

53 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages