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
add custom handler again
Browse files- handler.py +13 -0
handler.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Dict, List, Any
|
| 2 |
+
from InstructorEmbedding import INSTRUCTOR
|
| 3 |
+
|
| 4 |
+
class EndpointHandler():
|
| 5 |
+
def __init__(self, path=""):
|
| 6 |
+
self.model = INSTRUCTOR(path)
|
| 7 |
+
|
| 8 |
+
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 9 |
+
instruction = data.get("instruction", "")
|
| 10 |
+
document = data.get("document", "")
|
| 11 |
+
embedding = self.model.encode([[instruction, document]]).flatten()
|
| 12 |
+
|
| 13 |
+
return [{"embedding": embedding}]
|