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











