Using Huggingface Embeddings completely locally
Hi,I want to use JinaAI embeddings completely locally (jinaai/jina-embeddings-v2-base-de · Hugging Face) and downloaded all files to my machine (into folder jina_embeddings). However when I am now loading the embeddings, I am getting this message:image1184×230 20.8 KBI am loading the models like this:from langchain_community.embeddings import HuggingFaceEmbeddings

embeddings = HuggingFaceEmbeddings(model_name="jina_embeddings",
                                       model_kwargs={'device': 'mps'}, encode_kwargs={'device': 'mps'})So am I am doing something wrong here? I want to ensure that everything is working locally, without internet conntection if needed.
2024-01-27T17:34:41Z
Hi, if you pass only model name, the embedding will be loaded from remote repo. You must to pass model_name like local address path. Here is a example:Path to your local modellocal_model_path = “/Users/…/model_file”Instantiate HuggingFaceInstructEmbeddingshf = HuggingFaceInstructEmbeddings(model_name=local_model_path,model_kwargs=model_kwargs,encode_kwargs=encode_kwargs)
2024-01-27T17:39:38Z
Thanks, do you know how to pass the trust_remote_code=True parameter here? As for now I always get prompet to trust remote code.I am getting this error:ValidationError: 1 validation error for HuggingFaceInstructEmbeddings
trust_remote_code
  extra fields not permittedWith this code:from langchain_community.embeddings import HuggingFaceInstructEmbeddings

embeddings = HuggingFaceInstructEmbeddings(model_name="jinaembeddings",trust_remote_code=True,
                                       model_kwargs={'device': 'mps'}, encode_kwargs={'device': 'mps'})
2024-01-27T22:12:31Z
I think it isn’t possible at this moment. There are two opened issues at langchain github about it. But a guy found a work around for the problem by loading the embedding model via Transformers class.You can see here:Issue: HuggingFaceEmbeddings can not take trust_remote_code argument · Issue #6080 · langchain-ai/langchain · GitHubCheck comment of Nafay-0on Nov 9, 2023.
2024-01-28T16:16:25Z
gugaio:Issue: HuggingFaceEmbeddings can not take trust_remote_code argument · Issue#6080· langchain-ai/langchain · GitHubthanks the workaround works
2024-01-29T04:16:49Z
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.