Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,43 +1,43 @@
|
|
| 1 |
-
---
|
| 2 |
-
library_name: transformers
|
| 3 |
-
tags: []
|
| 4 |
-
---
|
| 5 |
-
|
| 6 |
-
# NOTE
|
| 7 |
-
The GitHub with the implementation and requirements can be found [here](https://github.com/Synthyra/FastPLMs.git).
|
| 8 |
-
|
| 9 |
-
# DPLM
|
| 10 |
-
Synthyra DPLM checkpoints are HuggingFace AutoModel compatible and include FastPLMs embedding helpers.
|
| 11 |
-
|
| 12 |
-
## Supported models
|
| 13 |
-
```python
|
| 14 |
-
model_dict = {
|
| 15 |
-
"Synthyra/DPLM-150M": "airkingbd/dplm_150m",
|
| 16 |
-
"Synthyra/DPLM-650M": "airkingbd/dplm_650m",
|
| 17 |
-
"Synthyra/DPLM-3B": "airkingbd/dplm_3b",
|
| 18 |
-
}
|
| 19 |
-
```
|
| 20 |
-
|
| 21 |
-
## Use with transformers
|
| 22 |
-
```python
|
| 23 |
-
import torch
|
| 24 |
-
from transformers import AutoModel, AutoModelForMaskedLM
|
| 25 |
-
|
| 26 |
-
model_path = "Synthyra/DPLM-150M"
|
| 27 |
-
model = AutoModel.from_pretrained(model_path, trust_remote_code=True, dtype=torch.float16).eval()
|
| 28 |
-
tokenizer = model.tokenizer
|
| 29 |
-
|
| 30 |
-
batch = tokenizer(["MPRTEIN", "MSEQWENCE"], padding=True, return_tensors="pt")
|
| 31 |
-
with torch.no_grad():
|
| 32 |
-
hidden = model(**batch).last_hidden_state
|
| 33 |
-
|
| 34 |
-
mlm = AutoModelForMaskedLM.from_pretrained(model_path, trust_remote_code=True, dtype=torch.float16).eval()
|
| 35 |
-
with torch.no_grad():
|
| 36 |
-
logits = mlm(**batch).logits
|
| 37 |
-
```
|
| 38 |
-
|
| 39 |
-
## Attention backend
|
| 40 |
-
`sdpa` is the default backend. Flex Attention is available by setting `config.attn_backend = "flex"` before loading.
|
| 41 |
-
|
| 42 |
-
## Embed datasets
|
| 43 |
-
All DPLM models inherit `EmbeddingMixin`, so you can call `model.embed_dataset(...)` directly.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
tags: []
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# NOTE
|
| 7 |
+
The GitHub with the implementation and requirements can be found [here](https://github.com/Synthyra/FastPLMs.git).
|
| 8 |
+
|
| 9 |
+
# DPLM
|
| 10 |
+
Synthyra DPLM checkpoints are HuggingFace AutoModel compatible and include FastPLMs embedding helpers.
|
| 11 |
+
|
| 12 |
+
## Supported models
|
| 13 |
+
```python
|
| 14 |
+
model_dict = {
|
| 15 |
+
"Synthyra/DPLM-150M": "airkingbd/dplm_150m",
|
| 16 |
+
"Synthyra/DPLM-650M": "airkingbd/dplm_650m",
|
| 17 |
+
"Synthyra/DPLM-3B": "airkingbd/dplm_3b",
|
| 18 |
+
}
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
## Use with transformers
|
| 22 |
+
```python
|
| 23 |
+
import torch
|
| 24 |
+
from transformers import AutoModel, AutoModelForMaskedLM
|
| 25 |
+
|
| 26 |
+
model_path = "Synthyra/DPLM-150M"
|
| 27 |
+
model = AutoModel.from_pretrained(model_path, trust_remote_code=True, dtype=torch.float16).eval()
|
| 28 |
+
tokenizer = model.tokenizer
|
| 29 |
+
|
| 30 |
+
batch = tokenizer(["MPRTEIN", "MSEQWENCE"], padding=True, return_tensors="pt")
|
| 31 |
+
with torch.no_grad():
|
| 32 |
+
hidden = model(**batch).last_hidden_state
|
| 33 |
+
|
| 34 |
+
mlm = AutoModelForMaskedLM.from_pretrained(model_path, trust_remote_code=True, dtype=torch.float16).eval()
|
| 35 |
+
with torch.no_grad():
|
| 36 |
+
logits = mlm(**batch).logits
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
## Attention backend
|
| 40 |
+
`sdpa` is the default backend. Flex Attention is available by setting `config.attn_backend = "flex"` before loading.
|
| 41 |
+
|
| 42 |
+
## Embed datasets
|
| 43 |
+
All DPLM models inherit `EmbeddingMixin`, so you can call `model.embed_dataset(...)` directly.
|