Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError for while using Instruct Embeddings on HuggingFace

Tags:

langchain

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

like image 879
Ivy Kutswa Avatar asked Jul 29 '26 08:07

Ivy Kutswa


2 Answers

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
like image 98
Jin Hoe Lian Avatar answered Jul 30 '26 23:07

Jin Hoe Lian


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

like image 40
Chetan Avatar answered Jul 30 '26 21:07

Chetan