Direct replacement for SentenceTransformer implemented using DeepSparse and optimum-deepsparse
Performance optimizations with bucketing/batching will come in future work
Smoke Test:
pip install -e ".[sentence_transformers]"
# from sentence_transformers import SentenceTransformer
from deepsparse.sentence_transformers import SentenceTransformer
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2", export=True)
# Sentences we'd like to encode
sentences = ['This framework generates embeddings for each input sentence',
'Sentences are passed as a list of string.',
'The quick brown fox jumps over the lazy dog.']
# Sentences are encoded by calling model.encode()
embeddings = model.encode(sentences)
# Print the embeddings
for sentence, embedding in zip(sentences, embeddings):
print("Sentence:", sentence)
print("Embedding:", embedding.shape)
print("")
### Sentence: This framework generates embeddings for each input sentence
### Embedding: (384,)
###
### Sentence: Sentences are passed as a list of string.
### Embedding: (384,)
###
### Sentence: The quick brown fox jumps over the lazy dog.
### Embedding: (384,)
Direct replacement for SentenceTransformer implemented using DeepSparse and optimum-deepsparse
Performance optimizations with bucketing/batching will come in future work
Smoke Test:
Full test through evaluation with MTEB
Output: