Sentence Similarity
sentence-transformers
PyTorch
ONNX
Safetensors
OpenVINO
English
bert
mteb
Sentence Transformers
Eval Results (legacy)
text-embeddings-inference
Instructions to use intfloat/e5-large-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use intfloat/e5-large-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("intfloat/e5-large-v2") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Inference
- Notebooks
- Google Colab
- Kaggle
Update handler.py
Browse filesbug: 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
- 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)
|
| 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()
|