TypeError for while using Instruct Embeddings on HuggingFace
Asked Answered
B

2

6

My code below causes the error TypeError: _load_sbert_model() got an unexpected keyword argument 'token' while I try to run it. This is the same code in the documentation for Langchain Instruct Embeddings but I can't seem to get it right.

from langchain_community.embeddings import HuggingFaceInstructEmbeddings, HuggingFaceEmbeddings from langchain.embeddings import HuggingFaceInstructEmbeddings from InstructorEmbedding import INSTRUCTOR from langchain.vectorstores import FAISS

embeddings = HuggingFaceInstructEmbeddings()

TypeError: _load_sbert_model() got an unexpected keyword argument 'token'

I have tried using other text similarity models like sentence-transformers/all-MiniLM-L6-v2 but when I try to run the line FAISS.from_documents(documents=data, embedding=instructor_embeddings) it causes an attribute error

Bores answered 30/1 at 4:35 Comment(1)
I have the exact same issue, python v 3.9, langchain community v 0.0.16 (importing from langchain.embeddings or langchain_community.embeddings does not make any difference).Kristeenkristel
W
5

The following commands fixed the issue, I do not need to change langchain version.

pip uninstall sentence-transformers
pip install sentence-transformers==2.2.2
Windowlight answered 31/1 at 5:58 Comment(1)
I was running the code in a Jupyter notebook and had to restart the notebook for the change to help.Amnesty
C
3

Due to recent changes in sentence transformer package this issue is coming up. Try using the below version.

!pip install langchain==0.1.2 sentence_transformers==2.2.2

Creator answered 30/1 at 16:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.