Transformers
Safetensors
PyTorch
t5
text2text-generation
knowledge-distillation
model-compression
generative-ai
polymer-generation
molecular-generation
property-conditioned-generation
cheminformatics
text-generation-inference
Instructions to use FahimehBahman/PolyTAO-Student with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FahimehBahman/PolyTAO-Student with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("FahimehBahman/PolyTAO-Student") model = AutoModelForSeq2SeqLM.from_pretrained("FahimehBahman/PolyTAO-Student", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,722 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PolyTAO Student-20: Knowledge-Distilled Transformer for Property-Conditioned Polymer Generation
|
| 2 |
+
---
|
| 3 |
+
library_name: transformers
|
| 4 |
+
base_model: hkqiu/PolyTAO-BigSMILES_Version
|
| 5 |
+
tags:
|
| 6 |
+
- transformers
|
| 7 |
+
- pytorch
|
| 8 |
+
- t5
|
| 9 |
+
- knowledge-distillation
|
| 10 |
+
- model-compression
|
| 11 |
+
- generative-ai
|
| 12 |
+
- polymer-generation
|
| 13 |
+
- molecular-generation
|
| 14 |
+
- property-conditioned-generation
|
| 15 |
+
- cheminformatics
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# PolyTAO Student: Knowledge-Distilled Transformer for Property-Conditioned Polymer Generation
|
| 19 |
+
|
| 20 |
+
**PolyTAO Student** is a property-conditioned Transformer model developed as part of my M.Sc. thesis, **βKnowledge-Distilled Transformers for Property-Conditioned Polymer Generation.β**
|
| 21 |
+
|
| 22 |
+
The project investigates whether smaller Transformer models can retain useful generative behavior after knowledge distillation from a larger property-conditioned teacher model.
|
| 23 |
+
|
| 24 |
+
The teacher was initialized from the publicly available **`hkqiu/PolyTAO-BigSMILES_Version`** checkpoint and subsequently trained with molecular-property conditioning. The trained teacher was then frozen and used for feature-level knowledge distillation into smaller student architectures.
|
| 25 |
+
|
| 26 |
+
Multiple student capacities were investigated by reducing the number of encoder and decoder layers while keeping the main Transformer configuration consistent.
|
| 27 |
+
|
| 28 |
+
The checkpoint published in this repository corresponds to the **20% student capacity configuration**.
|
| 29 |
+
|
| 30 |
+
> **Research model:** This checkpoint is provided for research and reproducibility purposes. It is not intended for production use or for making chemical or experimental decisions.
|
| 31 |
+
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
## Research Objective
|
| 35 |
+
|
| 36 |
+
The central research question behind PolyTAO is:
|
| 37 |
+
|
| 38 |
+
> **How does reducing Transformer model capacity affect the quality, chemical validity, and property fidelity of generated polymers?**
|
| 39 |
+
|
| 40 |
+
Rather than training only one compressed model, the research evaluates multiple student capacities to investigate the trade-off between model compression and generative behavior.
|
| 41 |
+
|
| 42 |
+
The work focuses particularly on whether knowledge distilled from a larger Transformer can preserve useful molecular-property information when the depth of the student architecture is substantially reduced.
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
+
|
| 46 |
+
## Model Lineage
|
| 47 |
+
|
| 48 |
+
The model development pipeline can be summarized as:
|
| 49 |
+
|
| 50 |
+
```text
|
| 51 |
+
hkqiu/PolyTAO-BigSMILES_Version
|
| 52 |
+
β
|
| 53 |
+
βΌ
|
| 54 |
+
Property-Conditioned Teacher
|
| 55 |
+
β
|
| 56 |
+
β Feature-Level
|
| 57 |
+
β Knowledge Distillation
|
| 58 |
+
βΌ
|
| 59 |
+
PolyTAO Students
|
| 60 |
+
β
|
| 61 |
+
βββββββββΌβββββββββ
|
| 62 |
+
βΌ βΌ βΌ
|
| 63 |
+
larger medium smaller
|
| 64 |
+
students students students
|
| 65 |
+
β
|
| 66 |
+
βΌ
|
| 67 |
+
CapacityβPerformance
|
| 68 |
+
Evaluation
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
The publicly available `hkqiu/PolyTAO-BigSMILES_Version` checkpoint therefore serves as the starting point for the teacher model rather than being the final student model itself.
|
| 72 |
+
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
## Teacher Model
|
| 76 |
+
|
| 77 |
+
The PolyTAO teacher is based on a **T5-style encoder-decoder Transformer architecture**.
|
| 78 |
+
|
| 79 |
+
The teacher was initialized using:
|
| 80 |
+
|
| 81 |
+
```text
|
| 82 |
+
hkqiu/PolyTAO-BigSMILES_Version
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
and loaded using Hugging Face Transformers.
|
| 86 |
+
|
| 87 |
+
The teacher architecture contains:
|
| 88 |
+
|
| 89 |
+
```text
|
| 90 |
+
Encoder layers: 12
|
| 91 |
+
Decoder layers: 12
|
| 92 |
+
d_model: 768
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
A custom property-conditioning mechanism was added to the model.
|
| 96 |
+
|
| 97 |
+
The teacher receives both:
|
| 98 |
+
|
| 99 |
+
1. a tokenized polymer representation, and
|
| 100 |
+
2. a 15-dimensional molecular-property vector.
|
| 101 |
+
|
| 102 |
+
The property vector is mapped into the Transformer's hidden space using a learned linear projection:
|
| 103 |
+
|
| 104 |
+
```text
|
| 105 |
+
15 Molecular Properties
|
| 106 |
+
β
|
| 107 |
+
βΌ
|
| 108 |
+
Linear Projection
|
| 109 |
+
β
|
| 110 |
+
βΌ
|
| 111 |
+
Normalized Property Embedding
|
| 112 |
+
β
|
| 113 |
+
βΌ
|
| 114 |
+
Encoder Hidden States
|
| 115 |
+
β
|
| 116 |
+
βΌ
|
| 117 |
+
Property-Conditioned
|
| 118 |
+
Encoder Representation
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
The property embedding is added to the encoder hidden states before decoding.
|
| 122 |
+
|
| 123 |
+
After training, the Transformer checkpoint, tokenizer, and learned property projection are saved separately.
|
| 124 |
+
|
| 125 |
+
---
|
| 126 |
+
|
| 127 |
+
## Student Architecture
|
| 128 |
+
|
| 129 |
+
Student models are constructed from the teacher configuration while reducing the number of encoder and decoder layers.
|
| 130 |
+
|
| 131 |
+
Student depth is calculated as:
|
| 132 |
+
|
| 133 |
+
```text
|
| 134 |
+
student_layers = max(
|
| 135 |
+
1,
|
| 136 |
+
round(teacher_layers Γ capacity / 100)
|
| 137 |
+
)
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
The main Transformer configuration is otherwise kept consistent so that the effect of reducing model depth can be investigated more directly.
|
| 141 |
+
|
| 142 |
+
The student Transformer is initialized independently rather than directly copying the trained teacher weights.
|
| 143 |
+
|
| 144 |
+
Knowledge is subsequently transferred from the frozen teacher during student training.
|
| 145 |
+
|
| 146 |
+
### Published Checkpoint
|
| 147 |
+
|
| 148 |
+
The checkpoint published in this repository corresponds to:
|
| 149 |
+
|
| 150 |
+
```text
|
| 151 |
+
Student capacity: 20%
|
| 152 |
+
|
| 153 |
+
Teacher encoder layers: 12
|
| 154 |
+
Student encoder layers: 2
|
| 155 |
+
|
| 156 |
+
Teacher decoder layers: 12
|
| 157 |
+
Student decoder layers: 2
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
This represents an aggressive reduction in Transformer depth and is used to study how much useful generative behavior can be retained through knowledge distillation.
|
| 161 |
+
|
| 162 |
+
---
|
| 163 |
+
|
| 164 |
+
## Property Conditioning
|
| 165 |
+
|
| 166 |
+
Both teacher and student models use the same property-conditioning mechanism.
|
| 167 |
+
|
| 168 |
+
Generation is conditioned on **15 molecular properties**:
|
| 169 |
+
|
| 170 |
+
1. `MolWt`
|
| 171 |
+
2. `HeavyAtomCount`
|
| 172 |
+
3. `NHOHCount`
|
| 173 |
+
4. `NOCount`
|
| 174 |
+
5. `NumAliphaticCarbocycles`
|
| 175 |
+
6. `NumAliphaticHeterocycles`
|
| 176 |
+
7. `NumAliphaticRings`
|
| 177 |
+
8. `NumAromaticCarbocycles`
|
| 178 |
+
9. `NumAromaticHeterocycles`
|
| 179 |
+
10. `NumAromaticRings`
|
| 180 |
+
11. `NumHAcceptors`
|
| 181 |
+
12. `NumHDonors`
|
| 182 |
+
13. `NumHeteroatoms`
|
| 183 |
+
14. `NumRotatableBonds`
|
| 184 |
+
15. `RingCount`
|
| 185 |
+
|
| 186 |
+
During preprocessing, normalized versions of these properties are used when available.
|
| 187 |
+
|
| 188 |
+
The property vector is projected into the Transformer hidden space:
|
| 189 |
+
|
| 190 |
+
```text
|
| 191 |
+
Property Vector (15 dimensions)
|
| 192 |
+
β
|
| 193 |
+
βΌ
|
| 194 |
+
Linear Projection
|
| 195 |
+
β
|
| 196 |
+
βΌ
|
| 197 |
+
L2 Normalization
|
| 198 |
+
β
|
| 199 |
+
βΌ
|
| 200 |
+
Property Scaling
|
| 201 |
+
β
|
| 202 |
+
βΌ
|
| 203 |
+
Property Embedding
|
| 204 |
+
β
|
| 205 |
+
βΌ
|
| 206 |
+
Encoder Hidden States
|
| 207 |
+
β
|
| 208 |
+
βΌ
|
| 209 |
+
Conditioned Representation
|
| 210 |
+
```
|
| 211 |
+
|
| 212 |
+
The property embedding is scaled before being added to the encoder representation.
|
| 213 |
+
|
| 214 |
+
The training configuration uses:
|
| 215 |
+
|
| 216 |
+
```text
|
| 217 |
+
Property scale = 0.05
|
| 218 |
+
```
|
| 219 |
+
|
| 220 |
+
---
|
| 221 |
+
|
| 222 |
+
## Knowledge Distillation
|
| 223 |
+
|
| 224 |
+
The student is trained using a frozen property-conditioned teacher.
|
| 225 |
+
|
| 226 |
+
For each training sample, both models receive the same tokenized polymer representation and molecular-property vector.
|
| 227 |
+
|
| 228 |
+
The teacher generates conditioned encoder hidden representations.
|
| 229 |
+
|
| 230 |
+
The student simultaneously learns:
|
| 231 |
+
|
| 232 |
+
- the sequence-generation task, and
|
| 233 |
+
- the internal representation produced by the teacher.
|
| 234 |
+
|
| 235 |
+
### Sequence Generation Loss
|
| 236 |
+
|
| 237 |
+
The student is trained using the standard sequence-to-sequence cross-entropy loss.
|
| 238 |
+
|
| 239 |
+
### Feature-Level Knowledge Distillation
|
| 240 |
+
|
| 241 |
+
The conditioned encoder representation produced by the student is compared with the corresponding teacher representation.
|
| 242 |
+
|
| 243 |
+
Mean Squared Error (MSE) is used for the feature-level distillation objective.
|
| 244 |
+
|
| 245 |
+
Conceptually:
|
| 246 |
+
|
| 247 |
+
```text
|
| 248 |
+
Teacher
|
| 249 |
+
β
|
| 250 |
+
βΌ
|
| 251 |
+
Conditioned Teacher Hidden States
|
| 252 |
+
β
|
| 253 |
+
β
|
| 254 |
+
β MSE
|
| 255 |
+
β
|
| 256 |
+
βΌ
|
| 257 |
+
Conditioned Student Hidden States
|
| 258 |
+
β²
|
| 259 |
+
β
|
| 260 |
+
Student
|
| 261 |
+
```
|
| 262 |
+
|
| 263 |
+
The training objective combines the sequence-generation and knowledge-distillation objectives.
|
| 264 |
+
|
| 265 |
+
Conceptually:
|
| 266 |
+
|
| 267 |
+
```text
|
| 268 |
+
Total Loss
|
| 269 |
+
=
|
| 270 |
+
Sequence Generation Loss
|
| 271 |
+
+
|
| 272 |
+
Ξ± Γ Knowledge Distillation Loss
|
| 273 |
+
```
|
| 274 |
+
|
| 275 |
+
with:
|
| 276 |
+
|
| 277 |
+
```text
|
| 278 |
+
Ξ± = 0.5
|
| 279 |
+
```
|
| 280 |
+
|
| 281 |
+
During student training, the teacher remains frozen.
|
| 282 |
+
|
| 283 |
+
---
|
| 284 |
+
|
| 285 |
+
## Training Configuration
|
| 286 |
+
|
| 287 |
+
### Teacher
|
| 288 |
+
|
| 289 |
+
The teacher training configuration includes:
|
| 290 |
+
|
| 291 |
+
| Parameter | Value |
|
| 292 |
+
|---|---:|
|
| 293 |
+
| Base checkpoint | `hkqiu/PolyTAO-BigSMILES_Version` |
|
| 294 |
+
| Optimizer | AdamW |
|
| 295 |
+
| Learning rate | `1e-5` |
|
| 296 |
+
| Batch size | `8` |
|
| 297 |
+
| Epochs | `3` |
|
| 298 |
+
| Property scale | `0.05` |
|
| 299 |
+
| Validation ratio | `0.1` |
|
| 300 |
+
| Precision | `32-bit` |
|
| 301 |
+
|
| 302 |
+
The teacher is trained using PyTorch Lightning.
|
| 303 |
+
|
| 304 |
+
Training and validation losses are logged during training.
|
| 305 |
+
|
| 306 |
+
---
|
| 307 |
+
|
| 308 |
+
### Student
|
| 309 |
+
|
| 310 |
+
The student training configuration includes:
|
| 311 |
+
|
| 312 |
+
| Parameter | Value |
|
| 313 |
+
|---|---:|
|
| 314 |
+
| Optimizer | AdamW |
|
| 315 |
+
| Learning rate | `5e-5` |
|
| 316 |
+
| Batch size | `16` |
|
| 317 |
+
| Epochs | `3` |
|
| 318 |
+
| KD alpha | `0.5` |
|
| 319 |
+
| Property scale | `0.05` |
|
| 320 |
+
| Validation ratio | `0.1` |
|
| 321 |
+
| Random seed | `42` |
|
| 322 |
+
| Precision | `32-bit` |
|
| 323 |
+
|
| 324 |
+
The implementation uses:
|
| 325 |
+
|
| 326 |
+
- PyTorch
|
| 327 |
+
- PyTorch Lightning
|
| 328 |
+
- Hugging Face Transformers
|
| 329 |
+
|
| 330 |
+
Training logs include:
|
| 331 |
+
|
| 332 |
+
- total training loss
|
| 333 |
+
- cross-entropy loss
|
| 334 |
+
- knowledge-distillation loss
|
| 335 |
+
- validation loss
|
| 336 |
+
|
| 337 |
+
---
|
| 338 |
+
|
| 339 |
+
## Dataset
|
| 340 |
+
|
| 341 |
+
The research dataset was derived from the **Open Macromolecular Genome (OMG)** polymer dataset.
|
| 342 |
+
|
| 343 |
+
The experimental dataset contains approximately **99,000 polymer samples**, where each sample contains a polymer representation together with molecular-property information.
|
| 344 |
+
|
| 345 |
+
The preprocessing pipeline includes:
|
| 346 |
+
|
| 347 |
+
```text
|
| 348 |
+
Raw Polymer Data
|
| 349 |
+
β
|
| 350 |
+
βΌ
|
| 351 |
+
Cleaning & Filtering
|
| 352 |
+
β
|
| 353 |
+
βΌ
|
| 354 |
+
Property Processing
|
| 355 |
+
β
|
| 356 |
+
βΌ
|
| 357 |
+
Property Normalization
|
| 358 |
+
β
|
| 359 |
+
βΌ
|
| 360 |
+
Polymer Tokenization
|
| 361 |
+
β
|
| 362 |
+
βΌ
|
| 363 |
+
Model Input
|
| 364 |
+
```
|
| 365 |
+
|
| 366 |
+
The molecular descriptors used for conditioning and evaluation are calculated using **RDKit**.
|
| 367 |
+
|
| 368 |
+
The dataset itself is **not distributed in this model repository**.
|
| 369 |
+
|
| 370 |
+
---
|
| 371 |
+
|
| 372 |
+
## Evaluation
|
| 373 |
+
|
| 374 |
+
The generated polymer representations are evaluated using several complementary metrics.
|
| 375 |
+
|
| 376 |
+
Evaluation considers both:
|
| 377 |
+
|
| 378 |
+
1. whether generated structures are chemically valid according to RDKit, and
|
| 379 |
+
2. whether the molecular properties of valid generated structures agree with the requested property conditions.
|
| 380 |
+
|
| 381 |
+
---
|
| 382 |
+
|
| 383 |
+
## Chemical Validity
|
| 384 |
+
|
| 385 |
+
Generated sequences are cleaned and subsequently parsed and sanitized using RDKit.
|
| 386 |
+
|
| 387 |
+
A generated structure is counted as valid only when RDKit can successfully construct and sanitize the molecule.
|
| 388 |
+
|
| 389 |
+
For the final evaluation of the **20% student configuration** published here:
|
| 390 |
+
|
| 391 |
+
| Metric | Result |
|
| 392 |
+
|---|---:|
|
| 393 |
+
| Generated samples | 500 |
|
| 394 |
+
| Valid samples | 250 |
|
| 395 |
+
| **Chemical validity** | **50.0%** |
|
| 396 |
+
|
| 397 |
+
Only valid generated structures are included in downstream molecular-property evaluation.
|
| 398 |
+
|
| 399 |
+
---
|
| 400 |
+
|
| 401 |
+
## Property Evaluation
|
| 402 |
+
|
| 403 |
+
For valid generated structures, the 15 molecular properties are recalculated using RDKit.
|
| 404 |
+
|
| 405 |
+
Generated properties are then compared with the corresponding conditioning targets.
|
| 406 |
+
|
| 407 |
+
The evaluation uses four complementary metrics.
|
| 408 |
+
|
| 409 |
+
### Mean Absolute Error β MAE
|
| 410 |
+
|
| 411 |
+
Measures the average absolute difference between generated and target property values.
|
| 412 |
+
|
| 413 |
+
Lower values indicate smaller average errors.
|
| 414 |
+
|
| 415 |
+
### Root Mean Squared Error β RMSE
|
| 416 |
+
|
| 417 |
+
Measures prediction error while giving greater weight to larger deviations.
|
| 418 |
+
|
| 419 |
+
Lower values indicate smaller errors.
|
| 420 |
+
|
| 421 |
+
### Pearson Correlation
|
| 422 |
+
|
| 423 |
+
Measures the linear relationship between generated and target property values.
|
| 424 |
+
|
| 425 |
+
Higher positive correlation indicates stronger agreement between changes in the target property and changes in the generated property.
|
| 426 |
+
|
| 427 |
+
### Maximum Mean Discrepancy β MMD
|
| 428 |
+
|
| 429 |
+
MMD compares the distributions of generated and target property values using an RBF kernel.
|
| 430 |
+
|
| 431 |
+
Lower MMD indicates closer distributional agreement.
|
| 432 |
+
|
| 433 |
+
However, MMD should **not be interpreted in isolation**.
|
| 434 |
+
|
| 435 |
+
A low MMD value does not necessarily imply superior generative performance. A compressed model may, for example, generate less diverse or structurally simpler outputs whose aggregate property distributions happen to resemble the target distribution.
|
| 436 |
+
|
| 437 |
+
For this reason, MMD is interpreted jointly with:
|
| 438 |
+
|
| 439 |
+
- chemical validity
|
| 440 |
+
- MAE
|
| 441 |
+
- RMSE
|
| 442 |
+
- Pearson correlation
|
| 443 |
+
- qualitative distribution analysis
|
| 444 |
+
|
| 445 |
+
---
|
| 446 |
+
|
| 447 |
+
## Distribution Analysis
|
| 448 |
+
|
| 449 |
+
Selected molecular-property distributions can be visualized by comparing valid generated samples with the corresponding reference distribution.
|
| 450 |
+
|
| 451 |
+
### Molecular Weight
|
| 452 |
+
|
| 453 |
+

|
| 454 |
+
|
| 455 |
+
### Heavy Atom Count
|
| 456 |
+
|
| 457 |
+

|
| 458 |
+
|
| 459 |
+
### Ring Count
|
| 460 |
+
|
| 461 |
+

|
| 462 |
+
|
| 463 |
+
These plots complement the numerical metrics and help illustrate whether the generated structures reproduce important aspects of the target property distributions.
|
| 464 |
+
|
| 465 |
+
---
|
| 466 |
+
|
| 467 |
+
## Complete Experimental Pipeline
|
| 468 |
+
|
| 469 |
+
```text
|
| 470 |
+
Open Macromolecular Genome
|
| 471 |
+
Dataset
|
| 472 |
+
β
|
| 473 |
+
βΌ
|
| 474 |
+
Data Preprocessing
|
| 475 |
+
β
|
| 476 |
+
βΌ
|
| 477 |
+
βββββββββββββββββββββββββββ
|
| 478 |
+
β Polymer Representation β
|
| 479 |
+
β + β
|
| 480 |
+
β 15 Molecular Properties β
|
| 481 |
+
ββββββββββββββ¬βββββββββββββ
|
| 482 |
+
β
|
| 483 |
+
βΌ
|
| 484 |
+
Base Transformer Model
|
| 485 |
+
hkqiu/PolyTAO-BigSMILES_Version
|
| 486 |
+
β
|
| 487 |
+
βΌ
|
| 488 |
+
Property-Conditioned Teacher
|
| 489 |
+
β
|
| 490 |
+
βΌ
|
| 491 |
+
Teacher Hidden States
|
| 492 |
+
β
|
| 493 |
+
β
|
| 494 |
+
β Knowledge Distillation
|
| 495 |
+
βΌ
|
| 496 |
+
Property-Conditioned Student
|
| 497 |
+
β
|
| 498 |
+
βΌ
|
| 499 |
+
Polymer Generation
|
| 500 |
+
β
|
| 501 |
+
βΌ
|
| 502 |
+
RDKit Validation
|
| 503 |
+
β
|
| 504 |
+
βΌ
|
| 505 |
+
Valid Generated Structures
|
| 506 |
+
β
|
| 507 |
+
βΌ
|
| 508 |
+
RDKit Property Recalculation
|
| 509 |
+
β
|
| 510 |
+
βΌ
|
| 511 |
+
βββββββββββββββββββββββββββββ
|
| 512 |
+
β MAE β
|
| 513 |
+
β RMSE β
|
| 514 |
+
β MMD β
|
| 515 |
+
β Pearson Correlation β
|
| 516 |
+
β Chemical Validity β
|
| 517 |
+
βββββββββββββββ¬ββββββββββββββ
|
| 518 |
+
β
|
| 519 |
+
βΌ
|
| 520 |
+
CapacityβPerformance
|
| 521 |
+
Analysis
|
| 522 |
+
```
|
| 523 |
+
|
| 524 |
+
---
|
| 525 |
+
|
| 526 |
+
## Model Files
|
| 527 |
+
|
| 528 |
+
The complete property-conditioned student model requires more than the standard Transformer checkpoint.
|
| 529 |
+
|
| 530 |
+
The model repository may contain files such as:
|
| 531 |
+
|
| 532 |
+
```text
|
| 533 |
+
config.json
|
| 534 |
+
generation_config.json
|
| 535 |
+
model.safetensors
|
| 536 |
+
tokenizer_config.json
|
| 537 |
+
tokenizer files
|
| 538 |
+
property_proj_student.pt
|
| 539 |
+
```
|
| 540 |
+
|
| 541 |
+
The standard Transformer weights are stored in:
|
| 542 |
+
|
| 543 |
+
```text
|
| 544 |
+
model.safetensors
|
| 545 |
+
```
|
| 546 |
+
|
| 547 |
+
The learned property-conditioning projection is stored separately in:
|
| 548 |
+
|
| 549 |
+
```text
|
| 550 |
+
property_proj_student.pt
|
| 551 |
+
```
|
| 552 |
+
|
| 553 |
+
This projection maps the 15-dimensional molecular-property vector into the Transformer hidden space.
|
| 554 |
+
|
| 555 |
+
Because the property-conditioning mechanism is implemented outside the standard T5 forward interface, loading only the Transformer checkpoint is **not sufficient to reproduce property-conditioned generation**.
|
| 556 |
+
|
| 557 |
+
---
|
| 558 |
+
|
| 559 |
+
## Usage
|
| 560 |
+
|
| 561 |
+
This model requires a custom property-conditioning step.
|
| 562 |
+
|
| 563 |
+
It should therefore not be treated as a standard text-to-text T5 model that can reproduce the research pipeline using only a generic Hugging Face `pipeline()` call.
|
| 564 |
+
|
| 565 |
+
The basic loading procedure is:
|
| 566 |
+
|
| 567 |
+
```python
|
| 568 |
+
import torch
|
| 569 |
+
import torch.nn as nn
|
| 570 |
+
|
| 571 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 572 |
+
|
| 573 |
+
MODEL_ID = "FahimehBahman/PolyTAO-Student"
|
| 574 |
+
|
| 575 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 576 |
+
|
| 577 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
| 578 |
+
|
| 579 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(
|
| 580 |
+
MODEL_ID
|
| 581 |
+
).to(device)
|
| 582 |
+
|
| 583 |
+
model.eval()
|
| 584 |
+
|
| 585 |
+
property_proj = nn.Linear(
|
| 586 |
+
15,
|
| 587 |
+
model.config.d_model
|
| 588 |
+
).to(device)
|
| 589 |
+
```
|
| 590 |
+
|
| 591 |
+
The learned weights from:
|
| 592 |
+
|
| 593 |
+
```text
|
| 594 |
+
property_proj_student.pt
|
| 595 |
+
```
|
| 596 |
+
|
| 597 |
+
must then be loaded into `property_proj`.
|
| 598 |
+
|
| 599 |
+
Property-conditioned generation requires the following steps:
|
| 600 |
+
|
| 601 |
+
```text
|
| 602 |
+
Polymer Input
|
| 603 |
+
β
|
| 604 |
+
βΌ
|
| 605 |
+
Tokenization
|
| 606 |
+
β
|
| 607 |
+
βΌ
|
| 608 |
+
Transformer Encoder
|
| 609 |
+
β
|
| 610 |
+
βΌ
|
| 611 |
+
Encoder Hidden States
|
| 612 |
+
β²
|
| 613 |
+
β
|
| 614 |
+
15 Molecular Properties
|
| 615 |
+
β
|
| 616 |
+
βΌ
|
| 617 |
+
Property Projection
|
| 618 |
+
β
|
| 619 |
+
βΌ
|
| 620 |
+
Normalized Property Embedding
|
| 621 |
+
β
|
| 622 |
+
βΌ
|
| 623 |
+
Conditioned Encoder Representation
|
| 624 |
+
β
|
| 625 |
+
βΌ
|
| 626 |
+
Autoregressive Generation
|
| 627 |
+
β
|
| 628 |
+
βΌ
|
| 629 |
+
Generated Polymer
|
| 630 |
+
```
|
| 631 |
+
|
| 632 |
+
The complete training and evaluation implementation is provided in the accompanying PolyTAO source-code repository.
|
| 633 |
+
|
| 634 |
+
---
|
| 635 |
+
|
| 636 |
+
## Intended Use
|
| 637 |
+
|
| 638 |
+
PolyTAO Student is intended primarily for research involving:
|
| 639 |
+
|
| 640 |
+
- knowledge distillation
|
| 641 |
+
- Transformer model compression
|
| 642 |
+
- property-conditioned generation
|
| 643 |
+
- polymer generative modeling
|
| 644 |
+
- capacityβperformance trade-offs
|
| 645 |
+
- efficient generative Transformer architectures
|
| 646 |
+
- evaluation of compressed generative models
|
| 647 |
+
|
| 648 |
+
The checkpoint can also serve as a reproducible artifact for studying aggressive Transformer depth reduction under feature-level knowledge distillation.
|
| 649 |
+
|
| 650 |
+
---
|
| 651 |
+
|
| 652 |
+
## Limitations
|
| 653 |
+
|
| 654 |
+
This model has several important limitations.
|
| 655 |
+
|
| 656 |
+
- It is a **research prototype**, not a production model.
|
| 657 |
+
- Chemical validity does not imply synthesizability.
|
| 658 |
+
- Chemical validity does not imply stability or experimental feasibility.
|
| 659 |
+
- Generated structures have not been experimentally validated.
|
| 660 |
+
- RDKit-based validation is a computational validity check rather than experimental verification.
|
| 661 |
+
- Property conditioning is limited to the molecular descriptors used during training.
|
| 662 |
+
- Performance depends on preprocessing and decoding configuration.
|
| 663 |
+
- Distributional similarity does not guarantee structural diversity.
|
| 664 |
+
- MMD should not be interpreted independently of validity and other evaluation metrics.
|
| 665 |
+
- Results from this model should not be used directly for safety-critical, medical, industrial, or experimental chemical decisions without independent expert validation.
|
| 666 |
+
|
| 667 |
+
---
|
| 668 |
+
|
| 669 |
+
## Research Context
|
| 670 |
+
|
| 671 |
+
PolyTAO was developed as part of the M.Sc. thesis:
|
| 672 |
+
|
| 673 |
+
**Knowledge-Distilled Transformers for Property-Conditioned Polymer Generation**
|
| 674 |
+
|
| 675 |
+
The research investigates the effect of Transformer capacity reduction on property-conditioned polymer generation.
|
| 676 |
+
|
| 677 |
+
The work combines:
|
| 678 |
+
|
| 679 |
+
- Transformer-based generative modeling
|
| 680 |
+
- molecular-property conditioning
|
| 681 |
+
- feature-level knowledge distillation
|
| 682 |
+
- model compression
|
| 683 |
+
- computational chemistry descriptors
|
| 684 |
+
- systematic quantitative evaluation
|
| 685 |
+
|
| 686 |
+
Multiple student configurations were trained and evaluated to investigate how model depth affects generative behavior and property fidelity.
|
| 687 |
+
|
| 688 |
+
The published checkpoint represents the **20% capacity student configuration**.
|
| 689 |
+
|
| 690 |
+
---
|
| 691 |
+
|
| 692 |
+
## Tools and Libraries
|
| 693 |
+
|
| 694 |
+
The project uses:
|
| 695 |
+
|
| 696 |
+
- Python
|
| 697 |
+
- PyTorch
|
| 698 |
+
- PyTorch Lightning
|
| 699 |
+
- Hugging Face Transformers
|
| 700 |
+
- RDKit
|
| 701 |
+
- NumPy
|
| 702 |
+
- Pandas
|
| 703 |
+
- Scikit-learn
|
| 704 |
+
- Matplotlib
|
| 705 |
+
|
| 706 |
+
---
|
| 707 |
+
|
| 708 |
+
## Author
|
| 709 |
+
|
| 710 |
+
**Fahimeh Bahman**
|
| 711 |
+
|
| 712 |
+
M.Sc. Data Science
|
| 713 |
+
Software Engineer & Machine Learning Researcher
|
| 714 |
+
|
| 715 |
+
Research interests include:
|
| 716 |
+
|
| 717 |
+
- Generative AI
|
| 718 |
+
- Transformer Models
|
| 719 |
+
- Knowledge Distillation
|
| 720 |
+
- Model Compression
|
| 721 |
+
- Machine Learning Systems
|
| 722 |
+
- AI for Software Engineering
|