Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 12
This is a sentence-transformers model finetuned from NovaSearch/stella_en_1.5B_v5. It maps sentences & paragraphs to a 1024-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': 512, 'do_lower_case': False}) with Transformer model: Qwen2Model
(1): Pooling({'word_embedding_dimension': 1536, '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): Dense({'in_features': 1536, 'out_features': 1024, 'bias': True, 'activation_function': 'torch.nn.modules.linear.Identity'})
)
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("bod9/fulldshardneg")
# Run inference
sentences = [
'#1 small corded treadmill without remote control',
'SUNNY HEALTH & FITNESS ASUNA Space Saving Treadmill, Motorized with Speakers for AUX Audio Connection - 8730G',
'Goplus Under Desk Treadmill, with Touchable LED Display and Wireless Remote Control, Built-in 3 Workout Modes and 12 Programs, Walking Jogging Machine, Superfit Electric Treadmill for Home Office',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
ir_evaluationInformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.5244 |
| cosine_accuracy@3 | 0.7189 |
| cosine_accuracy@5 | 0.7823 |
| cosine_accuracy@10 | 0.8453 |
| cosine_precision@1 | 0.5244 |
| cosine_precision@3 | 0.4476 |
| cosine_precision@5 | 0.4002 |
| cosine_precision@10 | 0.3198 |
| cosine_recall@1 | 0.0937 |
| cosine_recall@3 | 0.2136 |
| cosine_recall@5 | 0.298 |
| cosine_recall@10 | 0.4318 |
| cosine_ndcg@5 | 0.4676 |
| cosine_ndcg@10 | 0.4681 |
| cosine_mrr@1 | 0.5244 |
| cosine_mrr@5 | 0.6257 |
| cosine_mrr@10 | 0.6341 |
| cosine_map@10 | 0.3493 |
| cosine_map@100 | 0.4065 |
gr_evaluationGradedIREvaluator.GradedIREvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.7088 |
| cosine_accuracy@3 | 0.9038 |
| cosine_accuracy@5 | 0.9463 |
| cosine_accuracy@10 | 0.984 |
| cosine_precision@1 | 0.7088 |
| cosine_precision@3 | 0.6469 |
| cosine_precision@5 | 0.6045 |
| cosine_precision@10 | 0.5284 |
| cosine_recall@1 | 0.1272 |
| cosine_recall@3 | 0.3093 |
| cosine_recall@5 | 0.449 |
| cosine_recall@10 | 0.7099 |
| cosine_ndcg@5 | 0.7127 |
| cosine_ndcg@10 | 0.7543 |
| cosine_mrr@1 | 0.7088 |
| cosine_mrr@5 | 0.8066 |
| cosine_mrr@10 | 0.8118 |
| cosine_map@10 | 0.6051 |
| cosine_map@100 | 0.6944 |
@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{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
Base model
NovaSearch/stella_en_1.5B_v5