Sentence Similarity
sentence-transformers
PyTorch
Transformers
English
t5
text-embedding
embeddings
information-retrieval
beir
text-classification
language-model
text-clustering
text-semantic-similarity
text-evaluation
prompt-retrieval
text-reranking
feature-extraction
English
Sentence Similarity
natural_questions
ms_marco
fever
hotpot_qa
mteb
Eval Results
text-generation-inference
update handler
Browse files- 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 |
-
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
query = [['Retrieve documents that can help answer the question:',
|
| 23 |
-
inputs]]
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
-
return
|
|
|
|
| 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()
|