Instructions to use Synthyra/ESMplusplus_large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Synthyra/ESMplusplus_large with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="Synthyra/ESMplusplus_large", trust_remote_code=True)# Load model directly from transformers import AutoModelForMaskedLM model = AutoModelForMaskedLM.from_pretrained("Synthyra/ESMplusplus_large", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
|
|
|
| 3 |
tags: []
|
| 4 |
---
|
| 5 |
|
|
@@ -7,9 +8,11 @@ tags: []
|
|
| 7 |
The GitHub with the implementation and requirements.txt can be found [here](https://github.com/Synthyra/FastPLMs.git)
|
| 8 |
|
| 9 |
# ESM++
|
| 10 |
-
[ESM++](https://github.com/Synthyra/
|
| 11 |
The large version corresponds to the 600 million parameter version of ESMC.
|
| 12 |
|
|
|
|
|
|
|
| 13 |
## Attention backends
|
| 14 |
|
| 15 |
`sdpa` (PyTorch Scaled Dot Product Attention) is the default. The backend is set via `config.attn_backend` before loading.
|
|
@@ -17,9 +20,9 @@ The large version corresponds to the 600 million parameter version of ESMC.
|
|
| 17 |
| Backend | Key | Notes |
|
| 18 |
| :--- | :--- | :--- |
|
| 19 |
| PyTorch SDPA | `"sdpa"` | Default. Exact numerics, stable on all hardware. |
|
| 20 |
-
| Flash Attention | `"kernels_flash"` | Fastest on Ampere/Hopper GPUs. Requires `pip install kernels` (pre-built
|
| 21 |
-
| Flex Attention | `"flex"` | Skips padding tokens via block mask
|
| 22 |
-
| Auto | `"auto"` | Picks the best available: `kernels_flash`
|
| 23 |
|
| 24 |
```python
|
| 25 |
from transformers import AutoConfig, AutoModelForMaskedLM
|
|
@@ -32,7 +35,7 @@ model = AutoModelForMaskedLM.from_pretrained('Synthyra/ESMplusplus_large', confi
|
|
| 32 |
`torch.compile(model)` is heavily recommended for sustained throughput, especially with Flex Attention.
|
| 33 |
|
| 34 |
|
| 35 |
-
## Use with
|
| 36 |
```python
|
| 37 |
from transformers import AutoModelForMaskedLM
|
| 38 |
model = AutoModelForMaskedLM.from_pretrained('Synthyra/ESMplusplus_large', trust_remote_code=True)
|
|
@@ -75,7 +78,6 @@ embedding_dict = model.embed_dataset(
|
|
| 75 |
sequences=[
|
| 76 |
'MALWMRLLPLLALLALWGPDPAAA', ... # list of protein sequences
|
| 77 |
],
|
| 78 |
-
tokenizer=model.tokenizer,
|
| 79 |
batch_size=2, # adjust for your GPU memory
|
| 80 |
max_len=512, # adjust for your needs
|
| 81 |
full_embeddings=False, # if True, no pooling is performed
|
|
@@ -114,7 +116,7 @@ Note:
|
|
| 114 |
- Sequences will be truncated to max_len and sorted by length in descending order for faster processing
|
| 115 |
```
|
| 116 |
|
| 117 |
-
## Fine-tuning with
|
| 118 |
```python
|
| 119 |
model = AutoModelForSequenceClassification.from_pretrained('Synthyra/ESMplusplus_large', num_labels=2, trust_remote_code=True)
|
| 120 |
# these modules handle ESM++ and ESM2 attention layers
|
|
@@ -136,7 +138,7 @@ for param in model.classifier.parameters():
|
|
| 136 |
param.requires_grad = True
|
| 137 |
```
|
| 138 |
|
| 139 |
-
For a more
|
| 140 |
|
| 141 |
|
| 142 |
## Returning attention maps
|
|
@@ -178,9 +180,9 @@ We look at various ESM models and their throughput on an H100. Adding efficient
|
|
| 178 |
```bibtex
|
| 179 |
@misc{FastPLMs,
|
| 180 |
author={Hallee, Logan and Bichara, David and Gleghorn, Jason P.},
|
| 181 |
-
title={FastPLMs: Fast, efficient, protein language model inference from
|
| 182 |
year={2024},
|
| 183 |
-
url={https://huggingface.co/Synthyra/
|
| 184 |
DOI={10.57967/hf/3726},
|
| 185 |
publisher={Hugging Face}
|
| 186 |
}
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
license: mit
|
| 4 |
tags: []
|
| 5 |
---
|
| 6 |
|
|
|
|
| 8 |
The GitHub with the implementation and requirements.txt can be found [here](https://github.com/Synthyra/FastPLMs.git)
|
| 9 |
|
| 10 |
# ESM++
|
| 11 |
+
[ESM++](https://github.com/Synthyra/FastPLMs) is a faithful implementation of [ESMC](https://biohub.ai/esm/protein) ([license](https://github.com/Biohub/esm/blob/main/LICENSE.md)) that allows for batching and standard Hugging Face compatibility without requiring the ESM Python package.
|
| 12 |
The large version corresponds to the 600 million parameter version of ESMC.
|
| 13 |
|
| 14 |
+
This repository includes the Biohub ESM MIT license in `LICENSE`.
|
| 15 |
+
|
| 16 |
## Attention backends
|
| 17 |
|
| 18 |
`sdpa` (PyTorch Scaled Dot Product Attention) is the default. The backend is set via `config.attn_backend` before loading.
|
|
|
|
| 20 |
| Backend | Key | Notes |
|
| 21 |
| :--- | :--- | :--- |
|
| 22 |
| PyTorch SDPA | `"sdpa"` | Default. Exact numerics, stable on all hardware. |
|
| 23 |
+
| Flash Attention | `"kernels_flash"` | Fastest on Ampere/Hopper GPUs. Requires `pip install kernels` (pre-built, no hours-long compilation). Outputs are not bitwise identical to SDPA due to online softmax reordering; differences are often small but not guaranteed to be inconsequential, so use `"sdpa"` if exact numerics matter. |
|
| 24 |
+
| Flex Attention | `"flex"` | Skips padding tokens via block mask for faster variable-length batches. Near-exact numerics. First use compiles a Triton kernel (30-120 s). Best combined with `torch.compile`. |
|
| 25 |
+
| Auto | `"auto"` | Picks the best available: `kernels_flash`, then `flex`, then `sdpa`. |
|
| 26 |
|
| 27 |
```python
|
| 28 |
from transformers import AutoConfig, AutoModelForMaskedLM
|
|
|
|
| 35 |
`torch.compile(model)` is heavily recommended for sustained throughput, especially with Flex Attention.
|
| 36 |
|
| 37 |
|
| 38 |
+
## Use with Hugging Face Transformers
|
| 39 |
```python
|
| 40 |
from transformers import AutoModelForMaskedLM
|
| 41 |
model = AutoModelForMaskedLM.from_pretrained('Synthyra/ESMplusplus_large', trust_remote_code=True)
|
|
|
|
| 78 |
sequences=[
|
| 79 |
'MALWMRLLPLLALLALWGPDPAAA', ... # list of protein sequences
|
| 80 |
],
|
|
|
|
| 81 |
batch_size=2, # adjust for your GPU memory
|
| 82 |
max_len=512, # adjust for your needs
|
| 83 |
full_embeddings=False, # if True, no pooling is performed
|
|
|
|
| 116 |
- Sequences will be truncated to max_len and sorted by length in descending order for faster processing
|
| 117 |
```
|
| 118 |
|
| 119 |
+
## Fine-tuning with Hugging Face PEFT
|
| 120 |
```python
|
| 121 |
model = AutoModelForSequenceClassification.from_pretrained('Synthyra/ESMplusplus_large', num_labels=2, trust_remote_code=True)
|
| 122 |
# these modules handle ESM++ and ESM2 attention layers
|
|
|
|
| 138 |
param.requires_grad = True
|
| 139 |
```
|
| 140 |
|
| 141 |
+
For a more thorough example of fine-tuning, check out our example script [here](https://github.com/Synthyra/FastPLMs/blob/main/fine_tuning_example.py).
|
| 142 |
|
| 143 |
|
| 144 |
## Returning attention maps
|
|
|
|
| 180 |
```bibtex
|
| 181 |
@misc{FastPLMs,
|
| 182 |
author={Hallee, Logan and Bichara, David and Gleghorn, Jason P.},
|
| 183 |
+
title={FastPLMs: Fast, efficient, protein language model inference from Hugging Face AutoModel.},
|
| 184 |
year={2024},
|
| 185 |
+
url={https://huggingface.co/Synthyra/ESMplusplus_large},
|
| 186 |
DOI={10.57967/hf/3726},
|
| 187 |
publisher={Hugging Face}
|
| 188 |
}
|