模型简介
模型特点
模型能力
使用案例
🚀 ProtBert模型
ProtBert模型是一个基于蛋白质序列,采用掩码语言模型(MLM)目标进行预训练的模型。它能从无标签的蛋白质序列数据中提取特征,捕捉蛋白质形状的重要生物物理特性,在蛋白质特征提取和下游任务微调等方面具有重要价值。
🚀 快速开始
ProtBert模型可直接用于掩码语言建模任务,也能用于提取蛋白质序列的特征。以下是使用示例:
用于掩码语言建模
>>> from transformers import BertForMaskedLM, BertTokenizer, pipeline
>>> tokenizer = BertTokenizer.from_pretrained("Rostlab/prot_bert", do_lower_case=False )
>>> model = BertForMaskedLM.from_pretrained("Rostlab/prot_bert")
>>> unmasker = pipeline('fill-mask', model=model, tokenizer=tokenizer)
>>> unmasker('D L I P T S S K L V V [MASK] D T S L Q V K K A F F A L V T')
[{'score': 0.11088453233242035,
'sequence': '[CLS] D L I P T S S K L V V L D T S L Q V K K A F F A L V T [SEP]',
'token': 5,
'token_str': 'L'},
{'score': 0.08402521163225174,
'sequence': '[CLS] D L I P T S S K L V V S D T S L Q V K K A F F A L V T [SEP]',
'token': 10,
'token_str': 'S'},
{'score': 0.07328339666128159,
'sequence': '[CLS] D L I P T S S K L V V V D T S L Q V K K A F F A L V T [SEP]',
'token': 8,
'token_str': 'V'},
{'score': 0.06921856850385666,
'sequence': '[CLS] D L I P T S S K L V V K D T S L Q V K K A F F A L V T [SEP]',
'token': 12,
'token_str': 'K'},
{'score': 0.06382402777671814,
'sequence': '[CLS] D L I P T S S K L V V I D T S L Q V K K A F F A L V T [SEP]',
'token': 11,
'token_str': 'I'}]
用于提取蛋白质序列特征
from transformers import BertModel, BertTokenizer
import re
tokenizer = BertTokenizer.from_pretrained("Rostlab/prot_bert", do_lower_case=False )
model = BertModel.from_pretrained("Rostlab/prot_bert")
sequence_Example = "A E T C Z A O"
sequence_Example = re.sub(r"[UZOB]", "X", sequence_Example)
encoded_input = tokenizer(sequence_Example, return_tensors='pt')
output = model(**encoded_input)
✨ 主要特性
- 自监督学习:ProtBert基于Bert模型,以自监督方式在大量蛋白质序列语料库上进行预训练,无需人工标注数据,可利用大量公开可用数据。
- 序列处理方式独特:与原始Bert版本不同,该模型将每个蛋白质序列视为一个完整文档,不使用下一句预测任务。
- 捕捉生物物理特性:从该模型提取的特征表明,来自无标签数据(仅蛋白质序列)的语言模型嵌入捕捉了控制蛋白质形状的重要生物物理特性,意味着学习到了蛋白质序列中生命语言的部分语法。
📚 详细文档
模型描述
ProtBert基于Bert模型,以自监督方式在大量蛋白质序列语料库上进行预训练。这意味着它仅在原始蛋白质序列上进行预训练,无需人工以任何方式对其进行标注(这就是为什么它可以使用大量公开可用数据),并通过自动过程从这些蛋白质序列生成输入和标签。
与原始Bert版本的一个重要区别在于处理序列的方式,即把每个序列视为独立文档。这意味着不使用下一句预测任务,因为每个序列都被视为一个完整的文档。掩码过程遵循原始Bert训练方式,随机掩码输入中15%的氨基酸。
最后,从该模型提取的特征表明,来自无标签数据(仅蛋白质序列)的语言模型嵌入捕捉了控制蛋白质形状的重要生物物理特性。这意味着学习到了蛋白质序列中生命语言的部分语法。
预期用途和局限性
该模型可用于蛋白质特征提取或在下游任务上进行微调。我们注意到,在某些任务中,对模型进行微调比将其用作特征提取器可以获得更高的准确性。
训练数据
ProtBert模型在Uniref100数据集上进行预训练,该数据集包含2.17亿个蛋白质序列。
训练过程
预处理
蛋白质序列先转换为大写,然后使用单个空格进行分词,词汇表大小为21。将罕见氨基酸“U,Z,O,B”映射为“X”。模型的输入形式如下:
[CLS] Protein Sequence A [SEP] Protein Sequence B [SEP]
此外,每个蛋白质序列被视为一个独立文档。预处理步骤进行了两次,一次是针对组合长度(2个序列)小于512个氨基酸的情况,另一次是针对组合长度(2个序列)小于2048个氨基酸的情况。
每个序列的掩码过程细节遵循原始Bert模型:
- 15%的氨基酸被掩码。
- 在80%的情况下,被掩码的氨基酸被
[MASK]
替换。 - 在10%的情况下,被掩码的氨基酸被一个与它们所替换的氨基酸不同的随机氨基酸替换。
- 在剩下10%的情况下,被掩码的氨基酸保持不变。
预训练
该模型在单个TPU Pod V3 - 512上总共训练了400k步。其中300K步使用序列长度为512(批量大小为15k),100K步使用序列长度为2048(批量大小为2.5k)。使用的优化器是Lamb,学习率为0.002,权重衰减为0.01,学习率在40k步内进行热身,之后学习率线性衰减。
评估结果
在下游任务上进行微调时,该模型取得了以下结果:
任务/数据集 | 二级结构(3状态) | 二级结构(8状态) | 亚细胞定位 | 膜蛋白预测 |
---|---|---|---|---|
CASP12 | 75 | 63 | ||
TS115 | 83 | 72 | ||
CB513 | 81 | 66 | ||
DeepLoc | 79 | 91 |
BibTeX引用
@article {Elnaggar2020.07.12.199554,
author = {Elnaggar, Ahmed and Heinzinger, Michael and Dallago, Christian and Rehawi, Ghalia and Wang, Yu and Jones, Llion and Gibbs, Tom and Feher, Tamas and Angerer, Christoph and Steinegger, Martin and BHOWMIK, DEBSINDHU and Rost, Burkhard},
title = {ProtTrans: Towards Cracking the Language of Life{\textquoteright}s Code Through Self-Supervised Deep Learning and High Performance Computing},
elocation-id = {2020.07.12.199554},
year = {2020},
doi = {10.1101/2020.07.12.199554},
publisher = {Cold Spring Harbor Laboratory},
abstract = {Computational biology and bioinformatics provide vast data gold-mines from protein sequences, ideal for Language Models (LMs) taken from Natural Language Processing (NLP). These LMs reach for new prediction frontiers at low inference costs. Here, we trained two auto-regressive language models (Transformer-XL, XLNet) and two auto-encoder models (Bert, Albert) on data from UniRef and BFD containing up to 393 billion amino acids (words) from 2.1 billion protein sequences (22- and 112 times the entire English Wikipedia). The LMs were trained on the Summit supercomputer at Oak Ridge National Laboratory (ORNL), using 936 nodes (total 5616 GPUs) and one TPU Pod (V3-512 or V3-1024). We validated the advantage of up-scaling LMs to larger models supported by bigger data by predicting secondary structure (3-states: Q3=76-84, 8 states: Q8=65-73), sub-cellular localization for 10 cellular compartments (Q10=74) and whether a protein is membrane-bound or water-soluble (Q2=89). Dimensionality reduction revealed that the LM-embeddings from unlabeled data (only protein sequences) captured important biophysical properties governing protein shape. This implied learning some of the grammar of the language of life realized in protein sequences. The successful up-scaling of protein LMs through HPC to larger data sets slightly reduced the gap between models trained on evolutionary information and LMs. Availability ProtTrans: \<a href="https://github.com/agemagician/ProtTrans"\>https://github.com/agemagician/ProtTrans\</a\>Competing Interest StatementThe authors have declared no competing interest.},
URL = {https://www.biorxiv.org/content/early/2020/07/21/2020.07.12.199554},
eprint = {https://www.biorxiv.org/content/early/2020/07/21/2020.07.12.199554.full.pdf},
journal = {bioRxiv}
}











