Instructions to use Synthyra/DPLM-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Synthyra/DPLM-3B with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import EsmForDPLM model = EsmForDPLM.from_pretrained("Synthyra/DPLM-3B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload modeling_dplm.py with huggingface_hub
Browse files- modeling_dplm.py +5 -1
modeling_dplm.py
CHANGED
|
@@ -1869,7 +1869,7 @@ class DPLMModel(DPLMPreTrainedModel, EmbeddingMixin):
|
|
| 1869 |
)
|
| 1870 |
|
| 1871 |
|
| 1872 |
-
class DPLMForMaskedLM(DPLMPreTrainedModel, EmbeddingMixin):
|
| 1873 |
config_class = DPLMConfig
|
| 1874 |
|
| 1875 |
def __init__(self, config, dropout: float = 0.1):
|
|
@@ -1893,6 +1893,7 @@ class DPLMForMaskedLM(DPLMPreTrainedModel, EmbeddingMixin):
|
|
| 1893 |
self.eos_id = self.tokenizer.eos_token_id
|
| 1894 |
self.x_id = self.tokenizer.convert_tokens_to_ids("X")
|
| 1895 |
self.contact_head = None
|
|
|
|
| 1896 |
|
| 1897 |
def get_input_embeddings(self) -> nn.Module:
|
| 1898 |
return self.esm.get_input_embeddings()
|
|
@@ -1920,6 +1921,9 @@ class DPLMForMaskedLM(DPLMPreTrainedModel, EmbeddingMixin):
|
|
| 1920 |
def predict_contacts(self, input_ids: torch.Tensor, attention_mask: torch.Tensor) -> torch.Tensor:
|
| 1921 |
return self.esm.predict_contacts(input_ids, attention_mask=attention_mask)
|
| 1922 |
|
|
|
|
|
|
|
|
|
|
| 1923 |
def forward(
|
| 1924 |
self,
|
| 1925 |
input_ids: Optional[torch.Tensor] = None,
|
|
|
|
| 1869 |
)
|
| 1870 |
|
| 1871 |
|
| 1872 |
+
class DPLMForMaskedLM(FastPLMTestTimeTrainingMixin, DPLMPreTrainedModel, EmbeddingMixin):
|
| 1873 |
config_class = DPLMConfig
|
| 1874 |
|
| 1875 |
def __init__(self, config, dropout: float = 0.1):
|
|
|
|
| 1893 |
self.eos_id = self.tokenizer.eos_token_id
|
| 1894 |
self.x_id = self.tokenizer.convert_tokens_to_ids("X")
|
| 1895 |
self.contact_head = None
|
| 1896 |
+
self.init_ttt({"lora_target_replace_module": "ModifiedEsmAttention"})
|
| 1897 |
|
| 1898 |
def get_input_embeddings(self) -> nn.Module:
|
| 1899 |
return self.esm.get_input_embeddings()
|
|
|
|
| 1921 |
def predict_contacts(self, input_ids: torch.Tensor, attention_mask: torch.Tensor) -> torch.Tensor:
|
| 1922 |
return self.esm.predict_contacts(input_ids, attention_mask=attention_mask)
|
| 1923 |
|
| 1924 |
+
def _ttt_get_trainable_modules(self) -> list[nn.Module]:
|
| 1925 |
+
return [self.esm]
|
| 1926 |
+
|
| 1927 |
def forward(
|
| 1928 |
self,
|
| 1929 |
input_ids: Optional[torch.Tensor] = None,
|