Downloads · 30 days
0
rxn4chemistry/rxn-sandbox
rxn-sandbox is a machine learning model from rxn4chemistry. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as openmdw-1.1.
A lightweight, local instance of RXN for running forward reaction and retrosynthesis predictions.
Downloads · 30 days
0
Access
Public
Updated Aug 6, 2026
Repo size
314 MB
Likes
0
Public
Click a slice to open those files.
.ckpt310 MB · 99%
From the Hugging Face model README
A lightweight, local instance of RXN for running forward reaction and retrosynthesis predictions.
[!NOTE] This repository is cross-listed on GitHub and Hugging Face.
This repository enables offline chemical reaction prediction using transformer models. The available tasks are RXN's most used prediction functionality: forward reaction, single-step retrosynthesis, and retrosynthesis tree generation. These tasks are performed locally via Jupyter notebook, via dedicated Python scripts, or via LLM (using OpenWeb UI and MCP). The transformer models were trained using 2025Q2 Pistachio data.
| Forward Reaction | Retrosynthesis (Single Step) | Retrosynthesis (Tree) |
|---|---|---|
Software:
[!NOTE] If using Podman, replace
dockercommands withpodmanthroughout this guide.This repository uses Git LFS for
.ckptmodel files. Install Git LFS, then rungit lfs installonce on your machine before cloning or pulling the repository.
Hardware:
compose-cuda.yamlTwo Compose files are provided:
| File | Description |
|---|---|
compose.yaml | Default — CPU-only inference |
compose-cuda.yaml | GPU-accelerated inference via NVIDIA CUDA (requires an NVIDIA GPU and the NVIDIA Container Toolkit) |
Clone this repository, and from the root directory run the following commands. Replace compose.yaml with compose-cuda.yaml in each command to enable GPU acceleration.
docker compose -f compose.yaml build
docker compose -f compose.yaml up -d
You should see all containers running:

Access Jupyter at http://localhost:8888/ to use the interactive notebook environment.

Use the provided notebook.ipynb to explore examples and interact with the models.

Run the Celery setup and helper functions section first to:
Two examples are provided for product prediction (batch and single reaction). Customize the reactants list:
# Set up a list of reactants to make predictions
reactants_list = ["CCI.O=Cc1ccc([N+](=O)[O-])c(O)c1"]
Configure prediction parameters:
# Setup task kwargs
kwargs = {
"topn": 3, # Number of results per reactant
"num_beams": 5, # Number of beams used for prediction. Must be >= topn
}
After running the prediction, the results will be displayed in a table:

Retrosynthesis predictions process one product at a time. Set the target product:
# Choose product for retrosynthesis prediction
product = "C=CC(=C)C[Si](C)(C)C"
Configure retrosynthesis-specific parameters:
# Setup task kwargs
kwargs = {
"topn": 10, # Number of results per reactant
"num_beams": 10, # Number of beams used for prediction. Must be >= topn
"fap": 0.6, # Forward likelihood acceptance probability (not length averaged)
"fld": 0.2, # Forward likelihood delta required between the top2 forward prediction results
}
Results are displayed in a similar table format:

Start by selecting a target product SMILES:
# Choose product for retrosynthesis tree prediction
product = "C1C(C[Si](C)(C)C)=CCC2C(=O)OC(=O)C12"
Configure prediction and tree-specific parameters:
# Setup task kwargs
kwargs = {
"topn": 15, # Number of results per reactant
"num_beams": 15, # Number of beams used for prediction. Must be >= topn
"fap": 0.6, # Forward likelihood acceptance probability (not length averaged)
"fld": 0.2, # Forward likelihood delta required between the top2 forward prediction results
"max_depth": 4, # Max depth of the retrosynthesis tree
"beam_width": 6, # Max amount of nodes being expanded in each step
}
⚠️ Performance Note: Retrosynthesis tree predictions are computationally intensive and may take significant time to complete.
Two visualization options are available:
1. Text Representation - Complete textual view of predicted routes and steps:

2. Graph Representation - Visual tree structure with molecule expansion paths. Use the selector to switch between different prediction results:

Access OpenWeb UI at http://localhost:3000/ to interact with RXN models using natural language through AI assistants.

+ iconhttp://localhost:8000To use external AI models:

rxn-mcp-serverNote: You must re-enable the tool when switching models.

Interact with RXN functions using conversational prompts:

If you prefer a command-line workflow, you can run predictions directly from the provided Python scripts without using Jupyter or OpenWebUI. This method may be useful for running analyses on remote machines (which often lack GUIs).
The scripts are executed inside the worker container, where the models and Celery configuration are already available:
docker exec -it rxn-worker-1 bash
python scripts/predict_product.py — run forward reaction prediction examplespython scripts/predict_retrosynthesis.py — run single-step retrosynthesis examplespython scripts/predict_retrosynthesis_tree.py — run retrosynthesis tree examplespython scripts/run_notebook_examples.py — run the same examples shown in the notebook in sequence (this is effectively a combination of the three prior scripts)Each script is intended to be edited before execution. The scripts/ directory is mounted into the worker container, so local changes are immediately available without rebuilding the image. Update the input SMILES and prediction parameters directly in the file:
reactants_list for forward reaction predictionproduct for retrosynthesis and retrosynthesis tree predictiontopn, num_beams, fap, fld, max_depth, and beam_width as neededThen run the script you want:
python scripts/predict_product.py
When you are finished, leave the container shell with:
exit
</details>
The system consists of six containers:
# Stopping services
docker compose -f compose.yaml stop
# Restarting services
docker compose -f compose.yaml restart
# Viewing logs (all services)
docker compose -f compose.yaml logs -f
# Viewing logs (specific service)
docker compose -f compose.yaml logs -f worker
# Removing everything (containers, networks, and volumes)
docker compose -f compose.yaml down -v
[!TIP] Replace
-f compose.yamlwith-f compose-cuda.yamlin any of the commands above to manage the GPU-accelerated stack instead.
Optimization Tips:
topn and num_beams valuesmax_depth to 3-4 for tree predictionsbeam_width of 5-10 for reasonable performanceBenchmarking:
GPU acceleration provides significant speedup, especially for complex retrosynthesis tree predictions. These results are from the Python scripts in the scripts/ folder. Analysis
times can vary substantially depending on the query molecule(s) and parameters.
| Script | T4 GPU (AWS g4dn.xlarge) | M1 Mac CPU | GPU Speedup |
|---|---|---|---|
predict_product.py | 1.7 s | 3.4 s | 2.0x |
predict_retrosynthesis.py | 2.5 s | 8.5 s | 3.4x |
predict_retrosynthesis_tree.py | 87 s (1.5 min) | 763 s (12.7 min) | 8.8x |