Skip to main content

ChemBFN: Bayesian Flow Network for Chemistry

DOI DOI DOI

This is the repository of the PyTorch implementation of ChemBFN model.

Build State

PyPI CI document

Features

ChemBFN provides the state-of-the-art functionalities of

  • SMILES or SELFIES-based de novo molecule generation
  • Protein sequence de novo generation
  • Template optimisation (mol2mol)
  • Classifier-free guidance conditional generation (single or multi-objective optimisation)
  • Context-guided conditional generation (inpaint)
  • Outstanding out-of-distribution chemical space sampling
  • Fast sampling via ODE solver
  • Pseudo-continuous learning to learn from different datasets
  • Molecular property and activity prediction finetuning
  • Reaction yield prediction finetuning

in an all-in-one-model style. A built-in MLFF can further convert the generated SMILES strings to the corresponding 3D conformations.

News

  • [26/06/2026] Our second paper has been accepted by J. Cheminform.
  • [26/12/2025] We were invited to submit a short report about ChemBFN for CICSJ Bulletin.
  • [09/10/2025] A web app chembfn_webui for hosting ChemBFN models is available on PyPI.
  • [30/01/2025] The package bayesianflow_for_chem is available on PyPI.
  • [21/01/2025] Our first paper has been accepted by JCIM.
  • [17/12/2024] The second paper of out-of-distribution generation is available on arxiv.org.
  • [31/07/2024] Paper is available on arxiv.org.
  • [21/07/2024] Paper was submitted to arXiv.

Install

$ pip install -U bayesianflow_for_chem

Usage

You can find example scripts in 📁example folder.

Pre-trained Model

You can find pretrained models (linked to pretraining datasets) on our 🤗Hugging Face model page.

Dataset Handling

We provide a Python class CSVData to handle data stored in CSV or similar format containing headers to identify the entities. The following is a quickstart.

  1. Download your dataset file (e.g., ESOL from MoleculeNet) and split the file:
>>> from bayesianflow_for_chem.tool import split_data

>>> split_data("delaney-processed.csv", method="scaffold")
  1. Load the split data:
>>> from bayesianflow_for_chem.data import smiles2token, collate, CSVData

>>> dataset = CSVData("delaney-processed_train.csv")
>>> dataset[0]
{'Compound ID': ['Thiophene'], 
'ESOL predicted log solubility in mols per litre': ['-2.2319999999999998'], 
'Minimum Degree': ['2'], 
'Molecular Weight': ['84.14299999999999'], 
'Number of H-Bond Donors': ['0'], 
'Number of Rings': ['1'], 
'Number of Rotatable Bonds': ['0'], 
'Polar Surface Area': ['0.0'], 
'measured log solubility in mols per litre': ['-1.33'], 
'smiles': ['c1ccsc1']}
  1. Create a mapping function to tokenise the dataset and select values:
>>> import torch

>>> def encode(x):
...   smiles = x["smiles"][0]
...   value = [float(i) for i in x["measured log solubility in mols per litre"]]
...   return {"token": smiles2token(smiles), "value": torch.tensor(value)}

>>> dataset.map(encode)
>>> dataset[0]
{'token': tensor([  1, 151,  23, 151, 151, 154, 151,  23,   2]), 
'value': tensor([-1.3300])}
  1. Wrap the dataset in torch.utils.data.DataLoader:
>>> dataloader = torch.utils.data.DataLoader(dataset, 32, collate_fn=collate)

Cite This Work

@article{2025chembfn,
    title={Bayesian Flow Network Framework for Chemistry Tasks},
    author={Tao, Nianze and Abe, Minori},
    journal={Journal of Chemical Information and Modeling},
    volume={65},
    number={3},
    pages={1178-1187},
    year={2025},
    doi={10.1021/acs.jcim.4c01792},
}
@article{2025chembfn_report,
    title={Molecular Structure Design via Bayesian Flow Network},
    author={Tao, Nianze and Nagai, Touma and Abe, Minori},
    journal={CICSJ Bulletin},
    volume={43},
    number={1},
    pages={10-14},
    year={2025},
    doi={10.11546/cicsj.43.10},
}

Out-of-distribution generation and fast sampling:

@article{2026chembfn_ood,
    title={Sampling Out-of-Distribution Chemical Spaces via Bayesian Flow}, 
    author={Tao, Nianze and Abe, Minori},
    journal={Journal of Cheminformatics},
    volume={18},
    number={1},
    pages={130},
    year={2026},
    doi={10.1186/s13321-026-01248-9}, 
}

PhD thesis:

@phdthesis{2026thesis_tao,
    title={Efficient Multi-Object Optimisation for Molecular Design via Bayesian Flow Networks},
    author={Nianze Tao},
    year={2026},
    month={September},
    school={Hiroshima University},
    type={PhD thesis},
    note={Chemistry program},
}

Metadata

Release files for bayesianflow-for-chem 3.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bayesianflow-for-chem 3.0.4
File Size Uploaded Provenance Actions
bayesianflow_for_chem-3.0.4.tar.gz 4.8 MB Without provenance Details for bayesianflow_for_chem-3.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bayesianflow-for-chem 3.0.4
File Interpreter ABI Platform Actions
bayesianflow_for_chem-3.0.4-py3-none-any.whl Python 3 none any Details for bayesianflow_for_chem-3.0.4-py3-none-any.whl

Total release size: 9.6 MB

Release files / bayesianflow_for_chem-3.0.4.tar.gz

Download URL bayesianflow_for_chem-3.0.4.tar.gz
Size 4.8 MB
Tags Source
SHA-256 checksum
How to use checksums
a25e7db529dbf44bb012445c6d38dab80211cccc9ed048654110650334598c29
BLAKE2b-256 checksum
How to use checksums
8bb7473cfef72a680d51f32cea432b551e83b6a30b3579ddd2cf58fe5aeceb86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / bayesianflow_for_chem-3.0.4-py3-none-any.whl

Download URL bayesianflow_for_chem-3.0.4-py3-none-any.whl
Size 4.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
16206df0a9e3074c5f1c4a64b26ee6f07141e81f3c5d6e027119a89f9ef65eee
BLAKE2b-256 checksum
How to use checksums
e820814f57a3dbcbe14bca824ede8741e39021d55726ed9a619bccc3a5789ad8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for bayesianflow-for-chem 3.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.0.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page