ababeal commited on
Commit
4aadff9
·
1 Parent(s): b322e09

Update handler.py

Browse files

bug: fix an issue where the response returns dimensions of (1, 3, 1024) for a single string. This code was missing the edits made to the usage code on https://huggingface.co/intfloat/e5-large-v2

Files changed (1) hide show
  1. handler.py +3 -3
handler.py CHANGED
@@ -24,6 +24,6 @@ class EndpointHandler():
24
  outputs = self.model(**batch_dict)
25
 
26
  embeddings = average_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
27
- embeddings = F.normalize(embeddings, p=2, dim=1).tolist()
28
-
29
- return embeddings
 
24
  outputs = self.model(**batch_dict)
25
 
26
  embeddings = average_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
27
+ embeddings = F.normalize(embeddings, p=2, dim=1)
28
+ scores = (embeddings[:2] @ embeddings[2:].T) * 100
29
+ return embeddings.tolist()