Describe the bug
I'm trying to replicate the sample code given in the DeepSparseSentenceTransformer documentation. I'm facing errors while executing it. It is mostly related to the version compatibility of the modules , however I'm stuck trying to find what exactly the issue is , can you please help with this?
Expected behavior
To load models DeepSparseSentenceTransformer without any errors
Environment
Include all relevant environment information:
OS [e.g. Ubuntu 18.04]: Linux-5.10.215-203.850.amzn2.x86_64-x86_64-with-glibc2.26
Python version [e.g. 3.8]: 3.10.14
DeepSparse version or commit hash [e.g. 0.1.0, f7245c8]: deepsparse-1.7.1
ML framework version(s) [e.g. torch 1.7.1]: torch-2.1.0
To Reproduce
Exact steps to reproduce the behavior:
!pip install deepsparse[sentence_transformers]
!pip install tf-keras
(prompted by deepsparse to install this)
from deepsparse.sentence_transformers import DeepSparseSentenceTransformer
model = DeepSparseSentenceTransformer('neuralmagic/bge-small-en-v1.5-quant', export=False)
Our sentences we 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()
import time
st = time.time()
embeddings = model.encode(sentences)
ed = time.time()
print("time taken is : ",ed-st)
Print the embeddings
for sentence, embedding in zip(sentences, embeddings):
print("Sentence:", sentence)
print("Embedding:", embedding.shape)
print("")
**Errors**
RuntimeError: Failed to import optimum.deepsparse.modeling because of the following error (look up to see its traceback):
Failed to import optimum.exporters.onnx.__main__ because of the following error (look up to see its traceback):
cannot import name 'is_torch_less_than_1_11' from 'transformers.pytorch_utils' (/home/ec2-user/anaconda3/envs/pytorch_p310/lib/python3.10/site-packages/transformers/pytorch_utils.py)
**Additional context**
Add any other context about the problem here. Also include any relevant files.
Describe the bug I'm trying to replicate the sample code given in the DeepSparseSentenceTransformer documentation. I'm facing errors while executing it. It is mostly related to the version compatibility of the modules , however I'm stuck trying to find what exactly the issue is , can you please help with this? Expected behavior To load models DeepSparseSentenceTransformer without any errors Environment Include all relevant environment information:
f7245c8
]: deepsparse-1.7.1To Reproduce Exact steps to reproduce the behavior: !pip install deepsparse[sentence_transformers] !pip install tf-keras (prompted by deepsparse to install this)
Our sentences we 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()
import time st = time.time() embeddings = model.encode(sentences) ed = time.time() print("time taken is : ",ed-st)
Print the embeddings
for sentence, embedding in zip(sentences, embeddings): print("Sentence:", sentence) print("Embedding:", embedding.shape) print("")