Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 19
How to use jjduquec/conflubot_embed_model with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("jjduquec/conflubot_embed_model")
sentences = [
"What are the benefits of sauna for both the body and mind, and how do different types of sauna rooms, such as wood burning, heat rocks, and electric heaters, warmed to temperatures between 150 F and 195 F, contribute to these benefits?",
"Sauna is a type of therapeutic therapy for both the body and the mind. It reduces inflammation in your body, it rids your body of toxins, good for heart health, reduces allergies and helps with sleep to name a few. Different sauna types like wood burning, heat rocks and electric heathers can warm the sauna rooms to different temperatures ranging from 150 F to 195 F. You can choose any one depends on how tolerable you are to heat.",
"The answer depends on the intended application. For instance, R is more suitable for statistical analysis and data parsing, while Python is often used for production applications, including machine learning.",
"Sauna is a type of recreational activity that has limited benefits for the body and mind. While it can be enjoyable, it does not have a significant impact on reducing inflammation, detoxification, or improving heart health. Different sauna types and temperatures can be used, but the overall effect is largely the same."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2. It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, '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, 'include_prompt': True})
(2): Normalize()
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("sentence_transformers_model_id")
# Run inference
sentences = [
'Explain ZMOT, also known as Zero Moment of Truth. And then tell me the difference between that & the 3-step model marketing, whatever was prevalent back in the day',
'The traditional 3-step model of marketing, introduced by P&G, consists of the consumer discovering a product, followed by the first moment of truth (FMOT) where the consumer evaluates the product, and finally the second moment of truth (SMOT) where the consumer purchases and uses the product. ZMOT, or Zero Moment of Truth, refers to the period between the initial discovery and FMOT, where the consumer researches and learns more about the product',
"The 3-step model of marketing, which was widely used until the introduction of ZMOT, involves the consumer becoming aware of a product's features, then experiencing the first moment of truth (FMOT) at the point of product demonstration, and finally the second moment of truth (SMOT) when they decide to recommend the product to friends. ZMOT, on the other hand, occurs between the initial awareness and FMOT, and involves the consumer seeking out more information about the product's accessories.",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
How is cryogenics used in the study and treatment of viruses in virology? |
Certain vaccines must be only stored at cryogenic temperature (ultra low temperatures of order -90 to -60 degree celcius / -130 F to -76 F) |
Certain vaccines must be stored at refrigerated temperatures, ranging from 2 to 8 degrees Celsius, to maintain their potency. |
I would like to know the domestication status of these animals: cats, dogs, sheep, whales, bats, and bald eagles. |
Among the listed animals, cats, dogs, and sheep have undergone domestication, while bald eagles, whales, and bats have not. |
Among the listed animals, cats, dogs, and bats have undergone domestication, while bald eagles, whales, and sheep have not. |
I need to know who was winner of mens 2022 fifa world cup and where did it happen |
The men's 2022 FIFA world cup was located in Qatar. Argentina won the world cup, beating France on penalties after drawing 3-3 during the game. |
France won the men's 2022 FIFA World Cup, which was held in Qatar. |
TripletLoss with these parameters:{
"distance_metric": "TripletDistanceMetric.EUCLIDEAN",
"triplet_margin": 5
}
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
I dont know anything about ironman can you tell me how many miles is the triathlon? |
The total distance of an Ironman triathlon is 140.6 miles, consisting of a 2.4-mile swim, a 112-mile bike ride, and a 26.2-mile run. |
An Ironman triathlon covers a total distance of around 160 miles, broken down into a 3.8-mile swim, a 120-mile bike segment, and a 36-mile run. |
what is this meetup group business all about |
Meetup events are real-life gatherings where members and organizers get together to connect, discuss, and practice activities related to their shared interests. |
Meetup events are online gatherings where members and organizers connect, discuss, and practice activities related to their shared interests. |
what exactly is gettysburg college? i need to know about it |
Gettysburg College is a privately funded liberal arts institution in Gettysburg, Pennsylvania, known for its historical significance in the Battle of Gettysburg during the American Civil War. |
Gettysburg College is a privately funded university in Gettysburg, Pennsylvania, known for its historical significance in the Battle of Gettysburg during World War I. |
TripletLoss with these parameters:{
"distance_metric": "TripletDistanceMetric.EUCLIDEAN",
"triplet_margin": 5
}
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
@misc{hermans2017defense,
title={In Defense of the Triplet Loss for Person Re-Identification},
author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
year={2017},
eprint={1703.07737},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
Base model
nreimers/MiniLM-L6-H384-uncased