Use git-aware cache file layout#2339
Conversation
`cached_download` is deprecated. Use `hf_hub_download` instead to take advantage of the new cache.
|
Though I'm in favor of moving towards from sentence_transformers import SentenceTransformer
model = SentenceTransformer("sentence-transformers/all-mpnet-base-v2")results in a warning that
|
I've tested with the model above and it works: (I added some log outputs to make sure it uses my local sentence-transformers repo.) the directory hierarchy is: |
|
The PR does indeed download the model correctly - but it then tries to check if the loaded model is a Sentence Transformer model using See for example: from sentence_transformers import SentenceTransformer
model = SentenceTransformer("all-mpnet-base-v2")
print(model.encode(["This is a test sentence"]).sum())On
|
The reason is that modules = OrderedDict([('0', Transformer({'max_seq_length': 384, 'do_lower_case': False}) with Transformer model: MPNetModel ), ('1', Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False})), ('2', Normalize())])My branch uses the function modules = OrderedDict([('0', Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: MPNetModel ), ('1', Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False}))])I pushed a commit to fix this bug. In the above example, the outputs are the same on both branches now: >>> print(model.encode(["This is a test sentence"]).sum())
0.10015613I don't know why the output is different from yours. |
|
I think #2345 should supersede this PR, it also moves to
|
|
Thank you! This PR can be closed. |
cached_downloadis deprecated. Usehf_hub_downloadinstead to take advantage of the new cache.The new cache is introduced in https://github.com/huggingface/huggingface_hub/releases/tag/v0.8.1