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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: gpl-3.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pretty_name: SELFormerMM
|
| 6 |
+
size_categories:
|
| 7 |
+
- 1M<n<10M
|
| 8 |
+
task_categories:
|
| 9 |
+
- tabular-classification
|
| 10 |
+
- tabular-regression
|
| 11 |
+
- feature-extraction
|
| 12 |
+
- graph-ml
|
| 13 |
+
tags:
|
| 14 |
+
- chemistry
|
| 15 |
+
- cheminformatics
|
| 16 |
+
- drug-discovery
|
| 17 |
+
- molecular-property-prediction
|
| 18 |
+
- multimodal
|
| 19 |
+
- selfies
|
| 20 |
+
- chembl
|
| 21 |
+
- moleculenet
|
| 22 |
+
- representation-learning
|
| 23 |
+
configs:
|
| 24 |
+
- config_name: bace
|
| 25 |
+
data_files: finetuning_datasets/classification/bace/bace.csv
|
| 26 |
+
- config_name: bbbp
|
| 27 |
+
data_files: finetuning_datasets/classification/bbbp/bbbp.csv
|
| 28 |
+
- config_name: hiv
|
| 29 |
+
data_files: finetuning_datasets/classification/hiv/hiv.csv
|
| 30 |
+
- config_name: sider
|
| 31 |
+
data_files: finetuning_datasets/classification/sider/sider.csv
|
| 32 |
+
- config_name: tox21
|
| 33 |
+
data_files: finetuning_datasets/classification/tox21/tox21.csv
|
| 34 |
+
- config_name: esol
|
| 35 |
+
data_files: finetuning_datasets/regression/esol/esol.csv
|
| 36 |
+
- config_name: freesolv
|
| 37 |
+
data_files: finetuning_datasets/regression/freesolv/freesolv.csv
|
| 38 |
+
- config_name: lipo
|
| 39 |
+
data_files: finetuning_datasets/regression/lipo/lipo.csv
|
| 40 |
+
- config_name: pdbbind_full
|
| 41 |
+
data_files: finetuning_datasets/regression/pdbbind_full/pdbbind_full.csv
|
| 42 |
+
---
|
| 43 |
+
|
| 44 |
+
# SELFormerMM
|
| 45 |
+
|
| 46 |
+
Multimodal molecular representation data for **SELFormerMM** — an extension of
|
| 47 |
+
[SELFormer](https://github.com/HUBioDataLab/SELFormer) that aligns four complementary views of a
|
| 48 |
+
molecule in a shared embedding space: **SELFIES** sequences, **3D/structural graphs**,
|
| 49 |
+
**textual descriptions**, and **knowledge-graph** context, trained with multimodal supervised
|
| 50 |
+
contrastive learning on ~2.9M molecules.
|
| 51 |
+
|
| 52 |
+
Paper: **[SELFormerMM: multimodal molecular representation learning via SELFIES, structure, text, and
|
| 53 |
+
knowledge graph integration](https://doi.org/10.1093/bioinformatics/btag451)** (*Bioinformatics*, 2026)
|
| 54 |
+
|
| 55 |
+
Code: **https://github.com/HUBioDataLab/SELFormerMM**
|
| 56 |
+
|
| 57 |
+
This repository bundles everything needed to reproduce or build on SELFormerMM:
|
| 58 |
+
|
| 59 |
+
| Component | What it is |
|
| 60 |
+
|---|---|
|
| 61 |
+
| `pretraining_datasets/` | 2,854,815 ChEMBL v36 molecules with precomputed structure, text and KG embeddings, plus the heterogeneous KG itself |
|
| 62 |
+
| `finetuning_datasets/` | 9 downstream MoleculeNet benchmarks (BACE, BBBP, HIV, SIDER, Tox21, ESOL, FreeSolv, Lipophilicity, PDBbind), each with a metadata CSV and an aligned `.npz` of the three non-SELFIES modalities |
|
| 63 |
+
| `models/SELFormerMM/` | The multimodal RoBERTa backbone pretrained on the data above |
|
| 64 |
+
| `models/finetuned/` | One fine-tuned checkpoint per downstream task |
|
| 65 |
+
| `models/DMGI/` | The DMGI encoder used to produce the knowledge-graph embeddings |
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
Every artifact in this repository is row-aligned. Row `i` of a metadata CSV describes the same
|
| 70 |
+
molecule as row `i` of every `.npy` / `.npz` array that accompanies it.
|
| 71 |
+
|
| 72 |
+
A molecule that has no description, no KG node, or a structure that failed RDKit validation gets a
|
| 73 |
+
zero vector in that modality rather than being dropped. Downstream code is expected to treat an
|
| 74 |
+
all-zero row as "modality missing".
|
| 75 |
+
|
| 76 |
+
If you regenerate any modality yourself, you must preserve this ordering or the model will silently
|
| 77 |
+
receive mismatched inputs.
|
| 78 |
+
|
| 79 |
+
---
|
| 80 |
+
|
| 81 |
+
## Pretraining data
|
| 82 |
+
|
| 83 |
+
`pretraining_datasets/` — 2,854,815 drug-like molecules drawn from ChEMBL v36.
|
| 84 |
+
|
| 85 |
+
| File | Shape / size | Description |
|
| 86 |
+
|---|---|---|
|
| 87 |
+
| `pretraining_dataset_meta.csv` | 2,854,815 rows, 1.7 GB | Identifiers, structures and raw descriptions |
|
| 88 |
+
| `graph_embeddings.npy` | `(2854815, 512)` float32 | Uni-Mol `[CLS]` representations |
|
| 89 |
+
| `text_embeddings.npy` | `(2854815, 768)` float32 | SciBERT mean-pooled description embeddings |
|
| 90 |
+
| `kg_embeddings.npy` | `(2854815, 128)` float32 | DMGI node embeddings |
|
| 91 |
+
| `selformermm_kg_heterodata.pt` | 2.2 GB | The [CROssBAR v2](https://crossbarv2.hubiodatalab.com/) subgraph as a PyTorch Geometric `HeteroData` object |
|
| 92 |
+
|
| 93 |
+
### `pretraining_dataset_meta.csv` columns
|
| 94 |
+
|
| 95 |
+
| Column | Description |
|
| 96 |
+
|---|---|
|
| 97 |
+
| `selfies` | SELFIES string — the model's primary input |
|
| 98 |
+
| `chembl_id` | ChEMBL identifier, e.g. `CHEMBL153534` |
|
| 99 |
+
| `canonical_smiles` | Canonical SMILES from ChEMBL |
|
| 100 |
+
| `standard_inchi` | InChI |
|
| 101 |
+
| `standard_inchi_key` | InChIKey |
|
| 102 |
+
| `cid` | PubChem CID, when a mapping exists |
|
| 103 |
+
| `Description` | Textual description mapped from the [M3-20M](https://github.com/bz99bz/M-3) dataset |
|
| 104 |
+
| `kg_compound_node_idx` | Index of this compound's node in `selformermm_kg_heterodata.pt`, when present in the [CROssBAR v2](https://crossbarv2.hubiodatalab.com/) subgraph |
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
### Modality coverage
|
| 108 |
+
|
| 109 |
+
| Modality | Molecules with a non-zero vector | Coverage | Source |
|
| 110 |
+
|---|---:|---:|---|
|
| 111 |
+
| SELFIES | 2,854,815 | 100.00% | ChEMBL v36 SMILES, converted with `selfies` |
|
| 112 |
+
| Structure (Uni-Mol) | 2,854,734 | 100.00% | 81 molecules failed RDKit validation and were excluded |
|
| 113 |
+
| Text (description) | 492,702 | 17.26% | Mapped to M3-20M |
|
| 114 |
+
| Knowledge graph | 725,908 | 25.43% | CROssBAR v2 subgraph |
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
### The knowledge graph
|
| 118 |
+
|
| 119 |
+
`selformermm_kg_heterodata.pt` is a focused subgraph of **CROssBAR v2** (which itself integrates 34
|
| 120 |
+
heterogeneous biomedical sources), restricted to the node and edge types most directly tied to
|
| 121 |
+
molecular properties — compounds, proteins, drugs and genes. It contains **1,402,102 nodes** and
|
| 122 |
+
**4,424,830 relationships**. Node indices referenced by `kg_compound_node_idx` are into the
|
| 123 |
+
`Compound` node store, whose `mapping` attribute keys are of the form `chembl:CHEMBL6206`.
|
| 124 |
+
|
| 125 |
+
### How the embeddings were produced
|
| 126 |
+
|
| 127 |
+
Every non-SELFIES encoder is a **frozen pretrained checkpoint** — only the SELFIES encoder and the
|
| 128 |
+
projection networks were trained.
|
| 129 |
+
|
| 130 |
+
- **Structure — 512-d.** [Uni-Mol](https://github.com/deepmodeling/Uni-Mol) (`unimol_tools.UniMolRepr`,
|
| 131 |
+
`data_type="molecule"`, hydrogens retained) applied to the canonical SMILES; the `cls_repr` vector
|
| 132 |
+
is taken as the molecule representation.
|
| 133 |
+
- **Text — 768-d.** [SciBERT](https://huggingface.co/allenai/scibert_scivocab_uncased) (`allenai/scibert_scivocab_uncased`),
|
| 134 |
+
max length 512, mean-pooling over the last hidden state of the `Description` field.
|
| 135 |
+
- **Knowledge graph — 128-d.** A [DMGI](https://doi.org/10.1609/aaai.v34i04.5985) (Deep Multiplex Graph Infomax) encoder — one `GCNConv` per
|
| 136 |
+
relation type with a bilinear discriminator against a per-relation graph summary — trained on
|
| 137 |
+
`selformermm_kg_heterodata.pt`. Per-relation node embeddings are averaged to give the final vector.
|
| 138 |
+
The checkpoint is at `models/DMGI/dmgi_model.pt`.
|
| 139 |
+
|
| 140 |
+
All three matrices are mean-centered and L2-normalized over the non-zero rows; zero rows (missing
|
| 141 |
+
modality) are left untouched so they stay exactly zero.
|
| 142 |
+
|
| 143 |
+
---
|
| 144 |
+
|
| 145 |
+
## Fine-tuning datasets
|
| 146 |
+
|
| 147 |
+
`finetuning_datasets/` — nine downstream benchmarks, each a directory containing `<task>.csv` and
|
| 148 |
+
`<task>_embs.npz`. The `.npz` holds three arrays, `graph` `(n, 512)`, `text` `(n, 768)` and
|
| 149 |
+
`kg` `(n, 128)`, row-aligned to the CSV and produced by the same encoders as the pretraining data.
|
| 150 |
+
|
| 151 |
+
### Classification
|
| 152 |
+
|
| 153 |
+
| Task | Molecules | Label column(s) | Notes |
|
| 154 |
+
|---|---:|---|---|
|
| 155 |
+
| `bace` | 1,513 | `Class` | Binary — human β-secretase 1 inhibition. 691 positives (45.7%) |
|
| 156 |
+
| `bbbp` | 2,039 | `p_np` | Binary — blood–brain barrier permeability. 1,560 positives (76.5%) |
|
| 157 |
+
| `hiv` | 41,127 | `HIV_active` | Binary — HIV replication inhibition. 1,443 positives (3.5%) |
|
| 158 |
+
| `sider` | 1,427 | 27 columns | Multi-label — adverse drug reactions by MedDRA system organ class |
|
| 159 |
+
| `tox21` | 7,831 | 12 columns | Multi-label — nuclear-receptor and stress-response toxicity assays |
|
| 160 |
+
|
| 161 |
+
### Regression
|
| 162 |
+
|
| 163 |
+
| Task | Molecules | Target column | Range (mean) |
|
| 164 |
+
|---|---:|---|---|
|
| 165 |
+
| `esol` | 1,128 | `measured log solubility in mols per litre` | −11.60 … 1.58 (−3.05) |
|
| 166 |
+
| `freesolv` | 642 | `freesolv` | −25.47 … 3.43 (−3.80) |
|
| 167 |
+
| `lipo` | 4,200 | `lipo` | −1.50 … 4.50 (2.19) |
|
| 168 |
+
| `pdbbind_full` | 9,880 | `-logKd/Ki` | 0.40 … 9.30 (6.24) |
|
| 169 |
+
|
| 170 |
+
Besides its label column(s), every task CSV carries `selfies`, `smiles`, and the mapping columns
|
| 171 |
+
`standard_inchi_key`, `cid`, `Description`, `chembl_id`, `canonical_smiles`, `kg_compound_node_idx`.
|
| 172 |
+
`esol` additionally keeps the original MoleculeNet descriptor columns.
|
| 173 |
+
|
| 174 |
+
### Per-task modality coverage
|
| 175 |
+
|
| 176 |
+
Percentage of rows with a non-zero vector in each modality:
|
| 177 |
+
|
| 178 |
+
| Task | n | Graph | Text | KG | All four |
|
| 179 |
+
|---|---:|---:|---:|---:|---:|
|
| 180 |
+
| `bace` | 1,513 | 100.00% | 7.40% | 13.09% | 2.12% |
|
| 181 |
+
| `bbbp` | 2,039 | 100.00% | 67.48% | 2.70% | 1.86% |
|
| 182 |
+
| `hiv` | 41,127 | 99.98% | 14.23% | 0.78% | 0.28% |
|
| 183 |
+
| `sider` | 1,427 | 91.03% | 80.66% | 1.89% | 1.40% |
|
| 184 |
+
| `tox21` | 7,831 | 99.90% | 76.76% | 4.61% | 3.75% |
|
| 185 |
+
| `esol` | 1,128 | 100.00% | 88.30% | 3.55% | 3.46% |
|
| 186 |
+
| `freesolv` | 642 | 100.00% | 91.59% | 4.83% | 4.67% |
|
| 187 |
+
| `lipo` | 4,200 | 100.00% | 32.19% | 24.05% | 5.24% |
|
| 188 |
+
| `pdbbind_full` | 9,880 | 99.91% | 23.66% | 4.96% | 1.47% |
|
| 189 |
+
|
| 190 |
+
SELFIES coverage is 100% for every task.
|
| 191 |
+
|
| 192 |
+
### Splits
|
| 193 |
+
|
| 194 |
+
The CSVs are shipped unsplit. The paper's protocol is 80/10/10 train/validation/test, with
|
| 195 |
+
**scaffold splitting for the binary classification tasks** (BACE, BBBP, HIV) and **random splitting**
|
| 196 |
+
for the multilabel and regression tasks. `train_finetuning.py` reproduces this via `--use_scaffold`,
|
| 197 |
+
`--train_frac`/`--val_frac`/`--test_frac` and `--seed`; reported numbers are means over three seeds.
|
| 198 |
+
|
| 199 |
+
---
|
| 200 |
+
|
| 201 |
+
## Models
|
| 202 |
+
|
| 203 |
+
### `models/SELFormerMM/` — pretrained multimodal backbone
|
| 204 |
+
|
| 205 |
+
A RoBERTa encoder over SELFIES (12 layers, hidden size 768, 4 attention heads, vocabulary 800,
|
| 206 |
+
max position 514), initialized from [SELFormer](https://huggingface.co/HUBioDataLab/SELFormer), with
|
| 207 |
+
three parallel projection MLPs that map the structure (512-d), text (768-d) and KG (128-d) vectors
|
| 208 |
+
into the same 768-d space. Each projection expands and contracts the dimension through
|
| 209 |
+
`×4 → ×6 → ×6 → ×4 → ×1` of the hidden size with `LayerNorm` + `ReLU` between layers.
|
| 210 |
+
246,245,376 trainable parameters in total.
|
| 211 |
+
|
| 212 |
+
Trained with **SINCERE loss** (τ = 0.07), a supervised extension of InfoNCE that accommodates
|
| 213 |
+
multiple positive views per molecule. The three auxiliary encoders stay frozen; only the SELFIES
|
| 214 |
+
encoder and the projections are updated. Includes the SELFIES BPE tokenizer.
|
| 215 |
+
|
| 216 |
+
### `models/finetuned/<task>/`
|
| 217 |
+
|
| 218 |
+
One checkpoint per downstream task (`bace`, `bbbp`, `esol`, `freesolv`, `hiv`, `lipo`,
|
| 219 |
+
`pdbbind_full`, `sider`, `tox21`). Each directory holds the task tokenizer plus `model.pt`, a
|
| 220 |
+
checkpoint dict with `backbone` and `head` state dicts, loadable by `predict.py` in the code
|
| 221 |
+
repository.
|
| 222 |
+
|
| 223 |
+
### `models/DMGI/dmgi_model.pt`
|
| 224 |
+
|
| 225 |
+
The DMGI encoder checkpoint that generated `kg_embeddings.npy`.
|
| 226 |
+
|
| 227 |
+
### Reported performance
|
| 228 |
+
|
| 229 |
+
Selected results from the paper, mean ± standard deviation over three random seeds. ROC-AUC for
|
| 230 |
+
classification (higher is better), RMSE for regression (lower is better). See the paper for the full
|
| 231 |
+
table and the unimodal/multimodal baselines.
|
| 232 |
+
|
| 233 |
+
| Task | Metric | SELFormerMM |
|
| 234 |
+
|---|---|---|
|
| 235 |
+
| SIDER | ROC-AUC | 0.751 ± 0.013 |
|
| 236 |
+
| BACE | ROC-AUC | 0.779 ± 0.021 |
|
| 237 |
+
| BBBP | ROC-AUC | 0.947 ± 0.005 |
|
| 238 |
+
| HIV | ROC-AUC | 0.788 ± 0.025 |
|
| 239 |
+
| Tox21 | ROC-AUC | 0.845 ± 0.012 |
|
| 240 |
+
| ESOL | RMSE | 0.672 ± 0.060 |
|
| 241 |
+
| FreeSolv | RMSE | 1.070 ± 0.065 |
|
| 242 |
+
| Lipophilicity | RMSE | 0.624 ± 0.049 |
|
| 243 |
+
| PDBbind | RMSE | 1.310 ± 0.040 |
|
| 244 |
+
|
| 245 |
+
---
|
| 246 |
+
|
| 247 |
+
## Usage
|
| 248 |
+
|
| 249 |
+
### Browse a downstream task in the viewer
|
| 250 |
+
|
| 251 |
+
```python
|
| 252 |
+
from datasets import load_dataset
|
| 253 |
+
|
| 254 |
+
bbbp = load_dataset("HUBioDataLab/SELFormerMM", "bbbp")
|
| 255 |
+
```
|
| 256 |
+
|
| 257 |
+
The named configs above expose the nine task CSVs. The embedding arrays are not part of these
|
| 258 |
+
configs — `datasets` cannot align `.npz` files row-wise — so download them directly.
|
| 259 |
+
|
| 260 |
+
### Load a task with all four modalities
|
| 261 |
+
|
| 262 |
+
```python
|
| 263 |
+
import numpy as np, pandas as pd
|
| 264 |
+
from huggingface_hub import hf_hub_download
|
| 265 |
+
|
| 266 |
+
REPO = "HUBioDataLab/SELFormerMM"
|
| 267 |
+
meta = hf_hub_download(REPO, "finetuning_datasets/classification/bbbp/bbbp.csv", repo_type="dataset")
|
| 268 |
+
embs = hf_hub_download(REPO, "finetuning_datasets/classification/bbbp/bbbp_embs.npz", repo_type="dataset")
|
| 269 |
+
|
| 270 |
+
df = pd.read_csv(meta)
|
| 271 |
+
z = np.load(embs)
|
| 272 |
+
graph, text, kg = z["graph"], z["text"], z["kg"]
|
| 273 |
+
|
| 274 |
+
assert len(df) == len(graph) == len(text) == len(kg) # row-aligned
|
| 275 |
+
has_kg = np.linalg.norm(kg, axis=1) != 0 # zero vector == modality missing
|
| 276 |
+
```
|
| 277 |
+
|
| 278 |
+
### Fine-tune from the pretrained backbone
|
| 279 |
+
|
| 280 |
+
```bash
|
| 281 |
+
huggingface-cli download HUBioDataLab/SELFormerMM --repo-type dataset \
|
| 282 |
+
--include "models/SELFormerMM/*" "finetuning_datasets/classification/bbbp/*" --local-dir ./selformermm
|
| 283 |
+
|
| 284 |
+
python train_finetuning.py \
|
| 285 |
+
--model_path ./selformermm/models/SELFormerMM \
|
| 286 |
+
--dataset_meta_csv ./selformermm/finetuning_datasets/classification/bbbp/bbbp.csv \
|
| 287 |
+
--dataset_embs_npz ./selformermm/finetuning_datasets/classification/bbbp/bbbp_embs.npz \
|
| 288 |
+
--task_type binary --label_column p_np --num_labels 1 \
|
| 289 |
+
--use_scaffold 1 --epochs 50 --backbone_lr 1e-5 --head_lr 1e-4 \
|
| 290 |
+
--save_dir ./runs/bbbp
|
| 291 |
+
```
|
| 292 |
+
|
| 293 |
+
### Predict with a released fine-tuned checkpoint
|
| 294 |
+
|
| 295 |
+
```bash
|
| 296 |
+
python predict.py \
|
| 297 |
+
--model_dir ./selformermm/models/finetuned/bbbp \
|
| 298 |
+
--input_meta_csv ./selformermm/finetuning_datasets/classification/bbbp/bbbp.csv \
|
| 299 |
+
--input_embs_npz ./selformermm/finetuning_datasets/classification/bbbp/bbbp_embs.npz \
|
| 300 |
+
--task_type binary --num_labels 1 --label_column p_np \
|
| 301 |
+
--output_csv ./bbbp_predictions.csv
|
| 302 |
+
```
|
| 303 |
+
|
| 304 |
+
### Pretrain on your own corpus
|
| 305 |
+
|
| 306 |
+
Supply a SELFIES CSV plus a `.npy` per modality with identical row ordering; substitute a
|
| 307 |
+
zero matrix of the right shape for any modality you do not have. See `train_pretraining.py` and the
|
| 308 |
+
`generate_*_embeddings.py` scripts in the code repository.
|
| 309 |
+
|
| 310 |
+
> The pretraining files are large — `text_embeddings.npy` alone is 8.2 GB, and the full repository
|
| 311 |
+
> is roughly 66 GB. Use `--include` patterns to fetch only what you need, and `mmap_mode="r"` when
|
| 312 |
+
> loading the `.npy` files.
|
| 313 |
+
|
| 314 |
+
---
|
| 315 |
+
|
| 316 |
+
## Citation
|
| 317 |
+
|
| 318 |
+
If you use this data, please cite:
|
| 319 |
+
|
| 320 |
+
```bibtex
|
| 321 |
+
@article{ulusoy2026selformermm,
|
| 322 |
+
title = {SELFormerMM: multimodal molecular representation learning via SELFIES,
|
| 323 |
+
structure, text, and knowledge graph integration},
|
| 324 |
+
author = {Ulusoy, Erva and Bostanc{\i}, {\c{S}}evval and Deniz, Bora Engin and Do{\u{g}}an, Tunca},
|
| 325 |
+
journal = {Bioinformatics},
|
| 326 |
+
volume = {42},
|
| 327 |
+
number = {Supplement\_2},
|
| 328 |
+
pages = {btag451},
|
| 329 |
+
year = {2026},
|
| 330 |
+
doi = {10.1093/bioinformatics/btag451}
|
| 331 |
+
}
|
| 332 |
+
```
|
| 333 |
+
|
| 334 |
+
## License
|
| 335 |
+
|
| 336 |
+
**GNU General Public License v3.0 or later.**
|
| 337 |
+
|
| 338 |
+
> This program is free software: you can redistribute it and/or modify it under the terms of the GNU
|
| 339 |
+
> General Public License as published by the Free Software Foundation, either version 3 of the
|
| 340 |
+
> License, or (at your option) any later version.
|
| 341 |
+
|
| 342 |
+
Data redistributed here remains subject to the terms of its original sources (ChEMBL, M3-20M,
|
| 343 |
+
CROssBARv2, MoleculeNet, PDBbind).
|
| 344 |
+
|
| 345 |
+
## Contact
|
| 346 |
+
|
| 347 |
+
[HU Biological Data Science Lab](https://github.com/HUBioDataLab) — open an issue on the
|
| 348 |
+
[code repository](https://github.com/HUBioDataLab/SELFormerMM).
|