Feature Extraction
Transformers
Safetensors
fast_esm3
biology
protein-language-model
esm3
multimodal-protein-model
custom_code
Instructions to use Synthyra/ESM3_small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Synthyra/ESM3_small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="Synthyra/ESM3_small", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Synthyra/ESM3_small", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Upload modeling_esm3.py with huggingface_hub
Browse files- modeling_esm3.py +10 -1
modeling_esm3.py
CHANGED
|
@@ -41,6 +41,11 @@ except ImportError:
|
|
| 41 |
create_block_mask = None
|
| 42 |
flex_attention = None
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
ESM3_OPEN_SMALL = "esm3_sm_open_v1"
|
| 46 |
ESM3_OPEN_SMALL_ALIASES = {
|
|
@@ -1462,7 +1467,7 @@ class FastESM3PreTrainedModel(PreTrainedModel):
|
|
| 1462 |
return model
|
| 1463 |
|
| 1464 |
|
| 1465 |
-
class FastESM3Model(FastESM3PreTrainedModel):
|
| 1466 |
config_class = FastESM3Config
|
| 1467 |
|
| 1468 |
def __init__(self, config: FastESM3Config, **kwargs):
|
|
@@ -1470,6 +1475,7 @@ class FastESM3Model(FastESM3PreTrainedModel):
|
|
| 1470 |
self.tokenizer = EsmSequenceTokenizer()
|
| 1471 |
self.esm3 = _build_official_esm3(config)
|
| 1472 |
self.__dict__["_official_sdk_model"] = None
|
|
|
|
| 1473 |
|
| 1474 |
@property
|
| 1475 |
def device(self) -> torch.device:
|
|
@@ -1693,6 +1699,9 @@ class FastESM3Model(FastESM3PreTrainedModel):
|
|
| 1693 |
def batch_generate(self, inputs, configs):
|
| 1694 |
return self._get_official_sdk_model().batch_generate(inputs, configs)
|
| 1695 |
|
|
|
|
|
|
|
|
|
|
| 1696 |
def forward_and_sample(self, input, sampling_configuration):
|
| 1697 |
return self._get_official_sdk_model().forward_and_sample(
|
| 1698 |
input,
|
|
|
|
| 41 |
create_block_mask = None
|
| 42 |
flex_attention = None
|
| 43 |
|
| 44 |
+
try:
|
| 45 |
+
from fastplms.test_time_training import FastPLMTestTimeTrainingMixin
|
| 46 |
+
except ImportError:
|
| 47 |
+
pass # Running as HF Hub composite; shared definitions are above
|
| 48 |
+
|
| 49 |
|
| 50 |
ESM3_OPEN_SMALL = "esm3_sm_open_v1"
|
| 51 |
ESM3_OPEN_SMALL_ALIASES = {
|
|
|
|
| 1467 |
return model
|
| 1468 |
|
| 1469 |
|
| 1470 |
+
class FastESM3Model(FastPLMTestTimeTrainingMixin, FastESM3PreTrainedModel):
|
| 1471 |
config_class = FastESM3Config
|
| 1472 |
|
| 1473 |
def __init__(self, config: FastESM3Config, **kwargs):
|
|
|
|
| 1475 |
self.tokenizer = EsmSequenceTokenizer()
|
| 1476 |
self.esm3 = _build_official_esm3(config)
|
| 1477 |
self.__dict__["_official_sdk_model"] = None
|
| 1478 |
+
self.init_ttt({"lora_target_replace_module": "MultiHeadAttention"})
|
| 1479 |
|
| 1480 |
@property
|
| 1481 |
def device(self) -> torch.device:
|
|
|
|
| 1699 |
def batch_generate(self, inputs, configs):
|
| 1700 |
return self._get_official_sdk_model().batch_generate(inputs, configs)
|
| 1701 |
|
| 1702 |
+
def _ttt_get_trainable_modules(self) -> list[nn.Module]:
|
| 1703 |
+
return [self.esm3]
|
| 1704 |
+
|
| 1705 |
def forward_and_sample(self, input, sampling_configuration):
|
| 1706 |
return self._get_official_sdk_model().forward_and_sample(
|
| 1707 |
input,
|