Update app.py
Browse files
app.py
CHANGED
@@ -4,15 +4,13 @@ from transformers import AutoTokenizer, AutoModel, pipeline
|
|
4 |
from torch import nn
|
5 |
|
6 |
st.markdown("### Articles classificator.")
|
7 |
-
# st.markdown("<img width=200px src='https://rozetked.me/images/uploads/dwoilp3BVjlE.jpg'>", unsafe_allow_html=True)
|
8 |
|
9 |
@st.cache(allow_output_mutation=True)
|
10 |
-
def
|
11 |
-
model_name = '
|
12 |
-
# return AutoModel.from_pretrained(model_name), AutoTokenizer.from_pretrained(model_name)
|
13 |
return AutoTokenizer.from_pretrained(model_name)
|
14 |
|
15 |
-
tokenizer =
|
16 |
|
17 |
class devops_model(nn.Module):
|
18 |
def __init__(self):
|
@@ -28,12 +26,12 @@ class devops_model(nn.Module):
|
|
28 |
)
|
29 |
|
30 |
def forward(self, train_batch):
|
31 |
-
emb = self.bert(**train_batch)['
|
32 |
return self.fc(emb)
|
33 |
|
34 |
@st.cache
|
35 |
def LoadModel():
|
36 |
-
return torch.load('
|
37 |
|
38 |
model = LoadModel()
|
39 |
|
|
|
4 |
from torch import nn
|
5 |
|
6 |
st.markdown("### Articles classificator.")
|
|
|
7 |
|
8 |
@st.cache(allow_output_mutation=True)
|
9 |
+
def get_tokenizer():
|
10 |
+
model_name = 'microsoft/deberta-v3-small'
|
|
|
11 |
return AutoTokenizer.from_pretrained(model_name)
|
12 |
|
13 |
+
tokenizer = get_tokenizer()
|
14 |
|
15 |
class devops_model(nn.Module):
|
16 |
def __init__(self):
|
|
|
26 |
)
|
27 |
|
28 |
def forward(self, train_batch):
|
29 |
+
emb = self.bert(**train_batch)['last_hidden_state'].mean(axis=1)
|
30 |
return self.fc(emb)
|
31 |
|
32 |
@st.cache
|
33 |
def LoadModel():
|
34 |
+
return torch.load('model_full.pt', map_location=torch.device('cpu'))
|
35 |
|
36 |
model = LoadModel()
|
37 |
|