Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve compatibility issues with sentence-transformers 3.3.1 #127

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

merthmagic
Copy link

I encountered an issue when I loading the model, error message as follow:

TypeError: INSTRUCTOR._load_sbert_model() got an unexpected keyword argument 'local_files_only'

I checked the sentence-transformers version ,that is 3.3.1. The root cause might be newer version sentence-transformers has updated the signature of method _load_sbert_model() so we lack some parameter now.

My resolution contains an update of _load_sbert_model method in class INSTRUCTOR and it works fine locally.

@NoahBPeterson
Copy link

Doesn't work for me on sentence-transformers 3.3.1.

Traceback (most recent call last):
  File "/Users/noahpeterson/iembed/./run.py", line 7, in <module>
    model = INSTRUCTOR('hkunlp/instructor-large')
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahpeterson/iembed/venv/lib/python3.12/site-packages/sentence_transformers/SentenceTransformer.py", line 308, in __init__
    modules, self.module_kwargs = self._load_sbert_model(
                                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahpeterson/iembed/venv/lib/python3.12/site-packages/InstructorEmbedding/instructor.py", line 571, in _load_sbert_model
    with open(modules_json_path, encoding="UTF-8") as config_file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'hkunlp/instructor-large/modules.json'

@merthmagic
Copy link
Author

Doesn't work for me on sentence-transformers 3.3.1.

Traceback (most recent call last):
  File "/Users/noahpeterson/iembed/./run.py", line 7, in <module>
    model = INSTRUCTOR('hkunlp/instructor-large')
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahpeterson/iembed/venv/lib/python3.12/site-packages/sentence_transformers/SentenceTransformer.py", line 308, in __init__
    modules, self.module_kwargs = self._load_sbert_model(
                                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/noahpeterson/iembed/venv/lib/python3.12/site-packages/InstructorEmbedding/instructor.py", line 571, in _load_sbert_model
    with open(modules_json_path, encoding="UTF-8") as config_file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'hkunlp/instructor-large/modules.json'

have you tried to download the model's pretrained checkpoint and load it locally?

@NoahBPeterson
Copy link

Not with this PR, but I did with mine that adds support for 3.3.1 and also downloads the model from hugging face if it isn't already downloaded: #128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants