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},
    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.1

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.1
File Size Uploaded
bayesianflow_for_chem-3.0.1.tar.gz 2.5 MB Details

Built distribution (wheel)

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

Total release size: 5.0 MB

Release files / bayesianflow_for_chem-3.0.1.tar.gz

Download URL bayesianflow_for_chem-3.0.1.tar.gz
Size 2.5 MB
Tags Source
SHA-256 checksum
How to use checksums
1da0738ac9af42bbf253c177c2d375001ce2c2234e6b99f5ff57997cb35ef51e
BLAKE2b-256 checksum
How to use checksums
312ff8d9c2905578cf92a5050e471e4411b306ec539fb949f281f7aa7bf8604f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

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

Download URL bayesianflow_for_chem-3.0.1-py3-none-any.whl
Size 2.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
5f05fb7f03127ddd47e5ba12481f3dfcf17d0bf45e14f57692a85f0d2e2bf055
BLAKE2b-256 checksum
How to use checksums
34b279137e8b2a43d06813c967e49f3a819faa55146ee6c92a9f83db3fae90cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release history Release notifications | RSS feed

3.0.2

2 release files

This release

3.0.1 This release

2 release files

3.0.0

2 release files

2.4.4

2 release files

2.4.3

2 release files

2.4.2

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.5

2 release files

2.3.4

2 release files

2.3.3

2 release files

2.3.2

2 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.6

2 release files

2.2.5

2 release files

2.2.4

2 release files

2.2.3

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.1.0

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.1

2 release files

1.2.0

2 release files

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