模型概述
模型特點
模型能力
使用案例
🚀 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}
}











