Instructions to use sentence-transformers/all-mpnet-base-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use sentence-transformers/all-mpnet-base-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("sentence-transformers/all-mpnet-base-v2") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Transformers
How to use sentence-transformers/all-mpnet-base-v2 with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/all-mpnet-base-v2") model = AutoModelForMaskedLM.from_pretrained("sentence-transformers/all-mpnet-base-v2") - Inference
- Notebooks
- Google Colab
- Kaggle
How does the scoring function effect similarity performance of the model?
Coming to this page from https://www.sbert.net/docs/sentence_transformer/pretrained_models.html so not sure if this is the best place for this question, but the SentenceTransformer docs list dot-product, cosine-similarity, & euclidean-distance as suitable scoring functions for this model.
Is this any difference in performance for the different scoring functions used? Would using cosine-similarity vs euclidean-distance produce comparable results?
Regarding your question,
It is difficult to say that the performance is totally related to the scoring functions. Each of the scoring functions can reproduce different results. Also, the cosine similarity outputs the scores in a normalized manner (between 0 and 1), while others don't.
In each model card, it is possible to see the scoring function appropriate for its use case. However, all scoring functions work on all models as they produce mathematical matrixes plausible for calculation.
Directly answering your question -> The only main difference is computational time, as the mathematical expressions are different, the time to reproduce the results is distinct as well. In terms of performance, there is no semantic difference. However, you should choose the metric, mostly adapting it to your use case.
Hope this helps
Cheers
I guess I should elaborate a little more, what I was trying to get at is if one of the scoring functions outperforms the others in terms of semantic similarity results as documented on the SentenceTranformer site.