MolE represents molecules as sequences of Morgan fingerprint atom environments (radius-0, vocab ~211 tokens) and encodes them with a DeBERTa disentangled-attention transformer. Bond distances from the molecular graph are passed as relative position biases — no absolute positional embeddings.
Full TDC 22-task sweep. RTD-25% beats RTD-15% on hard pharmacokinetic tasks (vdss_lombardo +0.065, half_life_obach +0.183, cyp2d6_substrate +0.079). On easier tasks (herg, bioavailability), 15% is slightly better. Summary: 25% masking improves generalization on low-signal tasks at cost of slightly worse performance on saturated tasks.
1from collections import OrderedDict
2import torch
3from huggingface_hub import hf_hub_download
4from DeBERTa.deberta.config import ModelConfig
5from mole.training.models.mole import AtomEnvEmbeddings
6
7DISC_CFG = dict(
8 embedding_size=768, hidden_size=768, intermediate_size=3072,
9 num_hidden_layers=12, num_attention_heads=12, attention_head_size=64,
10 attention_probs_dropout_prob=0.1, hidden_dropout_prob=0.1,
11 hidden_act="gelu", layer_norm_eps=1e-7, max_position_embeddings=0,
12 max_relative_positions=512, position_buckets=0, norm_rel_ebd="layer_norm",
13 pos_att_type="p2c|c2p", position_biased_input=False, relative_attention=True,
14 share_att_key=True, type_vocab_size=0, vocab_size=211,
15)
16
17ckpt = hf_hub_download("caithmac/MolE-RTD-25pct", "mole_rtd_25pct_final.ckpt")
18raw = torch.load(ckpt, map_location="cpu", weights_only=False)
19sd = raw.get("state_dict", raw)
20
21gen_w = sd["model.generator.embeddings.word_embeddings.weight"]
22bias = sd["model.disc_word_bias"]
23enc_sd = OrderedDict()
24enc_sd["embeddings.word_embeddings.weight"] = gen_w + bias
25for k, v in sd.items():
26 if not k.startswith("model.discriminator."): continue
27 if ".embeddings.word_embeddings." in k: continue
28 enc_sd[k[len("model.discriminator."):]] = v
29
30encoder = AtomEnvEmbeddings(ModelConfig.from_dict(DISC_CFG))
31encoder.load_state_dict(enc_sd, strict=False)
32encoder.eval()
For Step 2 version (recommended for downstream use), see
caithmac/MolE-RTD-25pct-S2.
1@misc{mole-rtd-25pct,
2 author = {caithmac},
3 title = {MolE-RTD-25pct: RTD pre-training of MolE at 25% masking rate on 415M ZINC molecules},
4 year = {2026},
5 url = {https://huggingface.co/caithmac/MolE-RTD-25pct}
6}