Upload 2 files
Browse files- nextus_regressor.pt +3 -0
- nextus_regressor_class.py +23 -0
nextus_regressor.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b37302fa29dadfe2628c43ccabedc0c5c81dc068852a401cb57166cce1e92ff0
|
3 |
+
size 457056444
|
nextus_regressor_class.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from torch import nn
|
3 |
+
from sentence_transformers import SentenceTransformer
|
4 |
+
from regressor import *
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
|
8 |
+
class NextUsRegressor(nn.Module):
|
9 |
+
def __init__(self):
|
10 |
+
super(NextUsRegressor, self).__init__()
|
11 |
+
self.embedder = SentenceTransformer(ENCODER)
|
12 |
+
|
13 |
+
|
14 |
+
self.regressor = WRegressor()
|
15 |
+
|
16 |
+
return
|
17 |
+
|
18 |
+
def forward(self, txts):
|
19 |
+
# expects a list of strings
|
20 |
+
embedded = self.embedder.encode(np.array(txts))
|
21 |
+
embedded_tensor = torch.tensor(embedded, dtype=torch.float32)
|
22 |
+
return self.regressor(embedded_tensor)
|
23 |
+
|