UKPLab / sentence-transformers

State-of-the-Art Text Embeddings
https://www.sbert.net
Apache License 2.0
15.47k stars 2.5k forks source link

How do I load the local model? #1666

Open Chucy2020 opened 2 years ago

Chucy2020 commented 2 years ago

hello, I want to know I used this code, where did the model loaded? and How do I use SentenceTransformer to load local models?

from sentence_transformers import SentenceTransformer encoder = SentenceTransformer("sentence-transformers/all-mpnet-base-v2")

thank you!

uahmad235 commented 2 years ago

Hi @Chucy2020 . You can load local models by giving path to local model on your system in the SentenceTransformers constructor like this: local_model = SentenceTransformer('/path/to/local/model') In order to load a local model, you need to first save it like: encoder.save('/path/to/local/model') Hope it helps!

Matrix-X commented 7 months ago

question is the default ‘/path/to/local/model’ location