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

INSTRUCTOR._load_sbert_model() got an unexpected keyword argument 'token' #722

Closed
phoenixvictory opened this issue Jan 29, 2024 · 9 comments

Comments

@phoenixvictory
Copy link

Hey All,

Following the installation instructions of Windows 10. The installation of all dependencies went smoothly. I have tried several different models but the problem I am seeing appears to be the somewhere in the instructor. I am using ingest.py with a device type cpu using the pre-existing source pdf. Unfortunately I am met with this error constantly, any ideas what this may be?

2024-01-29 16:30:49,880 - INFO - SentenceTransformer.py:110 - Load pretrained SentenceTransformer: hkunlp/instructor-large
Traceback (most recent call last):
File "C:\Users\Phx\Documents\GitHub\Localgpt\ingest.py", line 181, in
main()
File "C:\Users\Phx.conda\envs\localGPT\lib\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
File "C:\Users\Phx.conda\envs\localGPT\lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
File "C:\Users\Phx.conda\envs\localGPT\lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\Phx.conda\envs\localGPT\lib\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "C:\Users\Phx\Documents\GitHub\Localgpt\ingest.py", line 157, in main
embeddings = HuggingFaceInstructEmbeddings(
File "C:\Users\Phx.conda\envs\localGPT\lib\site-packages\langchain\embeddings\huggingface.py", line 148, in init
self.client = INSTRUCTOR(
File "C:\Users\Phx.conda\envs\localGPT\lib\site-packages\sentence_transformers\SentenceTransformer.py", line 194, in init
modules = self._load_sbert_model(
TypeError: INSTRUCTOR._load_sbert_model() got an unexpected keyword argument 'token'

@ujwpi
Copy link
Contributor

ujwpi commented Jan 30, 2024

Specify v2.2.2 for Sentence Transformers in your requirements.txt, the latest version for it (v2.3.0) was released on 29th Jan and there seems to be a breaking change.

@phoenixvictory
Copy link
Author

That certainly did the trick! Thank you for taking the time to provide clarity on this one!

@g1ra
Copy link

g1ra commented Jan 30, 2024

I have a same error here , and did trick setting in requirements.txt :

sentence-transformers==2.2.2

@ujwpi
Copy link
Contributor

ujwpi commented Jan 30, 2024

PR raised for this issue, waiting for it to be reviewed.
@phoenixvictory can we keep this issue open till its been fixed.

@Phycotron
Copy link

Phycotron commented Mar 5, 2024

I have the same error here :
TypeError: INSTRUCTOR._load_sbert_model() got an unexpected keyword argument 'token'

@janas-adam
Copy link

had similar issue in latest version 2.6.0, like mentioned above: with 2.2.2 works well

line 191, in __init__
    modules = self._load_sbert_model(
TypeError: INSTRUCTOR._load_sbert_model() got an unexpected keyword argument 'token'

@qsdhj
Copy link

qsdhj commented May 6, 2024

I also get this error:
TypeError: INSTRUCTOR._load_sbert_model() got an unexpected keyword argument 'token'

My code is from the langchain doc:

from langchain.embeddings import HuggingFaceInstructEmbeddings

model_name = "hkunlp/instructor-large"
model_kwargs = {'device': 'cpu'}
encode_kwargs = {'normalize_embeddings': True}
hf = HuggingFaceInstructEmbeddings(
    model_name=model_name,
    model_kwargs=model_kwargs,
    encode_kwargs=encode_kwargs
)

sentence-transformers 2.7.0

@NebeyouMusie
Copy link

run pip install sentence-transformers==2.2.2 then restart your kernel. It worked for me.

@EZZAH
Copy link

EZZAH commented Jun 7, 2024

  1. Install pip install sentence-transformers==2.2.2
  2. restart your kernel.
  3. Wait for few second
  4. Rerun

from langchain_community.embeddings import HuggingFaceInstructEmbeddings
from InstructorEmbedding import INSTRUCTOR
instructembeddings= HuggingFaceInstructEmbeddings(model_name = "hkunlp/instructor-xl",
model_kwargs = {'device': 'cpu'}, encode_kwargs = {'normalize_embeddings': True})

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

No branches or pull requests

8 participants