Facing error
while running this code: from InstructorEmbedding import INSTRUCTOR
Load the model
model = INSTRUCTOR()
model_path = "./instructor-xl" # Update this with the correct path
model.load(model_path)
Encode sentences
sentence = "3D ActionSLAM: wearable person tracking in multi-floor environments the science title is NASA"
instruction = "Represent the Science title:"
embeddings = model.encode([instruction, sentence])
Now you can use the embeddings
print(embeddings)
facing this error: PS C:\Users\tgt587\Desktop\langchain> python app.py
C:\Users\tgt587\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch_utils.py:831: UserWarning: TypedStorage is deprecated. It will be removed in the future and UntypedStorage will be the only storage class. This should only matter to you if you are using storages directly. To access UntypedStorage directly, use tensor.untyped_storage() instead of tensor.storage()
return self.fget.get(instance, owner)()
Instructor models require include_prompt=False
in the pooling configuration. Either update the model configuration or call model.set_pooling_include_prompt(False)
after loading the model.SentenceTransformer._target_device
has been removed, please use SentenceTransformer.device
instead.
Traceback (most recent call last):
File "C:\Users\tgt587\AppData\Local\Programs\Python\Python311\Lib\site-packages\sentence_transformers\SentenceTransformer.py", line 1215, in device
return next(self.parameters()).device
^^^^^^^^^^^^^^^^^^^^^^^
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\tgt587\Desktop\langchain\app.py", line 56, in
embeddings = model.encode([instruction, sentence])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tgt587\AppData\Local\Programs\Python\Python311\Lib\site-packages\InstructorEmbedding\instructor.py", line 519, in encode
device = self._target_device
^^^^^^^^^^^^^^^^^^^
File "C:\Users\tgt587\AppData\Local\Programs\Python\Python311\Lib\site-packages\sentence_transformers\SentenceTransformer.py", line 1260, in _target_device
return self.device
^^^^^^^^^^^
File "C:\Users\tgt587\AppData\Local\Programs\Python\Python311\Lib\site-packages\sentence_transformers\SentenceTransformer.py", line 1224, in device
first_tuple = next(gen)
^^^^^^^^^
StopIteration