Upload configuration_esm.py
Browse files- configuration_esm.py +51 -0
configuration_esm.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2024 MultiomicsLM Team. All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
"""MultiomicsLM ESM model configuration."""
|
| 16 |
+
|
| 17 |
+
from transformers.models.esm.configuration_esm import EsmConfig
|
| 18 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 19 |
+
|
| 20 |
+
from typing import Optional
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class MMEsmConfig(EsmConfig):
|
| 24 |
+
"""
|
| 25 |
+
Configuration class for MultiomicsLM ESM model.
|
| 26 |
+
|
| 27 |
+
This configuration extends the base ESM configuration with multiomics-specific parameters.
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
model_type = "esm"
|
| 31 |
+
num_labels = 2
|
| 32 |
+
def __init__(
|
| 33 |
+
self,
|
| 34 |
+
structure: Optional[dict] = None,
|
| 35 |
+
**kwargs
|
| 36 |
+
):
|
| 37 |
+
super().__init__(**kwargs)
|
| 38 |
+
default_structure = {
|
| 39 |
+
"width": 512,
|
| 40 |
+
"projector": "mlp3x_gelu",
|
| 41 |
+
"output_dim": self.hidden_size if hasattr(self, "hidden_size") else 640,
|
| 42 |
+
"projector_norm": True,
|
| 43 |
+
"embedding_keys": ["esm_if_emb"],
|
| 44 |
+
}
|
| 45 |
+
if structure is None:
|
| 46 |
+
self.structure = default_structure
|
| 47 |
+
else:
|
| 48 |
+
cfg = dict(default_structure)
|
| 49 |
+
cfg.update(structure)
|
| 50 |
+
self.structure = cfg
|
| 51 |
+
|