Download code/README.md from eduzrh/LNPBench: direct link, hf CLI and curl.
- Browser
- Download file 15.6 kB
-
https://huggingface.co/datasets/eduzrh/LNPBench/resolve/4168d53fc6eb5ca3fc229a71f6501bdffe77af08/code/README.md
- Command line
-
hf download hf://datasets/eduzrh/LNPBench@4168d53fc6eb5ca3fc229a71f6501bdffe77af08/code/README.md
-
curl -L -o README.md https://huggingface.co/datasets/eduzrh/LNPBench/resolve/4168d53fc6eb5ca3fc229a71f6501bdffe77af08/code/README.md
LNPBench
A reproducible benchmark and three physics-informed architectures for structure–function learning of lipid nanoparticles on LNPDB.
This repository accompanies a manuscript submitted to Engineering (special issue Intelligent Drug Delivery Systems). It contains the full data pipeline, all baseline re-implementations, the three proposed models, the evaluation harness, every result table and figure, and the scripts needed to reproduce all of it from the public Lipid Nanoparticle Database (LNPDB).
1. What is in here
| Component | Description |
|---|---|
src/lnpbench/data.py |
LNPDB loading, canonicalisation, exact reconstruction of the published splits |
src/lnpbench/prepare.py |
One-off feature cache (fingerprints, RDKit descriptors, graphs, SMILES tokens, cCPP) |
src/lnpbench/cpp.py |
Conformer-based critical packing parameter (cCPP) surrogate |
src/lnpbench/store.py |
Tensor access layer + graph batching |
src/lnpbench/trainer.py |
Unified training loop (early stopping on validation Spearman, optional study-balanced sampling) |
src/lnpbench/metrics.py |
Spearman / Pearson / R² / MAE / RMSE / EF@10 / EF@20 / NDCG@10 |
src/lnpbench/models/backbone.py |
The final formulation encoder: GINE + descriptor MLP + hierarchical physics set + condition path |
src/lnpbench/models/ |
LiON, AGILE, Morgan-MLP, and the three proposed models |
scripts/ |
Benchmark runner, reports, figures, ensembles, ablations, cCPP validation |
Models
Baselines (re-implemented under identical data, splits and compute)
lion— directed message passing (D-MPNN) over the ionisable lipid with the formulation context appended, following LiON (Nat. Commun. 2026).agile— GIN structure encoder + RDKit descriptor encoder + context encoder, following AGILE (Nat. Commun. 2024).xgboost,randomforest,extratrees— tabular models on RDKit descriptors, cCPP and formulation context.mlp_fp— Morgan fingerprint + context MLP.mean— trivial reference.
Proposed
- A — PhyCausal-LNP (
phcausal_phys): hierarchical formulation set with physically biased set attention, condition cross-attention and a within-study ranking loss. - B — PhysSet-LNP (
physset_phys): the final architecture. A GINE encoder over the intact ionisable-lipid graph, an MLP over RDKit descriptors, and a ten-node formulation set (head, linker, tail ×4, whole lipid, helper lipid, cholesterol, PEG lipid) fused by physics-biased set attention. Every node is described by physical descriptors only — no Morgan fingerprint. That single choice is what separates the model from its identity-leaking variant (section 2.4). - C — SeqCausal-LNP (
seqcausal): GINE graph stream + bidirectional selective state-space (Mamba) SMILES stream with gated fusion, FiLM condition modulation and GroupDRO across source studies.
Final predictor. LNPBench-Stack = equal-weight, rank-normalised average of
PhysSet-LNP, random forest and extra trees. The member list is fixed a priori
and no weight is fitted on any evaluation data (section 2.3).
2. Results
Every number below is generated by scripts/report.py and scripts/ensemble.py
from results/*.csv; the authoritative, always-current version is
results/REPORT.md. All runs are full runs: four fully
held-out studies × five published folds = 20 external tasks, three seeds for
every neural model.
2.1 External generalisation
Train on the rest of LNPDB, test on a study the model has never seen. Spearman
rank correlation; seed_avg averages the rank-normalised predictions over the
seeds a model has, per_seed averages the individual runs.
| Model | LM_2019 | BL_2023 | SL_2020 | ZC_2023 | seed_avg | per_seed | seeds |
|---|---|---|---|---|---|---|---|
| Random forest | 0.194 | 0.156 | 0.656 | 0.420 | 0.357 | 0.357 | 1 |
| PhysSet-LNP (B, ours) | 0.142 | 0.103 | 0.750 | 0.430 | 0.356 | 0.345 | 3 |
| Extra trees | 0.179 | 0.049 | 0.713 | 0.445 | 0.346 | 0.346 | 1 |
| AGILE (re-trained, full pool) | 0.166 | 0.018 | 0.721 | 0.414 | 0.330 | 0.312 | 3 |
| LiON (from scratch) | 0.206 | 0.137 | 0.620 | 0.337 | 0.325 | 0.296 | 3 |
| Identity-free flat probe (ours) | 0.184 | −0.071 | 0.732 | 0.401 | 0.312 | 0.312 | 1 |
| XGBoost | 0.117 | 0.085 | 0.669 | 0.329 | 0.300 | 0.300 | 1 |
| PhyCausal-LNP (A, ours) | 0.089 | 0.050 | 0.701 | 0.329 | 0.292 | 0.292 | 1 |
| SeqCausal-LNP (C, ours) | −0.103 | 0.086 | 0.612 | 0.225 | 0.205 | 0.205 | 1 |
| Morgan FP + MLP | −0.063 | 0.007 | 0.490 | 0.344 | 0.194 | 0.194 | 1 |
| LNPBench-Stack (ours) | 0.199 | 0.132 | 0.741 | 0.466 | 0.385 | – | – |
| Published LiON w/ LNPDB | 0.11 | 0.09 | 0.63 | 0.52 | 5 | ||
| Published AGILE | 0.00 | −0.01 | −0.21 | 0.09 | 5 |
Every model is at full coverage: 20 tasks, five folds. seed_avg averages the
rank-normalised predictions over the seeds a model has before scoring; per_seed
averages the individual runs.
The published values are re-digitised from Nat. Commun. 2026 Fig. 3b and are not directly comparable: that AGILE entry was trained on ~1.2k formulations (16× less data than LiON), and the published LiON is pretrained on the whole corpus. Under an identical from-scratch budget AGILE is not negative on SL_2020 — it reaches 0.721 — so the negative value in the published comparison is a training-set-size artefact, not an architectural one.
2.2 What the benchmark shows
- PhysSet-LNP ties the random forest for the best single model. Paired Wilcoxon over the 20 tasks: Δ = −0.000, p = 0.96. The tie hides a real trade-off. PhysSet-LNP is the best model on both large held-out studies (SL_2020 0.750 vs 0.656; ZC_2023 0.430 vs 0.420) and clearly worse on the two small ones (LM_2019 0.142 vs 0.194; BL_2023 0.103 vs 0.156). Against the remaining models the ordering is unambiguous: +0.056 over XGBoost (p = 0.0005), +0.027 over AGILE (p = 0.070), +0.032 over LiON (p = 0.25).
- Cross-family diversity, not any single architecture, is the state of the
art.
LNPBench-Stackreaches 0.385, beating every single model with p < 0.05 (vs random forest +0.028, p = 0.027; vs PhysSet-LNP +0.027, p = 0.024; vs extra trees +0.038, p = 0.0001; vs AGILE +0.054, p = 0.0003). Leave-one-out attribution: removing PhysSet-LNP costs −0.018, removing the random forest −0.010, removing extra trees −0.003. The neural member is the largest single contributor, and the two tree families are not redundant with it. - In-distribution accuracy and cross-study transfer are anti-correlated. Under study-stratified 5-fold CV XGBoost scores 0.611, the fingerprint MLP 0.461 and PhysSet-LNP 0.462; on a genuinely unseen study the order inverts (0.300 / 0.194 / 0.356). The amine-disjoint split says the same thing (0.483 / 0.385 / 0.342). The features that buy in-distribution accuracy are the features that encode which study a formulation came from, so a model can be better precisely because it transfers less of that.
2.3 The dominant failure mode: study identity is a shortcut
Validation Spearman on source studies and external Spearman on a held-out study measure different things. Adding ingredients one at a time to a minimal formulation encoder (fold 0 of LM_2019 and BL_2023):
| Encoder | external Spearman |
|---|---|
| flat, chemistry only | 0.088 |
| + formulation set | −0.021 |
| + physics bias | −0.044 |
| + set + bias + rank loss | 0.035 |
Ablations of the final architecture (all four studies, fold 0, seed 0):
| Variant | external Spearman |
|---|---|
| full model | 0.368 |
| w/o rank loss | 0.352 |
| w/o physics bias | 0.356 |
| fingerprint nodes (study identity) | 0.189 |
Replacing the identity-free physical nodes with Morgan fingerprints of each fragment keeps validation Spearman high — the model still fits the source studies — while external Spearman collapses from 0.368 to 0.189. The fingerprint nodes let the network recognise which study a formulation came from instead of learning chemistry that transfers. This is the largest single effect anywhere in the study, and it is why the released model uses physics descriptors only at the node level, additive context only, and a 30-epoch budget.
A fifth, sampler-level fix — up-weighting the small source studies so that every
study contributes equally to each mini-batch — also fails: 0.304 versus 0.347
for the standard sampler, with BL_2023 dropping to −0.041. The deficit is not
sampling imbalance; the model finds study-specific structure wherever it is
allowed to. Full details in results/REPORT.md §4.1.
2.4 The conformer cCPP surrogate is a descriptor, not an MD replacement
- Protonated-state CPP below neutral-state CPP for 48.3% of 11,648 unique ionisable lipids (MD expectation ~100%): the sign of the pH shift is chance.
- Neutral-state absolute CPP on the one system with shipped MD values: 1.583 vs MD 1.542 — good. Protonated state: 2.469 vs MD 1.379 — not good.
- On the 34 stable LM_2019 bilayers the surrogate correlates with transfection at r = −0.285 (p = 0.10), whereas the MD-based value reported in Nat. Commun. 2026 is +0.53 to +0.72.
It is therefore used only as an input descriptor, and its contribution is
established by the w/o physics bias ablation — which is null (0.356 vs
0.368). We report that honestly rather than claiming the physical prior is what
makes the model work.
---## 3. Setup
git clone https://github.com/evancollins1/LNPDB.git data/LNPDB
pip install -r requirements.txt
pip install -e .
The LNPDB repository provides data/LNPDB_for_LiON/LNPDB.csv (raw) and the
exact split files used by the original publication.
4. Reproduce
4.1 Build the feature cache (once)
python -m lnpbench.prepare --stage all --workers 32
This writes cache/:
samples.parquet— the 18,858 evaluable formulationsil_fp.npy,il_desc.npy,il_cpp.npy,il_graphs.pkl,il_tokens.npzfrag_*.npz— per-substructure fingerprints and physical descriptorssample_features.npz,tasks.pkl,md_labels.npz
cCPP is the only expensive step (~0.4 s per lipid, two protonation states);
it is parallelised over --workers.
4.2 The full benchmark matrix
scripts/run_all_gpu.sh runs exactly what is reported here. The individual
commands are:
# tabular baselines, five folds x four held-out studies
python scripts/run_benchmark.py --models xgboost randomforest extratrees mlp_fp \
--protocols external --device cpu --out results/benchmark_classical.csv
# message-passing baselines, three seeds
python scripts/run_benchmark.py --models lion agile --protocols external \
--seeds 0 1 2 --device cuda --epochs 30 --batch-size 256 \
--save-preds --out results/full_agile.csv
# the proposed models, three seeds (physset) / one seed (phcausal, seqcausal)
python scripts/run_benchmark.py --models physset_phys --protocols external \
--seeds 0 1 2 --device cuda --epochs 30 --batch-size 256 \
--save-preds --out results/full_physset_phys.csv
python scripts/run_benchmark.py --models phcausal_phys --protocols external \
--device cuda --epochs 30 --batch-size 256 --save-preds \
--out results/full_phcausal_phys.csv
python scripts/run_benchmark.py --models seqcausal --protocols external \
--device cuda --epochs 30 --batch-size 128 --save-preds \
--out results/full_seqcausal.csv
# secondary protocols
python scripts/run_benchmark.py --models xgboost mlp_fp physset_phys \
--protocols amine --seeds 0 1 2 --out results/benchmark_amine.csv
python scripts/run_benchmark.py --models xgboost mlp_fp physset_phys \
--protocols cv5 --out results/benchmark_cv5.csv
# study-balanced sampling variant (reported as an ablation of the sampler)
python scripts/run_benchmark.py --models physset_phys_bal --protocols external \
--device cuda --epochs 30 --batch-size 256 --study-balance \
--out results/full_physset_bal.csv
4.3 Tables, figures, ensembles
python scripts/ensemble.py --pred-dirs results/predictions --out results/ensemble.csv
python scripts/report.py --results results # -> results/REPORT.md
python scripts/make_figures.py --results results --outdir figures
python scripts/validate_ccpp.py # -> results/ccpp_validation.json
scripts/report.py reads only CSVs, so the manuscript tables can be regenerated
in seconds without a GPU. scripts/ensemble.py reads only the per-sample
predictions, so the stack and every paired test can be rebuilt without
retraining.
5. Evaluation protocol
The unit is one LNP formulation. The target is the per-study standardised delivery readout shipped with LNPDB. Because the primary metric is Spearman rank correlation, per-study standardisation does not leak information.
Primary protocol (external generalisation). For each of the four studies
that the LNPDB/AGILE comparison holds out entirely (LM_2019, BL_2023,
SL_2020, ZC_2023), the model is trained on the remaining database using the
five published 80/20 folds, validated on the 20% split, and evaluated on the
fully unseen study. We reconstruct the published fold membership exactly by
multiset matching on (SMILES, value).
Secondary protocols.
amine— the published 70/15/15 amine-disjoint split (LNPDB Fig. 3a).cv5— study-stratified 5-fold cross-validation over the entire database.
Metrics: Spearman (primary), Pearson, R², MAE, RMSE, enrichment factor at 10% and 20% (EF@10, EF@20) and NDCG@10.
6. Compute actually used
All neural numbers were produced on a single 24 GB GPU; the tabular baselines were produced on CPU. Total neural compute:
| Model | Runs | Seeds | Folds | Epochs | GPU time |
|---|---|---|---|---|---|
| PhysSet-LNP | 58 | 3 | 5 | 30 | 2.9 h |
| AGILE | 60 | 3 | 5 | 30 | 1.5 h |
| LiON | 60 | 3 | 5 | 30 | 1.3 h |
| SeqCausal-LNP | 8+ | 1 | 2+ | 30 | 2.1 h |
| PhyCausal-LNP | 20 | 1 | 5 | 30 | 0.9 h |
| Identity-free probe | 20 | 1 | 5 | 30 | 0.4 h |
| Morgan FP + MLP | 20 | 1 | 5 | 45 | 0.1 h |
Tabular baselines: ~40 min of CPU for 60 fits. Rebuilding every table and figure from the stored predictions takes under a minute.
7. Reproducibility notes
- All featurisation is deterministic; the cache fully determines the inputs. The cCPP conformer search is seeded from a CRC32 of the SMILES, so it is bit-reproducible across machines.
- Every neural model is trained with early stopping on the validation split; the held-out study is never seen during training or model selection.
- Seeds are explicit (
--seeds), andrun_benchmark.py --resumemakes runs restartable. results/predictions/*.npzstores per-sample predictions (idx,y,pred) so every table, every ensemble and every paired test can be recomputed without retraining.
8. Data and code availability
The derived feature cache, per-sample predictions, result tables, figures and
trained checkpoints are mirrored on Hugging Face:
https://huggingface.co/datasets/eduzrh/LNPBench.
Raw data: LNPDB, https://lnpdb.molcube.com and https://github.com/evancollins1/LNPDB.
9. Citation
@article{lnpbench2026,
title = {Physics-informed hierarchical and set-based learning for lipid
nanoparticle structure--function prediction},
journal = {Engineering},
year = {2026}
}