Views
No views yet
1>>> from transformers import BertForMaskedLM, BertTokenizer, pipeline
2>>> tokenizer = BertTokenizer.from_pretrained('Rostlab/prot_bert_bfd', do_lower_case=False )
3>>> model = BertForMaskedLM.from_pretrained("Rostlab/prot_bert_bfd")
4>>> unmasker = pipeline('fill-mask', model=model, tokenizer=tokenizer)
5>>> 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')
6
7[{'score': 0.1165614128112793,
8 '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]',
9 'token': 5,
10 'token_str': 'L'},
11 {'score': 0.08976086974143982,
12 '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]',
13 'token': 8,
14 'token_str': 'V'},
15 {'score': 0.08864385634660721,
16 '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]',
17 'token': 10,
18 'token_str': 'S'},
19 {'score': 0.06227643042802811,
20 '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]',
21 'token': 6,
22 'token_str': 'A'},
23 {'score': 0.06194969266653061,
24 '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]',
25 'token': 15,
26 'token_str': 'T'}]1from transformers import BertModel, BertTokenizer
2import re
3tokenizer = BertTokenizer.from_pretrained('Rostlab/prot_bert_bfd', do_lower_case=False )
4model = BertModel.from_pretrained("Rostlab/prot_bert_bfd")
5sequence_Example = "A E T C Z A O"
6sequence_Example = re.sub(r"[UZOB]", "X", sequence_Example)
7encoded_input = tokenizer(sequence_Example, return_tensors='pt')
8output = model(**encoded_input)[CLS] Protein Sequence A [SEP] Protein Sequence B [SEP][MASK].| Task/Dataset | secondary structure (3-states) | secondary structure (8-states) | Localization | Membrane |
|---|---|---|---|---|
| CASP12 | 76 | 65 | ||
| TS115 | 84 | 73 | ||
| CB513 | 83 | 70 | ||
| DeepLoc | 78 | 91 |
1@article {Elnaggar2020.07.12.199554,
2 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},
3 title = {ProtTrans: Towards Cracking the Language of Life{\textquoteright}s Code Through Self-Supervised Deep Learning and High Performance Computing},
4 elocation-id = {2020.07.12.199554},
5 year = {2020},
6 doi = {10.1101/2020.07.12.199554},
7 publisher = {Cold Spring Harbor Laboratory},
8 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.},
9 URL = {https://www.biorxiv.org/content/early/2020/07/21/2020.07.12.199554},
10 eprint = {https://www.biorxiv.org/content/early/2020/07/21/2020.07.12.199554.full.pdf},
11 journal = {bioRxiv}
12}Created by Ahmed Elnaggar/@Elnaggar_AI | LinkedIn