lhallee commited on
Commit
c837ffb
·
verified ·
1 Parent(s): 41f44be

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +11 -9
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/ESMplusplus) 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 Huggingface compatibility without requiring the ESM Python package.
11
  The small version corresponds to the 300 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 small version corresponds to the 300 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 — 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 — use `"sdpa"` if exact numerics matter. |
21
- | Flex Attention | `"flex"` | Skips padding tokens via block mask — faster on variable-length batches. Near-exact numerics. First use compiles a Triton kernel (30–120 s). Best combined with `torch.compile`. |
22
- | Auto | `"auto"` | Picks the best available: `kernels_flash` → `flex` → `sdpa`. |
23
 
24
  ```python
25
  from transformers import AutoConfig, AutoModelForMaskedLM
@@ -32,7 +35,7 @@ model = AutoModelForMaskedLM.from_pretrained('Synthyra/ESMplusplus_small', confi
32
  `torch.compile(model)` is heavily recommended for sustained throughput, especially with Flex Attention.
33
 
34
 
35
- ## Use with 🤗 transformers
36
  ```python
37
  from transformers import AutoModelForMaskedLM
38
  model = AutoModelForMaskedLM.from_pretrained('Synthyra/ESMplusplus_small', 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 🤗 peft
118
  ```python
119
  model = AutoModelForSequenceClassification.from_pretrained('Synthyra/ESMplusplus_small', 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 thourough example of fine-tuning, check out our example script [here](https://github.com/Synthyra/FastPLMs/blob/main/fine_tuning_example.py).
140
 
141
 
142
  ## Returning attention maps
@@ -179,7 +181,7 @@ The most gains will be seen with PyTorch > 2.5 on linux machines.
179
  ```bibtex
180
  @misc{FastPLMs,
181
  author={Hallee, Logan and Bichara, David and Gleghorn, Jason P.},
182
- title={FastPLMs: Fast, efficient, protein language model inference from Huggingface AutoModel.},
183
  year={2024},
184
  url={https://huggingface.co/Synthyra/ESMplusplus_small},
185
  DOI={10.57967/hf/3726},
 
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 small version corresponds to the 300 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_small', 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_small', 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
 
181
  ```bibtex
182
  @misc{FastPLMs,
183
  author={Hallee, Logan and Bichara, David and Gleghorn, Jason P.},
184
+ title={FastPLMs: Fast, efficient, protein language model inference from Hugging Face AutoModel.},
185
  year={2024},
186
  url={https://huggingface.co/Synthyra/ESMplusplus_small},
187
  DOI={10.57967/hf/3726},