pstjohn commited on
Commit
38976b8
·
verified ·
1 Parent(s): aa7ff38

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +218 -16
  2. config.json +3 -2
  3. esm_nv.py +5 -2
README.md CHANGED
@@ -5,24 +5,112 @@ widget:
5
  - text: MQIFVKTLTGKTITLEVEPS<mask>TIENVKAKIQDKEGIPPDQQRLIFAGKQLEDGRTLSDYNIQKESTLHLVLRLRGG
6
  ---
7
 
8
- ## ESM-2 (TransformerEngine-optimized)
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  This version of the ESM-2 model is optimized with NVIDIA's
11
- [TransformerEngine](https://github.com/NVIDIA/TransformerEngine) library. It is based on the
12
- [original ESM-2 model](https://huggingface.co/facebook/esm2_t48_15B_UR50D) from Facebook Research,
13
- and (within numerical precision) has identical weights and outputs.
14
-
15
- ESM-2 is a state-of-the-art protein model trained on a masked language modelling objective. It is
16
- suitable for fine-tuning on a wide range of tasks that take protein sequences as input. For detailed
17
- information on the model architecture and training data, please refer to the [accompanying
18
- paper](https://www.biorxiv.org/content/10.1101/2022.07.20.500902v2). You may also be interested in
19
- some demo notebooks
20
- ([PyTorch](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/protein_language_modeling.ipynb),
21
- [TensorFlow](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/protein_language_modeling-tf.ipynb))
22
- which demonstrate how to fine-tune ESM-2 models on your tasks of interest.
23
-
24
- Several ESM-2 checkpoints are available in the Hub with varying sizes. Larger sizes generally have
25
- somewhat better accuracy, but require much more memory and time to train:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  | Checkpoint name | Num layers | Num parameters |
28
  | ------------------------------------------------------------------------ | ---------- | -------------- |
@@ -32,3 +120,117 @@ somewhat better accuracy, but require much more memory and time to train:
32
  | [esm2_t30_150M_UR50D](https://huggingface.co/nvidia/esm2_t30_150M_UR50D) | 30 | 150M |
33
  | [esm2_t12_35M_UR50D](https://huggingface.co/nvidia/esm2_t12_35M_UR50D) | 12 | 35M |
34
  | [esm2_t6_8M_UR50D](https://huggingface.co/nvidia/esm2_t6_8M_UR50D) | 6 | 8M |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  - text: MQIFVKTLTGKTITLEVEPS<mask>TIENVKAKIQDKEGIPPDQQRLIFAGKQLEDGRTLSDYNIQKESTLHLVLRLRGG
6
  ---
7
 
8
+ > [!NOTE]
9
+ > This model has been optimized using NVIDIA's [TransformerEngine](https://github.com/NVIDIA/TransformerEngine)
10
+ > library. Slight numerical differences may be observed between the original model and the optimized
11
+ > version. For instructions on how to install TransformerEngine, please refer to the
12
+ > [official documentation](https://github.com/NVIDIA/TransformerEngine?tab=readme-ov-file#installation).
13
+
14
+ # ESM-2 (TransformerEngine-Optimized) Overview
15
+
16
+ ## Description:
17
+
18
+ ESM-2 is a state-of-the-art protein model trained on a masked language modelling objective. It predicts protein
19
+ structures from amino acid sequences, leveraging a transformer-based architecture for accurate 3D modeling. It is
20
+ suitable for fine-tuning on a wide range of tasks that take protein sequences as input.
21
 
22
  This version of the ESM-2 model is optimized with NVIDIA's
23
+ [TransformerEngine](https://github.com/NVIDIA/TransformerEngine) library. It is based on the original ESM-2 model from
24
+ Facebook Research, and (within numerical precision) has identical weights and outputs.
25
+
26
+ This model is ready for commercial/non-commercial use.
27
+
28
+ ## Third-Party Community Consideration
29
+
30
+ This model is not owned or developed by NVIDIA. This model has been developed and built to a third-party's requirements
31
+ for this application and use case; see link to Non-NVIDIA Model Card [ESM-2 Model
32
+ Card](https://huggingface.co/facebook/esm2_t33_650M_UR50D).
33
+
34
+ ### License/Terms of Use:
35
+
36
+ ESM-2 is licensed under the [MIT license](https://github.com/facebookresearch/esm/blob/main/LICENSE).
37
+
38
+ ### Deployment Geography:
39
+
40
+ Global
41
+
42
+ ### Use Case:
43
+
44
+ Protein structure prediction, specifically predicting 3D protein structures from amino acid sequences.
45
+
46
+ ### Release Date:
47
+
48
+ Hugging Face 07/29/2025 via [https://huggingface.co/nvidia/esm2_t12_35M_UR50D](https://huggingface.co/nvidia/esm2_t12_35M_UR50D)
49
+
50
+ ## Reference(s):
51
+
52
+ - [Evolutionary-scale prediction of atomic level protein structure with a language
53
+ model](https://www.biorxiv.org/content/10.1101/2022.07.20.500902v2) - detailed information on the model architecture
54
+ and training data, please refer to the accompanying [paper].
55
+ - Demo notebooks
56
+ ([PyTorch](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/protein_language_modeling.ipynb),
57
+ [TensorFlow](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/protein_language_modeling-tf.ipynb))
58
+ which demonstrate how to fine-tune ESM-2 models on your tasks of interest.
59
+
60
+ ## Model Architecture:
61
+
62
+ **Architecture Type:** Transformer
63
+ **Network Architecture:** ESM-2
64
+
65
+ **This model was developed based on:** [ESM-2](https://huggingface.co/facebook/esm2_t33_650M_UR50D) <br>
66
+ **Number of model parameters:** 3.4 x 10^7
67
+
68
+ ## Input:
69
+
70
+ **Input Type:** Text (Protein Sequences) <br>
71
+ **Input Format:** String <br>
72
+ **Input Parameters:** One-Dimensional (1D) <br>
73
+ **Other Properties Related to Input:** Protein sequence represented as a string of canonical amino acids, of maximum
74
+ length 1022. Longer sequences are automatically truncated to this length.
75
+
76
+ ## Output:
77
+
78
+ **Output Type:** Embeddings (Amino acid and sequence-level) <br>
79
+ **Output Format:** Vector <br>
80
+ **Output Parameters:** One-Dimensional (1D) <br>
81
+ **Other Properties Related to Output:** Numeric vector with floating-point values corresponding to an embedding for each
82
+ amino acid in the input protein sequence. Maximum output length is 1022 embeddings - one embedding vector per amino
83
+ acid.
84
+
85
+ Our AI models are designed and/or optimized to run on NVIDIA GPU-accelerated systems. By leveraging NVIDIA’s hardware
86
+ (e.g. GPU cores) and software frameworks (e.g., CUDA libraries), the model achieves faster training and inference times
87
+ compared to CPU-only solutions.
88
+
89
+ ## Software Integration:
90
+
91
+ **Runtime Engine(s):**
92
+
93
+ - Hugging Face Transformers
94
+
95
+ **Supported Hardware Microarchitecture Compatibility:**
96
+
97
+ - NVIDIA Ampere
98
+ - NVIDIA Blackwell
99
+ - NVIDIA Hopper
100
+
101
+ **[Preferred/Supported] Operating System(s):**
102
+
103
+ - Linux
104
+
105
+ The integration of foundation and fine-tuned models into AI systems requires additional testing using use-case-specific
106
+ data to ensure safe and effective deployment. Following the V-model methodology, iterative testing and validation at
107
+ both unit and system levels are essential to mitigate risks, meet technical and functional requirements, and ensure
108
+ compliance with safety and ethical standards before deployment.
109
+
110
+ ## Model Version: This model features the following version/checkpoints:
111
+
112
+ Several ESM-2 checkpoints are available with varying sizes. Larger sizes have better accuracy, but require more memory
113
+ and time to train:
114
 
115
  | Checkpoint name | Num layers | Num parameters |
116
  | ------------------------------------------------------------------------ | ---------- | -------------- |
 
120
  | [esm2_t30_150M_UR50D](https://huggingface.co/nvidia/esm2_t30_150M_UR50D) | 30 | 150M |
121
  | [esm2_t12_35M_UR50D](https://huggingface.co/nvidia/esm2_t12_35M_UR50D) | 12 | 35M |
122
  | [esm2_t6_8M_UR50D](https://huggingface.co/nvidia/esm2_t6_8M_UR50D) | 6 | 8M |
123
+
124
+ ## Training and Evaluation Datasets:
125
+
126
+ ## Training Datasets:
127
+
128
+ **Link:** [UniRef90](https://www.uniprot.org/uniref?query=%28identity%3A0.9%29)
129
+
130
+ **Data Modality:**
131
+
132
+ - Text (Protein Sequences)
133
+
134
+ **Text Training Data Size:**
135
+
136
+ - 1 Billion to 10 Trillion Tokens
137
+
138
+ **Data Collection Method:**
139
+
140
+ - Human
141
+
142
+ **Labeling Method:**
143
+
144
+ - N/A
145
+
146
+ **Properties (Quantity, Dataset Descriptions, Sensor(s)):** UniRef90 clusters are generated from the UniRef100 seed
147
+ sequences with a 90% sequence identity threshold using the MMseqs2 algorithm. The seed sequences are the longest members
148
+ of the UniRef100 cluster. However, the longest sequence is not always the most informative. There is often more
149
+ biologically relevant information and annotation (name, function, cross-references) available on other cluster members.
150
+ All the proteins in each cluster are ranked to facilitate the selection of a biologically relevant representative for
151
+ the cluster.
152
+
153
+ **Link:** [UniRef50](https://www.uniprot.org/uniref?query=%28identity%3A0.5%29)
154
+
155
+ **Data Modality:**
156
+
157
+ - Text (Protein Sequences)
158
+
159
+ **Text Training Data Size:**
160
+
161
+ - 1 Billion to 10 Trillion Tokens
162
+
163
+ **Data Collection Method:**
164
+
165
+ - Human
166
+
167
+ **Labeling Method:**
168
+
169
+ - N/A
170
+
171
+ **Properties:** UniRef50 clusters are generated from the UniRef90 seed sequences with a 50% sequence identity threshold
172
+ using the MMseqs2 algorithm. The seed sequences are the longest members of the UniRef90 cluster. However, the longest
173
+ sequence is not always the most informative. There is often more biologically relevant information and annotation (name,
174
+ function, cross-references) available on other cluster members. All the proteins in each cluster are ranked to
175
+ facilitate the selection of a biologically relevant representative for the cluster.
176
+
177
+ ## Evaluation Datasets:
178
+
179
+ **Link:** [Continuous Automated Model Evaluation (CAMEO)](https://pmc.ncbi.nlm.nih.gov/articles/PMC8673552/)
180
+
181
+ **Benchmark Score:** 0.56
182
+
183
+ **Data Collection Method:**
184
+
185
+ - Human
186
+
187
+ **Labeling Method:**
188
+
189
+ - N/A
190
+
191
+ **Properties:** The data is collected by taking sequences of protein structures that are about to be released weekly by
192
+ the Protein Data Bank (PDB). These sequences are sent as "blind targets" to participating protein structure prediction
193
+ servers, which then return their predictions.
194
+
195
+ **Link:** [CASP14 (Critical Assessment of Methods of Protein Structure Prediction)](https://pubmed.ncbi.nlm.nih.gov/34533838/)
196
+
197
+ **Benchmark Score:** 0.41
198
+
199
+ **Data Collection Method:**
200
+
201
+ - Human
202
+
203
+ **Labeling Method:**
204
+
205
+ - N/A
206
+
207
+ **Properties:** The data for CASP14 targets is collected from protein structures that are newly solved by experimental
208
+ structural biologists. The CASP organizers receive the amino acid sequences of these proteins before their full,
209
+ three-dimensional structures are publicly released in the Protein Data Bank (PDB). They then provide these sequences to
210
+ participating research groups and servers, who must submit their predicted structures within a specific time frame.
211
+
212
+ ## Inference:
213
+
214
+ **Acceleration Engine:**
215
+
216
+ - Hugging Face Transformers
217
+
218
+ **Test Hardware:**
219
+
220
+ - A100
221
+ - H100
222
+ - H200
223
+ - GB200
224
+
225
+ ## Ethical Considerations:
226
+
227
+ NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable
228
+ development for a wide array of AI applications. When downloaded or used in accordance with our terms of service,
229
+ developers should work with their internal model team to ensure this model meets requirements for the relevant industry
230
+ and use case and addresses unforeseen product misuse.
231
+
232
+ Users are responsible for ensuring the physical properties of model-generated molecules are appropriately evaluated and
233
+ comply with applicable safety regulations and ethical standards.
234
+
235
+ Please report model quality, risk, security vulnerabilities or NVIDIA AI Concerns
236
+ [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).
config.json CHANGED
@@ -4,12 +4,14 @@
4
  ],
5
  "attention_probs_dropout_prob": 0.0,
6
  "attn_input_format": "bshd",
 
7
  "auto_map": {
8
  "AutoConfig": "esm_nv.NVEsmConfig",
9
  "AutoModel": "esm_nv.NVEsmModel",
10
  "AutoModelForMaskedLM": "esm_nv.NVEsmForMaskedLM"
11
  },
12
  "classifier_dropout": null,
 
13
  "emb_layer_norm_before": false,
14
  "encoder_activation": "gelu",
15
  "esmfold_config": null,
@@ -33,8 +35,7 @@
33
  "position_embedding_type": "rotary",
34
  "qkv_weight_interleaved": true,
35
  "token_dropout": true,
36
- "torch_dtype": "float32",
37
- "transformers_version": "4.55.4",
38
  "use_cache": true,
39
  "vocab_list": null,
40
  "vocab_size": 33
 
4
  ],
5
  "attention_probs_dropout_prob": 0.0,
6
  "attn_input_format": "bshd",
7
+ "attn_mask_type": "padding",
8
  "auto_map": {
9
  "AutoConfig": "esm_nv.NVEsmConfig",
10
  "AutoModel": "esm_nv.NVEsmModel",
11
  "AutoModelForMaskedLM": "esm_nv.NVEsmForMaskedLM"
12
  },
13
  "classifier_dropout": null,
14
+ "dtype": "float32",
15
  "emb_layer_norm_before": false,
16
  "encoder_activation": "gelu",
17
  "esmfold_config": null,
 
35
  "position_embedding_type": "rotary",
36
  "qkv_weight_interleaved": true,
37
  "token_dropout": true,
38
+ "transformers_version": "4.56.2",
 
39
  "use_cache": true,
40
  "vocab_list": null,
41
  "vocab_size": 33
esm_nv.py CHANGED
@@ -60,6 +60,7 @@ class NVEsmConfig(EsmConfig):
60
  micro_batch_size: Optional[int] = None,
61
  max_seq_length: Optional[int] = None,
62
  padded_vocab_size: Optional[int] = 64,
 
63
  **kwargs,
64
  ):
65
  """Initialize the NVEsmConfig with additional TE-related config options.
@@ -89,6 +90,7 @@ class NVEsmConfig(EsmConfig):
89
  ensure same kernels are used for forward propogation and activation recompute phase.
90
  padded_vocab_size: The padded vocabulary size to support FP8. If not provided, defaults
91
  to vocab_size. Must be greater than or equal to vocab_size.
 
92
  **kwargs: Additional config options to pass to EsmConfig.
93
  """
94
  super().__init__(**kwargs)
@@ -99,6 +101,7 @@ class NVEsmConfig(EsmConfig):
99
  self.fuse_qkv_params = fuse_qkv_params
100
  self.micro_batch_size = micro_batch_size
101
  self.max_seq_length = max_seq_length
 
102
 
103
  # Set padded_vocab_size with default fallback to vocab_size
104
  self.padded_vocab_size = padded_vocab_size if padded_vocab_size is not None else self.vocab_size
@@ -133,14 +136,14 @@ class NVEsmEncoder(nn.Module):
133
  qkv_weight_interleaved=config.qkv_weight_interleaved,
134
  layer_number=i + 1,
135
  layer_type="encoder",
136
- self_attn_mask_type="padding",
137
  activation=config.encoder_activation,
138
  attn_input_format=config.attn_input_format,
139
  seq_length=config.max_seq_length,
140
  micro_batch_size=config.micro_batch_size,
141
  num_gqa_groups=config.num_attention_heads,
142
  fuse_qkv_params=config.fuse_qkv_params,
143
- params_dtype=config.torch_dtype,
144
  window_size=(-1, -1),
145
  )
146
  for i in range(config.num_hidden_layers)
 
60
  micro_batch_size: Optional[int] = None,
61
  max_seq_length: Optional[int] = None,
62
  padded_vocab_size: Optional[int] = 64,
63
+ attn_mask_type: str = "padding",
64
  **kwargs,
65
  ):
66
  """Initialize the NVEsmConfig with additional TE-related config options.
 
90
  ensure same kernels are used for forward propogation and activation recompute phase.
91
  padded_vocab_size: The padded vocabulary size to support FP8. If not provided, defaults
92
  to vocab_size. Must be greater than or equal to vocab_size.
93
+ attn_mask_type: The type of attention mask to use.
94
  **kwargs: Additional config options to pass to EsmConfig.
95
  """
96
  super().__init__(**kwargs)
 
101
  self.fuse_qkv_params = fuse_qkv_params
102
  self.micro_batch_size = micro_batch_size
103
  self.max_seq_length = max_seq_length
104
+ self.attn_mask_type = attn_mask_type
105
 
106
  # Set padded_vocab_size with default fallback to vocab_size
107
  self.padded_vocab_size = padded_vocab_size if padded_vocab_size is not None else self.vocab_size
 
136
  qkv_weight_interleaved=config.qkv_weight_interleaved,
137
  layer_number=i + 1,
138
  layer_type="encoder",
139
+ self_attn_mask_type=config.attn_mask_type,
140
  activation=config.encoder_activation,
141
  attn_input_format=config.attn_input_format,
142
  seq_length=config.max_seq_length,
143
  micro_batch_size=config.micro_batch_size,
144
  num_gqa_groups=config.num_attention_heads,
145
  fuse_qkv_params=config.fuse_qkv_params,
146
+ params_dtype=config.dtype,
147
  window_size=(-1, -1),
148
  )
149
  for i in range(config.num_hidden_layers)