Noelia Ferruz commited on
Commit
c1253e2
1 Parent(s): ebeb946

Update README.md

Browse files

Fixed typos, included a link for installation.

Files changed (1) hide show
  1. README.md +21 -12
README.md CHANGED
@@ -1,22 +1,26 @@
1
  # **ProtGPT2**
2
 
3
- ProtGPT2 ([paper](https://www.biorxiv.org/content/10.1101/2022.03.09.483666v1)) is a language model that speaks the protein language and can be used for de novo protein design and engineering.
4
- ProtGPT2 is based on the GPT2 Transformer architecture and contains 36 layers with a model dimensionality of 1280, totalling 738 million parameters.
5
 
6
 
7
  ## **Model description**
8
- ProtGPT2 is a decoder-only transformer model pre-trained on the protein space, database UniRef50 (version 2021_04). The pre-training was done on the raw sequences without FASTA headers, details of training and datasets can be found here: https://huggingface.co/datasets/nferruz/UR50_2021_04
9
 
10
- ProtGPT2 was trained in a self-supervised fashion, this means that the raw sequence data was using during training, without including the annotation of sequences. In particular, ProtGPT2 was trained using an causal modelling objective, in which the model is trained to predict the next token (or in this case, oligomer) in the sequence.
11
- By doing so the model learns an internal representation of the 'protein language', in other words, learns the protein language and is able to <em>speak</em> it.
12
-
13
- ProtGPT2 generates sequences that populate unseen regions of the protein space and which besides are globular, ordered and distant from current natural sequences.
14
 
15
- ### **Intended uses and limitations**
 
 
 
 
16
 
17
  Since ProtGPT2 has been trained on the classical language model objective, it excels at generating protein sequences. It can be used to generate sequences in a zero-shot fashion or to generate sequences of a particular type after finetuning on a user-defined dataset.
18
 
19
- Example 1: Generating de novo proteins in a zero-shot fashion. We recommend the following parameters:
 
 
 
20
  ```
21
  >>> from transformers import pipeline
22
  >>> protgpt2 = pipeline('text-generation', model="nferruz/ProtGPT2")
@@ -35,15 +39,20 @@ Example 1: Generating de novo proteins in a zero-shot fashion. We recommend the
35
  {'generated_text': 'M\nRRAVGNADLGMEAARYEPSGAYQASEGDGAHGKPHSLPFVALERWQQLGPEERTLAEAVR\nAVLASGQYLLGEAVRRFETAVAAWLGVPFALGVASGTAALTLALRAYGVGPGDEVIVPAI\nTFIATSNAITAAGARPVLVDIDPSTWNMSVASLAARLTPKTKAILAVHLWGQPVDMHPLL\nDIAAQANLAVIEDCAQALGASIAGTKVGTFGDAAAFSFYPTKNMTTGEGGMLVTNARDLA\nQAARMLRSHGQDPPTAYMHSQVGFN'}
36
  ```
37
 
38
- Example 2: Finetuning on a set of user-defined sequences. This example finetunes using a user-defined training and validation files that contain a set of sequences of interest. The create the validation and training file, it is necessary to (1) substitute the FASTA headers for each sequence with the tag "<|endoftext|>" and (2) split the originating dataset into training and validation files, (this is often done with the ratio 90/10, 80/20 or 95/5). Here we show a learning rate of 1e-06, but ideally should be optimized in separate runs. After training, the finetuned model will be stored in the ./output folder. This model can be used as in the example above to generate tailored sequences.
 
 
39
 
40
- The HuggingFace script can be found here: https://github.com/huggingface/transformers/blob/master/examples/pytorch/language-modeling/run_clm.py
41
 
42
  ```
43
  python run_clm.py --model_name_or_path nferruz/ProtGPT2 --train_file training.txt --validation_file validation.txt --tokenizer_name nferruz/ProtGPT2
44
  --do_train --do_eval --output_dir output --learning_rate 1e-06
45
 
46
  ```
 
 
 
47
 
48
  ### **Training specs**
49
- The model was trained on 128 NVIDIA A100 GPUs for 50 epochs, using a block size of 512, and a total batch size of 1024 (65,536 tokens per batch). The optimizer used was Adam (beta1 = 0.9, beta2 = 0.999) with a learning rate of 1e-3 .
 
1
  # **ProtGPT2**
2
 
3
+ ProtGPT2 ([preprint](https://www.biorxiv.org/content/10.1101/2022.03.09.483666v1)) is a language model that speaks the protein language and can be used for de novo protein design and engineering. ProtGPT2 generated sequences conserve natural proteins' critical features (amino acid propensities, secondary structural content, and globularity) while exploring unseen regions of the protein space.
4
+
5
 
6
 
7
  ## **Model description**
8
+ ProtGPT2 is based on the GPT2 Transformer architecture and contains 36 layers with a model dimensionality of 1280, totalling 738 million parameters.
9
 
10
+ ProtGPT2 is a decoder-only transformer model pre-trained on the protein space, database UniRef50 (version 2021_04). The pre-training was done on the raw sequences without FASTA headers. Details of training and datasets can be found here: https://huggingface.co/datasets/nferruz/UR50_2021_04
 
 
 
11
 
12
+ ProtGPT2 was trained in a self-supervised fashion, i.e., the raw sequence data was used during training without including the annotation of sequences. In particular, ProtGPT2 was trained using a causal modelling objective, in which the model is trained to predict the next token (or, in this case, oligomer) in the sequence.
13
+ By doing so, the model learns an internal representation of proteins and is able to <em>speak</em> the protein language.
14
+
15
+ ### **How to use ProtGPT2**
16
+ ProtGPT2 can be used with the HuggingFace transformer python package. Detailed installation instructions can be found here: https://huggingface.co/docs/transformers/installation
17
 
18
  Since ProtGPT2 has been trained on the classical language model objective, it excels at generating protein sequences. It can be used to generate sequences in a zero-shot fashion or to generate sequences of a particular type after finetuning on a user-defined dataset.
19
 
20
+ **Example 1: Generating _de novo_ proteins in a zero-shot fashion**
21
+
22
+ In the example below, ProtGPT2 generates sequences that follow the amino acid 'M'. Any other amino acid, oligomer, fragment, or protein of choice can be selected instead. The model will generate the most probable sequences that follow the input. Alternatively, the input field can also be left empty and it will choose the starting tokens.
23
+
24
  ```
25
  >>> from transformers import pipeline
26
  >>> protgpt2 = pipeline('text-generation', model="nferruz/ProtGPT2")
 
39
  {'generated_text': 'M\nRRAVGNADLGMEAARYEPSGAYQASEGDGAHGKPHSLPFVALERWQQLGPEERTLAEAVR\nAVLASGQYLLGEAVRRFETAVAAWLGVPFALGVASGTAALTLALRAYGVGPGDEVIVPAI\nTFIATSNAITAAGARPVLVDIDPSTWNMSVASLAARLTPKTKAILAVHLWGQPVDMHPLL\nDIAAQANLAVIEDCAQALGASIAGTKVGTFGDAAAFSFYPTKNMTTGEGGMLVTNARDLA\nQAARMLRSHGQDPPTAYMHSQVGFN'}
40
  ```
41
 
42
+ **Example 2: Finetuning on a set of user-defined sequences**
43
+
44
+ This alternative option to the zero-shot generation permits introducing direction in the generation process. User-defined training and validation files containing the sequences of interest are provided to the model. After a short update of the model's weights, ProtGPT2 will generate sequences that follow the input properties.
45
 
46
+ To create the validation and training file, it is necessary to (1) substitute the FASTA headers for each sequence with the expression "<|endoftext|>" and (2) split the originating dataset into training and validation files (this is often done with the ratio 90/10, 80/20 or 95/5). Then, to finetune the model to the input sequences, we can use the example below. Here we show a learning rate of 1e-06, but ideally, the learning rate should be optimised in separate runs. After training, the finetuned model will be stored in the ./output folder. Lastly, ProtGPT2 can generate the tailored sequences as shown in Example 1:
47
 
48
  ```
49
  python run_clm.py --model_name_or_path nferruz/ProtGPT2 --train_file training.txt --validation_file validation.txt --tokenizer_name nferruz/ProtGPT2
50
  --do_train --do_eval --output_dir output --learning_rate 1e-06
51
 
52
  ```
53
+ The HuggingFace script run_clm.py can be found here: https://github.com/huggingface/transformers/blob/master/examples/pytorch/language-modeling/run_clm.py
54
+
55
+
56
 
57
  ### **Training specs**
58
+ The model was trained on 128 NVIDIA A100 GPUs for 50 epochs, using a block size of 512, and a total batch size of 1024 (65,536 tokens per batch). The optimizer used was Adam (beta1 = 0.9, beta2 = 0.999) with a learning rate of 1e-3.