offline mode

#18
by andreariboni - opened
This comment has been hidden

Hello, I want to use offline mode.
I have downloads files into '/home/data/sentence-transformers/all-mpnet-base-v2', I tried codes like this:
hf = HuggingFaceEmbeddings(cache_folder='/home/data/sentence-transformers/all-mpnet-base-v2') and
hf = HuggingFaceEmbeddings(model_name='sentence-transformers/all-mpnet-base-v2', cache_folder='/home/data')

then these two lines codes raise same error:

Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'. ```

After that, I tried:  
```hf = HuggingFaceEmbeddings('/home/data/sentence-transformers/all-mpnet-base-v2') ```, 

then raise error:
``` HuggingFaceEmbeddings.__init__() takes 1 positional argument but 2 were given``` 

Then I tried codes: 
```hf = HuggingFaceEmbeddings(model_name='/home/data/sentence-transformers/all-mpnet-base-v2') ``` 

then raise error: ```Repo id must be in the form 'repo_name' or 'namespace/repo_name': '/home/data/sentence-transformers/all-mpnet-base-v2'. Use `repo_type` argument if needed.```

How can I load model from my local directory `/home/data/sentence-transformers/all-mpnet-base-v2`? 

i meet the same error. Have you solved it?

Sentence Transformers org

Hello!

Apologies, I missed this until now. You should be able to do:

embeddings = HuggingFaceEmbeddings('/home/data/sentence-transformers/all-mpnet-base-v2')

I.e., you can use the path to the directory with your local model.

  • Tom Aarsen

Hello!

Apologies, I missed this until now. You should be able to do:

embeddings = HuggingFaceEmbeddings('/home/data/sentence-transformers/all-mpnet-base-v2')

I.e., you can use the path to the directory with your local model.

  • Tom Aarsen

thanks , when i fixed my code as your instructions ,

image.png

i meet the error as following

image.png
is there any other suggestions?

Sentence Transformers org

Ahh, I see the API is slightly different than I thought. This should work:

embeddings = HuggingFaceEmbeddings(model_name='/home/data/sentence-transformers/all-mpnet-base-v2')

Sign up or log in to comment