UKPLab / sentence-transformers

Multilingual Sentence & Image Embeddings with BERT
https://www.SBERT.net
Apache License 2.0
14.35k stars 2.39k forks source link

Want to Load an HF model using the SentenceTransformers library #2760

Open borito1907 opened 2 weeks ago

borito1907 commented 2 weeks ago

Hi, There's a fine-tuned version of a SentenceTransformer as an HF model at this link. I'd like to load it using SentenceTransformers(model_name), but I can't. I can load it from AutoModel.from_pretrained and it works fine. When I use the SentenceTransformer library, I get the following error:

embedder = SentenceTransformer("AbeHou/SemStamp-c4-sbert")

WARNING:sentence_transformers.SentenceTransformer:No sentence-transformers model found with name AbeHou/SemStamp-c4-sbert. Creating a new one with mean pooling.

I'd appreciate some help!

tomaarsen commented 2 weeks ago

Hello!

It looks like https://huggingface.co/AbeHou/SemStamp-c4-sbert is missing some Sentence Transformers-specific files, such as the modules.json, config_sentence_transformers.json and sentence_bert_config.json. As a result, I think this is just a "normal" transformers model despite the sbert in the name.

If you load it, you'll indeed get that warning because it can't find the Sentence Transformers-specific files. It'll then load the transformers model and add a standard option for Sentence Transformers on it: mean pooling. If you want to finetune this further, then this is totally fine, but if you want to use this immediately, then it might not give great results.