Sentence Similarity
sentence-transformers
Safetensors
Transformers
new
feature-extraction
mteb
multilingual
text-embeddings-inference
custom_code
Eval Results (legacy)
Instructions to use Alibaba-NLP/gte-multilingual-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Alibaba-NLP/gte-multilingual-base with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True) sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Transformers
How to use Alibaba-NLP/gte-multilingual-base with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Alibaba-NLP/gte-multilingual-base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Fix the dense embedding dimension slice
#32
by CyberNativeAI - opened
README.md
CHANGED
|
@@ -4684,7 +4684,7 @@ batch_dict = tokenizer(input_texts, max_length=8192, padding=True, truncation=Tr
|
|
| 4684 |
outputs = model(**batch_dict)
|
| 4685 |
|
| 4686 |
dimension=768 # The output dimension of the output embedding, should be in [128, 768]
|
| 4687 |
-
embeddings = outputs.last_hidden_state[:, 0
|
| 4688 |
|
| 4689 |
embeddings = F.normalize(embeddings, p=2, dim=1)
|
| 4690 |
scores = (embeddings[:1] @ embeddings[1:].T) * 100
|
|
|
|
| 4684 |
outputs = model(**batch_dict)
|
| 4685 |
|
| 4686 |
dimension=768 # The output dimension of the output embedding, should be in [128, 768]
|
| 4687 |
+
embeddings = outputs.last_hidden_state[:, 0, :dimension]
|
| 4688 |
|
| 4689 |
embeddings = F.normalize(embeddings, p=2, dim=1)
|
| 4690 |
scores = (embeddings[:1] @ embeddings[1:].T) * 100
|