模型简介
模型特点
模型能力
使用案例
🚀 ProtBert - BFD模型
ProtBert - BFD模型是一个基于蛋白质序列进行预训练的模型,采用掩码语言建模(MLM)目标。它能够从蛋白质序列中提取重要特征,捕捉蛋白质形状的关键生物物理特性,为蛋白质相关的研究和应用提供有力支持。
🚀 快速开始
ProtBert - BFD是基于Bert模型,以自监督的方式在大量蛋白质序列语料库上进行预训练的。这意味着它仅在原始蛋白质序列上进行预训练,无需人工进行任何标注(因此可以利用大量公开可用的数据),并通过自动流程从这些蛋白质序列中生成输入和标签。
与原始Bert版本的一个重要区别在于对序列的处理方式,即把每个序列视为一个完整的文档,因此不使用下一句预测。掩码操作遵循原始Bert训练方式,随机掩码输入中15%的氨基酸。
最后,从该模型提取的特征表明,来自未标记数据(仅蛋白质序列)的语言模型嵌入捕捉了控制蛋白质形状的重要生物物理特性,这意味着学习到了蛋白质序列中所体现的生命语言的部分语法规则。
✨ 主要特性
- 特征提取与微调:该模型可用于蛋白质特征提取,也可在下游任务中进行微调。在某些任务中,微调模型比将其用作特征提取器能获得更高的准确性。
- 捕捉生物物理特性:从无标签数据(仅蛋白质序列)中提取的语言模型嵌入能够捕捉到控制蛋白质形状的重要生物物理特性,有助于理解蛋白质序列中的生命语言语法。
📦 安装指南
文档未提供具体安装步骤,故跳过此章节。
💻 使用示例
基础用法
你可以直接使用这个模型和掩码语言建模管道:
>>> from transformers import BertForMaskedLM, BertTokenizer, pipeline
>>> tokenizer = BertTokenizer.from_pretrained('Rostlab/prot_bert_bfd', do_lower_case=False )
>>> model = BertForMaskedLM.from_pretrained("Rostlab/prot_bert_bfd")
>>> 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.1165614128112793,
'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.08976086974143982,
'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.08864385634660721,
'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.06227643042802811,
'sequence': '[CLS] D L I P T S S K L V V A D T S L Q V K K A F F A L V T [SEP]',
'token': 6,
'token_str': 'A'},
{'score': 0.06194969266653061,
'sequence': '[CLS] D L I P T S S K L V V T D T S L Q V K K A F F A L V T [SEP]',
'token': 15,
'token_str': 'T'}]
高级用法
以下是如何在PyTorch中使用此模型获取给定蛋白质序列的特征:
from transformers import BertModel, BertTokenizer
import re
tokenizer = BertTokenizer.from_pretrained('Rostlab/prot_bert_bfd', do_lower_case=False )
model = BertModel.from_pretrained("Rostlab/prot_bert_bfd")
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 - BFD模型在BFD数据集上进行预训练,该数据集包含21亿个蛋白质序列。
训练过程
预处理
蛋白质序列先转换为大写,然后使用单个空格进行分词,词汇表大小为21。模型的输入形式如下:
[CLS] Protein Sequence A [SEP] Protein Sequence B [SEP]
此外,每个蛋白质序列被视为一个单独的文档。预处理步骤进行了两次,一次是针对总长度(2个序列)小于512个氨基酸的情况,另一次是针对总长度(2个序列)小于2048个氨基酸的情况。
每个序列的掩码过程细节遵循原始Bert模型:
- 15%的氨基酸被掩码。
- 在80%的情况下,被掩码的氨基酸被
[MASK]
替换。 - 在10%的情况下,被掩码的氨基酸被一个随机的(不同的)氨基酸替换。
- 在剩下10%的情况下,被掩码的氨基酸保持不变。
预训练
该模型在单个TPU Pod V3 - 1024上总共训练了100万步。其中80万步使用序列长度为512(批量大小为32k),20万步使用序列长度为2048(批量大小为6k)。使用的优化器是Lamb,学习率为0.002,权重衰减为0.01,学习率在14万步内进行热身,之后线性衰减。
评估结果
在下游任务中进行微调时,该模型取得了以下结果:
测试结果:
任务/数据集 | 二级结构(3状态) | 二级结构(8状态) | 亚细胞定位 | 膜蛋白预测 |
---|---|---|---|---|
CASP12 | 76 | 65 | ||
TS115 | 84 | 73 | ||
CB513 | 83 | 70 | ||
DeepLoc | 78 | 91 |
🔧 技术细节
模型架构
ProtBert - BFD基于Bert模型架构,通过自监督学习在大规模蛋白质序列数据上进行预训练。它采用掩码语言建模(MLM)目标,随机掩码输入序列中的部分氨基酸,然后让模型预测这些被掩码的氨基酸。这种训练方式使得模型能够学习到蛋白质序列中的上下文信息和语义特征。
数据处理
在预处理阶段,蛋白质序列被转换为大写,并使用单个空格进行分词,词汇表大小为21。每个序列被视为一个独立的文档,不使用下一句预测。为了适应不同长度的输入,预处理进行了两次,分别针对总长度小于512和2048个氨基酸的序列组合。
训练优化
模型在单个TPU Pod V3 - 1024上进行训练,使用Lamb优化器,学习率为0.002,权重衰减为0.01。学习率在训练初期进行14万步的热身,之后线性衰减。训练过程分为两个阶段,分别使用不同的序列长度和批量大小,以充分利用硬件资源和数据信息。
📄 许可证
文档未提供许可证信息,故跳过此章节。
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}
}
由 Ahmed Elnaggar/@Elnaggar_AI 创建 | 领英











