Instructions to use Synthyra/DPLM2-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Synthyra/DPLM2-3B with Transformers:
# Load model directly from transformers import AutoTokenizer, EsmForDPLM2 tokenizer = AutoTokenizer.from_pretrained("Synthyra/DPLM2-3B", trust_remote_code=True) model = EsmForDPLM2.from_pretrained("Synthyra/DPLM2-3B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload modeling_dplm2.py with huggingface_hub
Browse files- modeling_dplm2.py +5 -1
modeling_dplm2.py
CHANGED
|
@@ -1819,7 +1819,7 @@ class DPLM2Model(DPLM2PreTrainedModel, EmbeddingMixin):
|
|
| 1819 |
)
|
| 1820 |
|
| 1821 |
|
| 1822 |
-
class DPLM2ForMaskedLM(DPLM2PreTrainedModel, EmbeddingMixin):
|
| 1823 |
config_class = DPLM2Config
|
| 1824 |
def __init__(self, config, dropout: float = 0.1, vocab_size: Optional[int] = None):
|
| 1825 |
config.hidden_dropout_prob = dropout
|
|
@@ -1835,6 +1835,7 @@ class DPLM2ForMaskedLM(DPLM2PreTrainedModel, EmbeddingMixin):
|
|
| 1835 |
self.tokenizer = self.__class__.tokenizer
|
| 1836 |
if isinstance(config._name_or_path, str) and len(config._name_or_path) > 0:
|
| 1837 |
self.tokenizer = EsmTokenizer.from_pretrained(config._name_or_path)
|
|
|
|
| 1838 |
|
| 1839 |
def get_input_embeddings(self) -> nn.Module:
|
| 1840 |
return self.esm.get_input_embeddings()
|
|
@@ -1874,6 +1875,9 @@ class DPLM2ForMaskedLM(DPLM2PreTrainedModel, EmbeddingMixin):
|
|
| 1874 |
store_all_hidden_states=store_all_hidden_states,
|
| 1875 |
)
|
| 1876 |
|
|
|
|
|
|
|
|
|
|
| 1877 |
def forward(
|
| 1878 |
self,
|
| 1879 |
input_ids: Optional[torch.Tensor] = None,
|
|
|
|
| 1819 |
)
|
| 1820 |
|
| 1821 |
|
| 1822 |
+
class DPLM2ForMaskedLM(FastPLMTestTimeTrainingMixin, DPLM2PreTrainedModel, EmbeddingMixin):
|
| 1823 |
config_class = DPLM2Config
|
| 1824 |
def __init__(self, config, dropout: float = 0.1, vocab_size: Optional[int] = None):
|
| 1825 |
config.hidden_dropout_prob = dropout
|
|
|
|
| 1835 |
self.tokenizer = self.__class__.tokenizer
|
| 1836 |
if isinstance(config._name_or_path, str) and len(config._name_or_path) > 0:
|
| 1837 |
self.tokenizer = EsmTokenizer.from_pretrained(config._name_or_path)
|
| 1838 |
+
self.init_ttt({"lora_target_replace_module": "ModifiedEsmAttention"})
|
| 1839 |
|
| 1840 |
def get_input_embeddings(self) -> nn.Module:
|
| 1841 |
return self.esm.get_input_embeddings()
|
|
|
|
| 1875 |
store_all_hidden_states=store_all_hidden_states,
|
| 1876 |
)
|
| 1877 |
|
| 1878 |
+
def _ttt_get_trainable_modules(self) -> list[nn.Module]:
|
| 1879 |
+
return [self.esm]
|
| 1880 |
+
|
| 1881 |
def forward(
|
| 1882 |
self,
|
| 1883 |
input_ids: Optional[torch.Tensor] = None,
|