langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
95.67k stars 15.53k forks source link

ImportError: Dependencies for InstructorEmbedding not found. #27767

Open PabloVD opened 1 month ago

PabloVD commented 1 month ago

Checked other resources

Example Code


from langchain_community.embeddings import HuggingFaceInstructEmbeddings

DEVICE = "cpu"

#Initialize embeddings using a pre-trained model to represent the text data.
embedddings_model = "sentence-transformers/multi-qa-distilbert-cos-v1"

embeddings = HuggingFaceInstructEmbeddings(
    model_name=embedddings_model,
    model_kwargs={"device": DEVICE}
)

Error Message and Stack Trace (if applicable)

USER_AGENT environment variable not set, consider setting it to identify your requests.
Traceback (most recent call last):
  File "/home/tda/miniconda3/envs/ragbot2/lib/python3.10/site-packages/langchain_community/embeddings/huggingface.py", line 188, in __init__
    from InstructorEmbedding import INSTRUCTOR
ModuleNotFoundError: No module named 'InstructorEmbedding'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/tda/GenAICourse/RAG/ragbot_langchain/app.py", line 38, in <module>
    embeddings = HuggingFaceInstructEmbeddings(
  File "/home/tda/miniconda3/envs/ragbot2/lib/python3.10/site-packages/langchain_community/embeddings/huggingface.py", line 194, in __init__
    raise ImportError("Dependencies for InstructorEmbedding not found.") from e
ImportError: Dependencies for InstructorEmbedding not found.

Description

I'm trying to build embeddings for a RAG application and I get the error ImportError: Dependencies for InstructorEmbedding not found.

System Info

System Information

OS: Linux OS Version: #134~20.04.1-Ubuntu SMP Tue Oct 1 15:27:33 UTC 2024 Python Version: 3.10.0 (default, Mar 3 2022, 09:58:08) [GCC 7.5.0]

Package Information

langchain_core: 0.3.14 langchain: 0.3.5 langchain_community: 0.3.3 langsmith: 0.1.138 langchain_chroma: 0.1.4 langchain_mistralai: 0.2.0 langchain_openai: 0.2.4 langchain_text_splitters: 0.3.1

Optional packages not installed

langgraph langserve

Other Dependencies

aiohttp: 3.10.10 async-timeout: 4.0.3 chromadb: 0.5.16 dataclasses-json: 0.6.7 fastapi: 0.115.4 httpx: 0.27.2 httpx-sse: 0.4.0 jsonpatch: 1.33 numpy: 1.26.4 openai: 1.53.0 orjson: 3.10.10 packaging: 24.1 pydantic: 2.9.2 pydantic-settings: 2.6.0 PyYAML: 6.0.2 requests: 2.32.3 requests-toolbelt: 1.0.0 SQLAlchemy: 2.0.36 tenacity: 9.0.0 tiktoken: 0.8.0 tokenizers: 0.20.1 typing-extensions: 4.12.2

siddarthreddygsr commented 4 weeks ago

https://pypi.org/project/InstructorEmbedding/