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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: pytorch
|
| 4 |
+
tags:
|
| 5 |
+
- chemistry
|
| 6 |
+
- materials
|
| 7 |
+
- polymers
|
| 8 |
+
- molecular-property-prediction
|
| 9 |
+
- inverse-design
|
| 10 |
+
- smiles
|
| 11 |
+
- fire-safety
|
| 12 |
+
base_model:
|
| 13 |
+
- ibm-research/materials.smi-ted
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# poly4mer v3.0.0
|
| 17 |
+
|
| 18 |
+
A chemical language model for polymer **fire property prediction** and **inverse design**,
|
| 19 |
+
conditioned on the test conditions of the experiment (sample thickness and incident heat flux).
|
| 20 |
+
|
| 21 |
+
poly4mer maps a polymer pSMILES string to a single 768-dimensional latent vector `z`. From
|
| 22 |
+
that latent it both reconstructs the pSMILES and predicts four cone-calorimeter properties, so
|
| 23 |
+
the same representation supports forward prediction and gradient-based design in one space.
|
| 24 |
+
|
| 25 |
+
| | |
|
| 26 |
+
|---|---|
|
| 27 |
+
| Code | https://github.com/fishmoon1234/poly4mer (branch `dev`) |
|
| 28 |
+
| Backbone | [SMI-TED](https://github.com/IBM/materials) Light, frozen |
|
| 29 |
+
| Latent | 768 dimensions |
|
| 30 |
+
| Max sequence | 202 tokens, vocabulary 2393 |
|
| 31 |
+
| Properties | time to ignition, peak heat release rate, smoke extinction area, CO yield |
|
| 32 |
+
| Conditions | sample thickness (mm), incident heat flux (kW/m²) |
|
| 33 |
+
| License | MIT |
|
| 34 |
+
|
| 35 |
+
## Predicted properties
|
| 36 |
+
|
| 37 |
+
| Key | Property | Unit |
|
| 38 |
+
|---|---|---|
|
| 39 |
+
| `tig` | time to ignition | s |
|
| 40 |
+
| `pkhrr` | peak heat release rate | kW/m² |
|
| 41 |
+
| `sea` | smoke extinction area | m²/kg |
|
| 42 |
+
| `co` | carbon monoxide yield | kg/kg |
|
| 43 |
+
|
| 44 |
+
## Files
|
| 45 |
+
|
| 46 |
+
This repository holds both released versions. v3 lives under `poly4mer_pretrained_v3/`.
|
| 47 |
+
|
| 48 |
+
| Path in this repository | Size | Where it goes in the code repo |
|
| 49 |
+
|---|---:|---|
|
| 50 |
+
| `poly4mer_pretrained_v3/poly4mer_v3.ckpt` | 3.7 GB | `checkpoint/` |
|
| 51 |
+
| `poly4mer_pretrained_v2/smi_ted_light/smi-ted-Light_40.pt` | 1.1 GB | `smi_ted_light/` |
|
| 52 |
+
| `poly4mer_pretrained_v3/tig_10folds/fold_{0..9}_best_fp32.ckpt` | 32 MB | `poly4mer_monotone/checkpoint/tig/last_two_linear/` |
|
| 53 |
+
| `poly4mer_pretrained_v3/phrr_10folds/fold_{0..9}_best_fp32.ckpt` | 32 MB | `poly4mer_monotone/checkpoint/phrr/last_two_linear/` |
|
| 54 |
+
| `poly4mer_pretrained_v3/sea_10folds/fold_{0..9}.ckpt` | 32 MB | `checkpoint/fire_property_heads/sea/` |
|
| 55 |
+
| `poly4mer_pretrained_v3/co_10folds/fold_{0..9}.ckpt` | 32 MB | `checkpoint/fire_property_heads/co/` |
|
| 56 |
+
|
| 57 |
+
Only the first two are needed for prediction, reconstruction or design. The main checkpoint
|
| 58 |
+
already carries a property head for each of the four properties.
|
| 59 |
+
|
| 60 |
+
**The per-fold folders hold two different kinds of head.** For tig and pHRR they are the
|
| 61 |
+
**monotone** heads described below, recognisable by the `_best_fp32` suffix. For SEA and CO,
|
| 62 |
+
which have no monotone variant, they are the standard per-fold heads used to reproduce the
|
| 63 |
+
cross-validation tables. The v2 release is under `poly4mer_pretrained_v2/`.
|
| 64 |
+
|
| 65 |
+
## What is in `poly4mer_v3.ckpt`
|
| 66 |
+
|
| 67 |
+
| Key | Contents |
|
| 68 |
+
|---|---|
|
| 69 |
+
| `star_encoder` | embeds the `*` attachment-point token |
|
| 70 |
+
| `autoencoder_encoder` | token embeddings → latent `z` |
|
| 71 |
+
| `decoder` | latent `z` → token embeddings |
|
| 72 |
+
| `predictor` | token embeddings → token logits (the **token** predictor, not the property one) |
|
| 73 |
+
| `property_regressors` | four MLP heads for tig, pHRR, SEA, CO |
|
| 74 |
+
| `property_stats` | standardization statistics for thickness, flux and the four targets |
|
| 75 |
+
|
| 76 |
+
> **Two kinds of "predictor".** `predictor` is the token predictor, the last stage of the
|
| 77 |
+
> decoder. The property predictors live under `property_regressors`.
|
| 78 |
+
|
| 79 |
+
The property heads consume the **raw** latent. Only thickness and flux are standardized.
|
| 80 |
+
|
| 81 |
+
| Head | Input | Dimension |
|
| 82 |
+
|---|---|---:|
|
| 83 |
+
| tig | `[z, thickness_norm, flux_norm]` | 770 |
|
| 84 |
+
| pHRR | `[z, thickness_norm, flux_norm]` | 770 |
|
| 85 |
+
| SEA | `z` | 768 |
|
| 86 |
+
| CO | `z` | 768 |
|
| 87 |
+
|
| 88 |
+
Each head emits a standardized value; the physical value is `output * y_std[k] + y_mean[k]`.
|
| 89 |
+
|
| 90 |
+
## Input format
|
| 91 |
+
|
| 92 |
+
Inputs must be **RDKit-canonical pSMILES with bare `*` attachment points**, for example
|
| 93 |
+
`*CC(*)c1ccccc1`. Bracketed stars such as `[*]`, and non-canonical orderings of the same
|
| 94 |
+
molecule, do not encode faithfully and will not reconstruct.
|
| 95 |
+
|
| 96 |
+
This is the single most common cause of a failed installation reporting near-zero
|
| 97 |
+
reconstruction. The repository ships `canonical_psmiles()` and a `--canonicalize` flag for
|
| 98 |
+
exactly this.
|
| 99 |
+
|
| 100 |
+
The model is trained on single repeat units. Multi-component strings joined by `.`, used for
|
| 101 |
+
blends and some thermoset formulations, do not reconstruct: the fragments come back but the
|
| 102 |
+
separator does not.
|
| 103 |
+
|
| 104 |
+
## Quick start
|
| 105 |
+
|
| 106 |
+
```bash
|
| 107 |
+
git clone -b dev https://github.com/fishmoon1234/poly4mer.git && cd poly4mer
|
| 108 |
+
pip install -r requirements.txt
|
| 109 |
+
|
| 110 |
+
huggingface-cli download fishmoon1234/poly4mer \
|
| 111 |
+
poly4mer_pretrained_v3/poly4mer_v3.ckpt --local-dir /tmp/p4m
|
| 112 |
+
mv /tmp/p4m/poly4mer_pretrained_v3/poly4mer_v3.ckpt checkpoint/
|
| 113 |
+
huggingface-cli download fishmoon1234/poly4mer \
|
| 114 |
+
poly4mer_pretrained_v2/smi_ted_light/smi-ted-Light_40.pt --local-dir /tmp/p4m
|
| 115 |
+
mv /tmp/p4m/poly4mer_pretrained_v2/smi_ted_light/smi-ted-Light_40.pt smi_ted_light/
|
| 116 |
+
|
| 117 |
+
python fire_property_prediction_V3.py --smiles '*CC(*)C' --thickness 3 --flux 50
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
```
|
| 121 |
+
>> Predicted Tig 30.0235 s
|
| 122 |
+
>> Predicted pHRR 2106.3787 kW/m^2
|
| 123 |
+
>> Predicted SEA 0.053634 m^2/kg
|
| 124 |
+
>> Predicted CO 0.028990 kg/kg
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
Inverse design from a seed polymer, and a reconstruction check:
|
| 128 |
+
|
| 129 |
+
```bash
|
| 130 |
+
./run_design.sh
|
| 131 |
+
python evaluate_reconstruction_v3.py --files homo=example_pSMILES_homo.txt
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
## Performance
|
| 135 |
+
|
| 136 |
+
### Reconstruction
|
| 137 |
+
|
| 138 |
+
Canonical pSMILES in, canonical pSMILES out, exact string match.
|
| 139 |
+
|
| 140 |
+
| Set | n | Exact match | Mean Tanimoto |
|
| 141 |
+
|---|---:|---:|---:|
|
| 142 |
+
| Training corpus sample | 100,000 | 99.99% | 1.000 |
|
| 143 |
+
| Simulated set | 109,993 | 100.00% | 1.000 |
|
| 144 |
+
| Commodity homopolymers | 16 | 100.00% | 1.000 |
|
| 145 |
+
|
| 146 |
+
The 16 homopolymers include seven absent from the training corpus; all seven reconstruct
|
| 147 |
+
exactly, including an 87-token polyetherimide.
|
| 148 |
+
|
| 149 |
+
### Property prediction
|
| 150 |
+
|
| 151 |
+
Mean absolute relative error on experimental cone-calorimeter data, 10-fold cross-validation.
|
| 152 |
+
|
| 153 |
+
| Property | Best-5 folds |
|
| 154 |
+
|---|---:|
|
| 155 |
+
| tig | 15.76% |
|
| 156 |
+
| pHRR | 12.61% |
|
| 157 |
+
| SEA | 1.58% |
|
| 158 |
+
| CO | 0.93% |
|
| 159 |
+
|
| 160 |
+
**Read these with the protocol in mind.** The training epoch and learning rate are selected on
|
| 161 |
+
each fold's own test rows, so per-fold test errors are optimistically biased. Prefer the
|
| 162 |
+
all-10 column when a single number is needed. The repository ships the fold data, the 40
|
| 163 |
+
per-fold heads and `evaluate_fire_prediction_heads.py` so both columns can be checked, plus a
|
| 164 |
+
`--cv` mode that re-runs the training; re-training reproduces the best-5 figure to about 0.1
|
| 165 |
+
points for tig and 0.03 for CO.
|
| 166 |
+
|
| 167 |
+
Sanity against measurement, at 50 kW/m²:
|
| 168 |
+
|
| 169 |
+
| Polymer | Measured pHRR | Predicted |
|
| 170 |
+
|---|---:|---:|
|
| 171 |
+
| nylon 6,6 | 1226 | 1228 |
|
| 172 |
+
| polypropylene | 2141 | 1947 |
|
| 173 |
+
| PMMA | 1115 | 1144 |
|
| 174 |
+
|
| 175 |
+
## Intended use
|
| 176 |
+
|
| 177 |
+
Screening and ranking candidate polymer repeat units for fire behaviour, and exploring the
|
| 178 |
+
latent neighbourhood of a known polymer. Suitable for research.
|
| 179 |
+
|
| 180 |
+
**Not suitable** as a substitute for cone-calorimeter testing, for safety certification, or
|
| 181 |
+
for any decision where a wrong fire-performance estimate carries risk. The experimental data
|
| 182 |
+
behind the property heads is small, a few hundred rows, and errors on unseen polymers are tens
|
| 183 |
+
of percent.
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
## Monotone heads for tig and pHRR
|
| 187 |
+
|
| 188 |
+
`tig_10folds/` and `phrr_10folds/` hold alternative heads that are **hard-monotone in heat
|
| 189 |
+
flux** by construction: tig can only fall as the flux rises, pHRR can only rise. The constraint
|
| 190 |
+
is structural rather than a penalty, so it holds for every input, including polymers far
|
| 191 |
+
outside the data. The encoder is unchanged, so these drop in beside the main checkpoint.
|
| 192 |
+
|
| 193 |
+
The head is not read out directly. The MLP is evaluated at 17 fixed flux knots from 20 to
|
| 194 |
+
100 kW/m², a running minimum (tig) or maximum (pHRR) is taken across them, and the value at
|
| 195 |
+
the requested flux is interpolated between the two bracketing knots. Fluxes outside that range
|
| 196 |
+
are clamped to the end knots.
|
| 197 |
+
|
| 198 |
+
Ten checkpoints ship per property, one per fold. `--ensemble` averages them, which is the
|
| 199 |
+
safer choice for a polymer outside the experimental set.
|
| 200 |
+
|
| 201 |
+
```bash
|
| 202 |
+
cd poly4mer_monotone
|
| 203 |
+
./run_property_prediction_monotone.sh
|
| 204 |
+
```
|
| 205 |
+
|
| 206 |
+
Use them when a prediction feeds an optimizer or a screening loop and a non-physical flux
|
| 207 |
+
trend would be costly. On held-out polymers they are **level with**, not better than, the
|
| 208 |
+
standard heads under leakage-free selection, so the case for them is the guarantee rather than
|
| 209 |
+
the accuracy. SEA and CO have no monotone variant.
|
| 210 |
+
|
| 211 |
+
## Citation
|
| 212 |
+
|
| 213 |
+
```bibtex
|
| 214 |
+
@article{liu2025harnessing,
|
| 215 |
+
title={Harnessing large language models for data-scarce learning of polymer properties},
|
| 216 |
+
author={Liu, Ning and Jafarzadeh, Siavash and Lattimer, Brian Y and Ni, Shuna and Lua, Jim and Yu, Yue},
|
| 217 |
+
journal={Nature Computational Science},
|
| 218 |
+
volume={5},
|
| 219 |
+
number={3},
|
| 220 |
+
pages={245--254},
|
| 221 |
+
year={2025},
|
| 222 |
+
publisher={Nature Publishing Group US New York}
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
@inproceedings{yin2025fake,
|
| 226 |
+
title={Fake It Till You Make It: Multi-Physics Synthesis Breaks the Data Barrier in Chemical Language Models},
|
| 227 |
+
author={Yin, Naiyu and Liu, Ning and Chen, Jiuzhou and Lattimer, Brian Y and Lua, Jim and Yu, Yue},
|
| 228 |
+
booktitle={NeurIPS 2025 Machine Learning and the Physical Sciences Workshop}
|
| 229 |
+
}
|
| 230 |
+
```
|