markaw commited on
Commit
72d53c8
·
verified ·
1 Parent(s): 3abce5f

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +21 -21
handler.py CHANGED
@@ -1,22 +1,22 @@
1
- from typing import Dict, List, Any
2
- from sentence_transformers import SentenceTransformer
3
-
4
- class EndpointHandler():
5
- def __init__(self, path=""):
6
- # Preload all the elements you are going to need at inference.
7
- # pseudo:
8
- # self.model= load_model(path)
9
- self.embedding_model = SentenceTransformer(path,trust_remote_code=True,)
10
-
11
- def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
12
- """
13
- data args:
14
- inputs (:obj: `str` | `PIL.Image` | `np.array`)
15
- kwargs
16
- Return:
17
- A :obj:`list` | `dict`: will be serialized and returned
18
- """
19
- embeddings = self.embedding_model.encode(data)
20
- return embeddings
21
- # pseudo
22
  # self.model(input)
 
1
+ from typing import Dict, List, Any
2
+ from sentence_transformers import SentenceTransformer
3
+
4
+ class EndpointHandler():
5
+ def __init__(self, path="NV-Embed-v2"):
6
+ # Preload all the elements you are going to need at inference.
7
+ # pseudo:
8
+ # self.model= load_model(path)
9
+ self.embedding_model = SentenceTransformer(path)
10
+
11
+ def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
12
+ """
13
+ data args:
14
+ inputs (:obj: `str` | `PIL.Image` | `np.array`)
15
+ kwargs
16
+ Return:
17
+ A :obj:`list` | `dict`: will be serialized and returned
18
+ """
19
+ embeddings = self.embedding_model.encode(data)
20
+ return embeddings
21
+ # pseudo
22
  # self.model(input)