File size: 1,896 Bytes
3268dfc 58c1360 a3a86d3 6a3704d 3268dfc c6e45fc 6a3704d 2e96d8d 6a3704d dd7ff1f e7f41d0 a51645a e7f41d0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | ---
tags:
- model_hub_mixin
- pytorch_model_hub_mixin
---

# Molecule Embedding Diffusion Language Model (DLM)
This HuggingFace 🤗 implementation code only support molecule embedding extraction with DLM, for generation code please refer to our [main ApexOracle GitHub repo](https://github.com/DragonDescentZerotsu/ApexOracle).
### Example Usage
1. Clone repo
```shell
git clone https://huggingface.co/Kiria-Nozan/ApexOracle
cd ApexOracle
```
2. Extract embedding
```python
from DLM_emb_model import MolEmbDLM
from transformers import AutoTokenizer
import torch
MODEL_DIR = "Kiria-Nozan/ApexOracle"
tokenizer = AutoTokenizer.from_pretrained(MODEL_DIR)
model = MolEmbDLM.from_pretrained(MODEL_DIR)
model.eval()
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
model = model.to(device)
seq = "[C][C][O]" # ← replace with the SELFIES string of your molecule
batch = tokenizer(
seq.replace('][', '] ['),
padding=False,
truncation=False,
return_tensors="pt",
)
print(batch)
batch.to(device)
with torch.no_grad():
embeddings = model(
input_ids=batch["input_ids"],
attention_mask=batch["attention_mask"],
) # (1, seq_len + 2, hidden_size), including <cls> and <eos> special tokens
print(f"Embedding shape: {embeddings.shape}")
```
### Paper can be found at [Predicting and generating antibiotics against future pathogens with ApexOracle](https://arxiv.org/pdf/2507.07862) 🚀
### Citation
```
@article{leng2025predicting,
title={Predicting and generating antibiotics against future pathogens with ApexOracle},
author={Leng, Tianang and Wan, Fangping and Torres, Marcelo Der Torossian and de la Fuente-Nunez, Cesar},
journal={arXiv preprint arXiv:2507.07862},
year={2025}
}
```
<p align="center">
<img src="./UPenn_logo.jpg" alt="UPenn" width="300">
</p>
|