kblevins commited on
Commit
46ee5d9
1 Parent(s): 6c69c8a

update handler

Browse files
Files changed (1) hide show
  1. handler.py +8 -7
handler.py CHANGED
@@ -16,13 +16,14 @@ class EndpointHandler:
16
  # get inputs
17
  inputs: dict = data.pop("inputs", data)
18
 
19
- print(inputs)
 
 
20
 
21
- # add instruction
22
- query = [['Retrieve documents that can help answer the question:',
23
- inputs]]
24
 
25
- # encode
26
- embedding = self.model.encode(query)
 
27
 
28
- return embedding
 
16
  # get inputs
17
  inputs: dict = data.pop("inputs", data)
18
 
19
+ # make sure texts is a list
20
+ if not isinstance(inputs, list):
21
+ inputs = [inputs]
22
 
23
+ instruction = 'Retrieve documents that can help answer the question:'
 
 
24
 
25
+ instructions = [[instruction, text] for text in inputs]
26
+
27
+ embeddings = self.model.encode(instructions)
28
 
29
+ return embeddings.tolist()