Sentence Similarity
sentence-transformers
PyTorch
Safetensors
Transformers
new
feature-extraction
mteb
custom_code
Eval Results (legacy)
text-embeddings-inference
Instructions to use NovaSearch/stella_en_400M_v5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use NovaSearch/stella_en_400M_v5 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("NovaSearch/stella_en_400M_v5", trust_remote_code=True) 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] - Transformers
How to use NovaSearch/stella_en_400M_v5 with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("NovaSearch/stella_en_400M_v5", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Error in running the model in CPU
#17
by Navanit-AI - opened
while running the same code below for bge-large-en-v1.55 and gte-large-en-v1.5. I didn't faced any error. But for this model I am facing the error
from sentence_transformers import SentenceTransformer
from sentence_transformers.util import cos_sim
from tqdm.autonotebook import tqdm, trange
import torch
device = torch.device("cpu")
sentences = ['That is a happy person', 'That is a very happy person']
model = SentenceTransformer('dunzhang/stella_en_400M_v5',
trust_remote_code=True,
device ="cpu"
)
embeddings = model.encode(sentences)
print(cos_sim(embeddings[0], embeddings[1]))
The error is
"name": "ValueError",
"message": "Attention bias and Query/Key/Value should be on the same device
query.device: cpu
attn_bias : cuda:0
@infgrad Kindly help please.
Did you find a solution?
in config.json change both to false:
"unpad_inputs": true,
"use_memory_efficient_attention": true,
and then you also do not need xformers package.
It then runs on CPU