Update handler.py
Browse files- handler.py +10 -1
handler.py
CHANGED
@@ -37,14 +37,23 @@ class EndpointHandler():
|
|
37 |
Return:
|
38 |
A :obj:`list` | `dict`: will be serialized and returned
|
39 |
"""
|
|
|
40 |
sentences = data.pop("inputs",data)
|
|
|
41 |
sentence_embeddings = []
|
|
|
42 |
for sentence in sentences:
|
43 |
encoded_input = self.tokenizer(sentence, padding=True, truncation=True, return_tensors='pt')
|
|
|
|
|
44 |
# Compute token embeddings
|
45 |
with torch.no_grad():
|
46 |
-
model_output = self.onnx_extractor(**encoded_input)
|
|
|
|
|
47 |
# Perform pooling. In this case, max pooling.
|
48 |
embedding = mean_pooling(model_output, encoded_input['attention_mask'])
|
|
|
49 |
sentence_embeddings.append(embedding.tolist())
|
|
|
50 |
return sentence_embeddings
|
|
|
37 |
Return:
|
38 |
A :obj:`list` | `dict`: will be serialized and returned
|
39 |
"""
|
40 |
+
print("A")
|
41 |
sentences = data.pop("inputs",data)
|
42 |
+
print("B")
|
43 |
sentence_embeddings = []
|
44 |
+
print("C")
|
45 |
for sentence in sentences:
|
46 |
encoded_input = self.tokenizer(sentence, padding=True, truncation=True, return_tensors='pt')
|
47 |
+
print("D")
|
48 |
+
|
49 |
# Compute token embeddings
|
50 |
with torch.no_grad():
|
51 |
+
model_output = self.onnx_extractor(**encoded_input)
|
52 |
+
print("E")
|
53 |
+
|
54 |
# Perform pooling. In this case, max pooling.
|
55 |
embedding = mean_pooling(model_output, encoded_input['attention_mask'])
|
56 |
+
print("F")
|
57 |
sentence_embeddings.append(embedding.tolist())
|
58 |
+
print("G")
|
59 |
return sentence_embeddings
|