shhossain commited on
Commit
0f7cc62
1 Parent(s): 4f84af9

Upload config

Browse files
Files changed (2) hide show
  1. config.json +1 -6
  2. model.py +14 -1
config.json CHANGED
@@ -1,10 +1,6 @@
1
  {
2
- "architectures": [
3
- "SententenceTransformerSentimentModel"
4
- ],
5
  "auto_map": {
6
- "AutoConfig": "config.SentimentConfig",
7
- "AutoModelForSequenceClassification": "model.SententenceTransformerSentimentModel"
8
  },
9
  "class_map": {
10
  "0": "sad",
@@ -18,6 +14,5 @@
18
  "h1": 44,
19
  "h2": 46,
20
  "model_type": "SententenceTransformerSentimentClassifier",
21
- "torch_dtype": "float32",
22
  "transformers_version": "4.29.0"
23
  }
 
1
  {
 
 
 
2
  "auto_map": {
3
+ "AutoConfig": "model.SentimentConfig"
 
4
  },
5
  "class_map": {
6
  "0": "sad",
 
14
  "h1": 44,
15
  "h2": 46,
16
  "model_type": "SententenceTransformerSentimentClassifier",
 
17
  "transformers_version": "4.29.0"
18
  }
model.py CHANGED
@@ -1,9 +1,22 @@
1
- from config import SentimentConfig
2
  from transformers import PreTrainedModel
3
  import torch.nn as nn
4
  import torch.nn.functional as F
 
5
 
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  class SententenceTransformerSentimentModel(PreTrainedModel):
8
  config_class = SentimentConfig
9
 
 
 
1
  from transformers import PreTrainedModel
2
  import torch.nn as nn
3
  import torch.nn.functional as F
4
+ from transformers import PretrainedConfig
5
 
6
 
7
+ mp = {0:'sad',1:'joy',2:'love',3:'anger',4:'fear',5:'surprise'}
8
+
9
+ class SentimentConfig(PretrainedConfig):
10
+ model_type = "SententenceTransformerSentimentClassifier"
11
+
12
+ def __init__(self, embedding_model: str="sentence-transformers/all-MiniLM-L6-v2", class_map: dict=mp, h1: int=44, h2: int=46, **kwargs):
13
+ self.embedding_model = embedding_model
14
+ self.class_map = class_map
15
+ self.h1 = h1
16
+ self.h2 = h2
17
+
18
+ super().__init__(**kwargs)
19
+
20
  class SententenceTransformerSentimentModel(PreTrainedModel):
21
  config_class = SentimentConfig
22