You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, let me thank you for maintaining this great package!
I think that the model-caching logic in SentenceTransformer.py could be improved. When I specify a model and a cache_dir like so SentenceTransformer("distiluse-base-multilingual-cased-v1", cache_folder="~/.models/") , my hope (and expectation) was the following behaviour:
When executed for the first time, it should download the model into the cache_folder (this is ok!).
When executed for a second time, it should re-load the existing model from that cache folder (does not work!). Even worse, it will download the model every time.
To actually make the model reload from cache, one would need to specify the model_name_or_path like so: SentenceTransformer(model_name_or_path="~/.models/sentence-transformers_distiluse-base-multilingual-cased-v1"). This leaves me with two different calls (first call, later re-loads) to SentenceTransformer with some checking in between.
The caching functionality has been overhauled in the new v2.3.0. It shouldn't re-download the model every time! I'll close this for now. Feel free to let me know if other model loading issues pop up with the new release.
First, let me thank you for maintaining this great package!
I think that the model-caching logic in
SentenceTransformer.py
could be improved. When I specify amodel
and acache_dir
like soSentenceTransformer("distiluse-base-multilingual-cased-v1", cache_folder="~/.models/")
, my hope (and expectation) was the following behaviour:cache_folder
(this is ok!).To actually make the model reload from cache, one would need to specify the
model_name_or_path
like so:SentenceTransformer(model_name_or_path="~/.models/sentence-transformers_distiluse-base-multilingual-cased-v1")
. This leaves me with two different calls (first call, later re-loads) to SentenceTransformer with some checking in between.The fix to this is rather simple. The loading code should check if the model was already downloaded to the cache_dir. The call to
snapshot_download
in https://github.com/UKPLab/sentence-transformers/blob/master/sentence_transformers/SentenceTransformer.py#L86 should only be executed if there is no existing model atmodel_path
yet.The text was updated successfully, but these errors were encountered: