🚀 MoLFormer-XL-both-10%
MoLFormer是一类在来自ZINC和PubChem的多达11亿个分子的SMILES字符串表示上进行预训练的模型。本仓库是在这两个数据集的10%数据上进行预训练的模型。该模型由Ross等人在论文Large-Scale Chemical Language Representations Capture Molecular Structure and Properties中提出,并首次在此仓库中发布。
🚀 快速开始
使用以下代码开始使用该模型:
import torch
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("ibm/MoLFormer-XL-both-10pct", deterministic_eval=True, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("ibm/MoLFormer-XL-both-10pct", trust_remote_code=True)
smiles = ["Cn1c(=O)c2c(ncn2C)n(C)c1=O", "CC(=O)Oc1ccccc1C(=O)O"]
inputs = tokenizer(smiles, padding=True, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
outputs.pooler_output
✨ 主要特性
- 可用于掩码语言建模,但主要用作特征提取器或针对预测任务进行微调。
- “冻结”的模型嵌入可用于相似度测量、可视化或训练预测模型。
- 也可针对序列分类任务(如溶解度、毒性等)进行微调。
📚 详细文档
模型描述
MoLFormer是一个大规模化学语言模型,旨在学习在以SMILES字符串表示的小分子上训练的模型。MoLFormer利用掩码语言建模,并采用线性注意力Transformer结合旋转嵌入。

上图展示了MoLFormer管道的概述。可以看到,基于Transformer的神经网络模型以自监督的方式在来自两个公共化学数据集PubChem和ZINC的由SMILES序列表示的大量化学分子上进行训练。MoLFormer架构设计了高效的线性注意力机制和相对位置嵌入,目标是学习化学分子有意义且压缩的表示。训练后,MoLFormer基础模型通过在特定任务数据上进行微调,被应用于不同的下游分子属性预测任务。为了进一步测试MoLFormer的表示能力,使用MoLFormer编码来恢复分子相似度,并对给定分子的原子间空间距离和注意力值之间的对应关系进行了分析。
预期用途和限制
该模型可用于掩码语言建模,但主要用于特征提取或针对预测任务进行微调。“冻结”的模型嵌入可用于相似度测量、可视化或训练预测模型。该模型也可针对序列分类任务(如溶解度、毒性等)进行微调。
该模型不用于分子生成,也未对大于约200个原子的分子(即大分子)进行测试。此外,使用无效或非规范的SMILES可能会导致性能下降。
🔧 技术细节
训练数据
我们在ZINC15和PubChem数据集的分子组合上训练了MoLFormer-XL。本仓库包含在10% ZINC + 10% PubChem上训练的版本。
在训练前,使用RDKit对分子进行规范化处理,并去除异构体信息。此外,长度超过202个标记的分子被丢弃。
硬件
评估
我们通过在MoleculeNet的11个基准任务上进行微调来评估MoLFormer。下表显示了不同MoLFormer变体的性能:
|
BBBP |
HIV |
BACE |
SIDER |
ClinTox |
Tox21 |
10% ZINC + 10% PubChem |
91.5 |
81.3 |
86.6 |
68.9 |
94.6 |
84.5 |
10% ZINC + 100% PubChem |
92.2 |
79.2 |
86.3 |
69.0 |
94.7 |
84.5 |
100% ZINC |
89.9 |
78.4 |
87.7 |
66.8 |
82.2 |
83.2 |
MoLFormer-Base |
90.9 |
77.7 |
82.8 |
64.8 |
61.3 |
43.1 |
MoLFormer-XL |
93.7 |
82.2 |
88.2 |
69.0 |
94.8 |
84.7 |
|
QM9 |
QM8 |
ESOL |
FreeSolv |
Lipophilicity |
10% ZINC + 10% PubChem |
1.7754 |
0.0108 |
0.3295 |
0.2221 |
0.5472 |
10% ZINC + 100% PubChem |
1.9093 |
0.0102 |
0.2775 |
0.2050 |
0.5331 |
100% ZINC |
1.9403 |
0.0124 |
0.3023 |
0.2981 |
0.5440 |
MoLFormer-Base |
2.2500 |
0.0111 |
0.2798 |
0.2596 |
0.6492 |
MoLFormer-XL |
1.5984 |
0.0102 |
0.2787 |
0.2308 |
0.5298 |
我们报告了所有分类任务的AUROC、QM9/8的平均MAE以及其余回归任务的RMSE。
📄 许可证
本项目采用Apache-2.0许可证。
📖 引用
@article{10.1038/s42256-022-00580-7,
year = {2022},
title = {{Large-scale chemical language representations capture molecular structure and properties}},
author = {Ross, Jerret and Belgodere, Brian and Chenthamarakshan, Vijil and Padhi, Inkit and Mroueh, Youssef and Das, Payel},
journal = {Nature Machine Intelligence},
doi = {10.1038/s42256-022-00580-7},
pages = {1256--1264},
number = {12},
volume = {4}
}
@misc{https://doi.org/10.48550/arxiv.2106.09553,
doi = {10.48550/ARXIV.2106.09553},
url = {https://arxiv.org/abs/2106.09553},
author = {Ross, Jerret and Belgodere, Brian and Chenthamarakshan, Vijil and Padhi, Inkit and Mroueh, Youssef and Das, Payel},
keywords = {Machine Learning (cs.LG), Computation and Language (cs.CL), Biomolecules (q-bio.BM), FOS: Computer and information sciences, FOS: Computer and information sciences, FOS: Biological sciences, FOS: Biological sciences},
title = {Large-Scale Chemical Language Representations Capture Molecular Structure and Properties},
publisher = {arXiv},
year = {2021},
copyright = {arXiv.org perpetual, non-exclusive license}
}