Datasets:
card: three-seed checkpoint layout, evaluate.py usage
Browse files
README.md
CHANGED
|
@@ -196,6 +196,10 @@ The CSVs are shipped unsplit. The paper's protocol is 80/10/10 train/validation/
|
|
| 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
|
|
@@ -215,10 +219,26 @@ encoder and the projections are updated. Includes the SELFIES BPE tokenizer.
|
|
| 215 |
|
| 216 |
### `models/finetuned/<task>/`
|
| 217 |
|
| 218 |
-
|
| 219 |
-
`
|
| 220 |
-
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
### `models/DMGI/dmgi_model.pt`
|
| 224 |
|
|
@@ -277,16 +297,41 @@ has_kg = np.linalg.norm(kg, axis=1) != 0 # zero vector == modal
|
|
| 277 |
|
| 278 |
### Fine-tune from the pretrained backbone
|
| 279 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
```bash
|
|
|
|
|
|
|
| 281 |
huggingface-cli download HUBioDataLab/SELFormerMM --repo-type dataset \
|
| 282 |
-
--include "models/SELFormerMM/*" "
|
|
|
|
| 283 |
|
| 284 |
python train_finetuning.py \
|
| 285 |
-
--
|
| 286 |
-
--
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
--save_dir ./runs/bbbp
|
| 291 |
```
|
| 292 |
|
|
@@ -294,13 +339,41 @@ python train_finetuning.py \
|
|
| 294 |
|
| 295 |
```bash
|
| 296 |
python predict.py \
|
| 297 |
-
--model_dir
|
| 298 |
-
--input_meta_csv
|
| 299 |
-
--input_embs_npz
|
| 300 |
-
--task_type binary --num_labels
|
| 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
|
|
|
|
| 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 |
+
The exact values used for each task and seed are recorded in
|
| 200 |
+
`models/finetuned/<task>/seed_<n>/finetuning_optimized_config.json`, so you do not have to set
|
| 201 |
+
them by hand.
|
| 202 |
+
|
| 203 |
---
|
| 204 |
|
| 205 |
## Models
|
|
|
|
| 219 |
|
| 220 |
### `models/finetuned/<task>/`
|
| 221 |
|
| 222 |
+
Nine downstream tasks (`bace`, `bbbp`, `esol`, `freesolv`, `hiv`, `lipo`, `pdbbind_full`,
|
| 223 |
+
`sider`, `tox21`), each with all three seeds of its multi-seed run:
|
| 224 |
+
|
| 225 |
+
```
|
| 226 |
+
models/finetuned/<task>/
|
| 227 |
+
├── seed_42/
|
| 228 |
+
├── seed_123/
|
| 229 |
+
└── seed_3407/
|
| 230 |
+
```
|
| 231 |
+
|
| 232 |
+
Every seed directory is self-contained:
|
| 233 |
+
|
| 234 |
+
- `model.pt` — a checkpoint dict with `backbone` and `head` state dicts, loadable by `predict.py`
|
| 235 |
+
and `evaluate.py` in the code repository
|
| 236 |
+
- `finetuning_optimized_config.json` — the full hyperparameter set behind that checkpoint
|
| 237 |
+
together with the dataset paths and the split settings. Pass it to
|
| 238 |
+
`train_finetuning.py` to retrain the task from the pretrained backbone, or to `evaluate.py` to
|
| 239 |
+
score the checkpoint.
|
| 240 |
+
- the task tokenizer and `config.json`
|
| 241 |
+
|
| 242 |
|
| 243 |
### `models/DMGI/dmgi_model.pt`
|
| 244 |
|
|
|
|
| 297 |
|
| 298 |
### Fine-tune from the pretrained backbone
|
| 299 |
|
| 300 |
+
Each task ships the hyperparameters that produced its checkpoints, so the recommended way to
|
| 301 |
+
retrain is to hand `train_finetuning.py` that config instead of re-deriving the flags.
|
| 302 |
+
|
| 303 |
+
The paths inside the configs are relative to the code repository root, with this dataset mounted at
|
| 304 |
+
`data/`. Download into `data/` from the root of your clone and everything lines up:
|
| 305 |
+
|
| 306 |
```bash
|
| 307 |
+
cd /path/to/SELFormerMM # the code repository
|
| 308 |
+
|
| 309 |
huggingface-cli download HUBioDataLab/SELFormerMM --repo-type dataset \
|
| 310 |
+
--include "models/SELFormerMM/*" "models/finetuned/bbbp/*" \
|
| 311 |
+
"finetuning_datasets/classification/bbbp/*" --local-dir ./data
|
| 312 |
|
| 313 |
python train_finetuning.py \
|
| 314 |
+
--config data/models/finetuned/bbbp/seed_42/finetuning_optimized_config.json \
|
| 315 |
+
--save_dir ./runs/bbbp
|
| 316 |
+
```
|
| 317 |
+
|
| 318 |
+
`models/SELFormerMM` in the dataset becomes `data/models/SELFormerMM` locally, which is exactly what
|
| 319 |
+
the config's `pretrained_multimodal_dir` points at. If you download somewhere else, override the
|
| 320 |
+
three path flags (`--pretrained_multimodal_dir`, `--dataset_meta_csv`, `--dataset_embs_npz`); any
|
| 321 |
+
flag on the command line wins over the config, which is also how you sweep one setting
|
| 322 |
+
(`--seed 123`, `--head_lr 1e-4`, …) while keeping the rest fixed.
|
| 323 |
+
|
| 324 |
+
Without a config the equivalent call is:
|
| 325 |
+
|
| 326 |
+
```bash
|
| 327 |
+
python train_finetuning.py \
|
| 328 |
+
--model_path HUBioDataLab/SELFormer \
|
| 329 |
+
--pretrained_multimodal_dir data/models/SELFormerMM \
|
| 330 |
+
--dataset_meta_csv data/finetuning_datasets/classification/bbbp/bbbp.csv \
|
| 331 |
+
--dataset_embs_npz data/finetuning_datasets/classification/bbbp/bbbp_embs.npz \
|
| 332 |
+
--task_type binary --label_column p_np --num_labels 2 \
|
| 333 |
+
--use_scaffold 1 --seed 42 --epochs 50 \
|
| 334 |
+
--batch_size 32 --backbone_lr 5e-5 --head_lr 5e-5 --weight_decay 0.01 \
|
| 335 |
--save_dir ./runs/bbbp
|
| 336 |
```
|
| 337 |
|
|
|
|
| 339 |
|
| 340 |
```bash
|
| 341 |
python predict.py \
|
| 342 |
+
--model_dir data/models/finetuned/bbbp/seed_42 \
|
| 343 |
+
--input_meta_csv data/finetuning_datasets/classification/bbbp/bbbp.csv \
|
| 344 |
+
--input_embs_npz data/finetuning_datasets/classification/bbbp/bbbp_embs.npz \
|
| 345 |
+
--task_type binary --num_labels 2 --label_column p_np \
|
| 346 |
--output_csv ./bbbp_predictions.csv
|
| 347 |
```
|
| 348 |
|
| 349 |
+
### Score the released checkpoints
|
| 350 |
+
|
| 351 |
+
`predict.py` writes predictions but no metrics. `evaluate.py` rebuilds the split a checkpoint was
|
| 352 |
+
trained with and prints them. Point it at the task directory to score all three seeds and get the
|
| 353 |
+
mean ± standard deviation, which is the form the table above is stated in:
|
| 354 |
+
|
| 355 |
+
```bash
|
| 356 |
+
python evaluate.py \
|
| 357 |
+
--model_dir data/models/finetuned/bbbp \
|
| 358 |
+
--config data/models/finetuned/bbbp/seed_42/finetuning_optimized_config.json \
|
| 359 |
+
--device cuda
|
| 360 |
+
```
|
| 361 |
+
|
| 362 |
+
```
|
| 363 |
+
[evaluate] 3 seeds: 42=0.9484 123=0.9264 3407=0.9605
|
| 364 |
+
[evaluate] roc-auc = 0.9451 +/- 0.0141 (mean +/- std over seeds)
|
| 365 |
+
```
|
| 366 |
+
|
| 367 |
+
Each seed is scored on its own split, taken from the directory name, so one checkpoint cannot
|
| 368 |
+
accidentally be evaluated under another's. For a single seed, pass that seed's config and leave
|
| 369 |
+
`--model_dir` out:
|
| 370 |
+
|
| 371 |
+
```bash
|
| 372 |
+
python evaluate.py \
|
| 373 |
+
--config data/models/finetuned/bbbp/seed_123/finetuning_optimized_config.json \
|
| 374 |
+
--device cuda
|
| 375 |
+
```
|
| 376 |
+
|
| 377 |
### Pretrain on your own corpus
|
| 378 |
|
| 379 |
Supply a SELFIES CSV plus a `.npy` per modality with identical row ordering; substitute a
|