Jiqing commited on
Commit
d9b4e66
1 Parent(s): f5b6331

Create configuration_protst.py

Browse files
Files changed (1) hide show
  1. configuration_protst.py +42 -0
configuration_protst.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PretrainedConfig
2
+ from transformers.utils import logging
3
+ from transformers.models.esm import EsmConfig
4
+
5
+ logger = logging.get_logger(__name__)
6
+
7
+
8
+ class ProtSTConfig(PretrainedConfig):
9
+ r"""
10
+ This is the configuration class to store the configuration of a [`ProtSTModel`].
11
+ Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
12
+ documentation from [`PretrainedConfig`] for more information.
13
+ Args:
14
+ protein_config (`dict`, *optional*):
15
+ Dictionary of configuration options used to initialize [`EsmForProteinRepresentation`].
16
+ ```"""
17
+
18
+ model_type = "protst"
19
+
20
+ def __init__(
21
+ self,
22
+ protein_config=None,
23
+ **kwargs,
24
+ ):
25
+ super().__init__(**kwargs)
26
+
27
+ if protein_config is None:
28
+ protein_config = {}
29
+ logger.info("`protein_config` is `None`. Initializing the `ProtSTProteinConfig` with default values.")
30
+
31
+ self.protein_config = EsmConfig(**protein_config)
32
+
33
+ @classmethod
34
+ def from_protein_text_configs(
35
+ cls, protein_config: EsmConfig, **kwargs
36
+ ):
37
+ r"""
38
+ Instantiate a [`ProtSTConfig`] (or a derived class) from ProtST text model configuration. Returns:
39
+ [`ProtSTConfig`]: An instance of a configuration object
40
+ """
41
+
42
+ return cls(protein_config=protein_config.to_dict(), **kwargs)