Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
11
This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2 on the csv dataset. 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, 'architecture': '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("Ermiyas/embedding-1")
# Run inference
sentences = [
" We're working on a story about negotiating a raise at work during a time of rising inflation. We need these queries answered for the story.\n\n1. What impact, if any, is skyrocketing inflation having on salaries and compensation on the job?\n\n2. Is it reasonable for an employee to ask for a raise at a time of high inflation? Or should job responsibilities be the only factor when asking for a raise?\n\n3. What are your best tips for negotiating a raise at a time of high inflation? What strategies works and what doesn't?\n\nThanks. | Looking for negotiation, career and financial experts for an article on negotiating a raise at work at a time of high inflation ",
' ',
'Hey Amy Walters, Thank you for reaching out. Dr. Sandeep Nayak, a Surgical Oncologist (DNB, MRCS UK, Fellowship in Laparoscopic and Robotic Surgical Oncology), provides his professional insight into the claim of curing cancer through dietary changes: "A claim like this needs to be examined carefully. While diet and nutrition play a crucial role in overall health and can support recovery during and after cancer treatment, there is no scientific evidence to suggest that dietary changes alone can cure cancer. The case mentioned, where surgery was performed and a plant-based diet followed, likely reflects the combined effect of medical intervention and lifestyle improvements. Surgery is often a curative treatment for localized cancers, but attributing the cure solely to dietary changes is misleading. What diet does offer is an enhancement to the body’s ability to heal and recover. For example, a diet rich in vegetables, legumes, and whole foods provides antioxidants and anti-inflammatory properties that can support the immune system and potentially reduce the risk of cancer recurrence. However, this should complement, not replace, proven cancer therapies like surgery, chemotherapy, or immunotherapy. It’s important for patients to understand that cancer is multifactorial, involving genetic, environmental, and lifestyle factors. While maintaining a healthy diet is essential for reducing risks and supporting recovery, it is not a standalone cure. Bold claims like this can deter patients from seeking evidence-based treatments, which could have life-saving outcomes." Dr. Nayak emphasizes that diet, while a powerful tool in promoting health, is one part of a larger treatment plan. "The best approach combines advanced medical treatments with lifestyle modifications for long-term well-being and prevention. Patients should always consult their oncologist or healthcare provider before making decisions about cancer care based on anecdotal reports." If you’d like additional commentary or specific examples, please feel free to reach out. Here are Dr. Nayak’s details for attribution: Dr. Sandeep Nayak DNB (General Surgery), DNB (Surgical Oncology), MRCS (UK), MNAMS (General Surgery) Fellowship in Laparoscopic and Robotic Surgical Oncology Profile: Dr. Sandeep Nayak Website: MACS for Cancer',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[ 1.0000, -0.0021, 0.4980],
# [ -0.0021, 1.0000, 0.0003],
# [ 0.4980, 0.0003, 1.0000]])
sts-devEmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.9238 |
| spearman_cosine | 0.8171 |
request, pitch, and score| request | pitch | score | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| request | pitch | score |
|---|---|---|
What can be done to improve diversity for financial advisors? |
What are tangible ways that the financial advisory industry can increase diversity? | What can be done to improve diversity for financial advisors? What are tangible ways that the financial advisory industry can increase diversity? |
UPDATE: Medical Doctors who are also Geriatricians |
Topic: Baby Boomers I want to speak with US medical experts (for 15 min) support the medical needs of those born from 1946 and 1964 AKA "Boomers" Previous: or those in professions that support their healthcare and retirement concerns. Aging life Specialists and Care Managers and Geriatricians to the front, please. Someone who can chat with me about the nuance in this demographic and what that are currently facing. -Please don't send ready-made quotes for this one. -Looking for experts who can speak to the health and social concerns of this demographic. It would be ideal to connect with an expert who can speak for 15 minutes on the 11 or 12 of next week. Here are my primary questions about Baby Boomers: What Role do Baby Boomers play in family dynamics today and why does it matter? What are challenges baby boomers are facing when it comes to their health? What are challenges baby boomers are facing when it comes to senio... |
Hi Yolande, |
Looking to speak to a researcher that has been in academia 20+ years |
Looking to have a quick conversation with a researcher that has been in academia 20+ years and uses Twitter to share their research. | |
CosineSimilarityLoss with these parameters:{
"loss_fct": "torch.nn.modules.loss.MSELoss"
}
request, pitch, and score| request | pitch | score | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| request | pitch | score |
|---|---|---|
I am working on an article for USA Today's Blueprint (Business Section) on the best onboarding practices. Looking for an HR professional to weigh in on the following: |
Human resources professional needed for insights on best onboarding and worker retention practices | Hey Jackie, I work with Keith Harper, the founder and CEO of NY-based Above & Beyond Talent Acquisition. A&B is on a mission to increase executive diversity among the Fortune 500 and along the way Keith has helped hundreds of companies find and successfully onboard candidates. They actually covered some onboarding strategies that maximize retention in a recent blog post here: https://aandbtalent.com/importance-of-mentorship-during-new-employee-onboarding/ I think Keith would be a fantastic resource and I'd be happy to connect you both if you'd like to schedule some time to speak with him. Very best, Bruce |
I’m working on a TravelSavvy feature on the Best Spring Break Destinations for Families With Young Kids—places where parents can relax, kids can play, and everyone gets the most out of their vacation. Whether it's a beach escape with calm waters (for newbie swimmers), a resort packed with kid-friendly activities, or an off-the-beaten-path gem perfect that's safe for family adventures, I want to hear about it! If you rep a destination (hotel, resort, tourism board) that offers an unforgettable spring break experience for families, send me your pitch! Please include links to book, off-peak and peak price ranges, and details on what makes it kid-friendly! I'll respond to those I plan to include. |
Best Spring Break Destinations for Families With Young Kids | Hi Ysolt, Hope you're doing well! For your story on the best Spring Break Destinations for Families with Young Kids, I wanted to put forward Cornwall, England for potential consideration. Destination: Cornwall, England Why: Cornwall is the ultimate British beach holiday location in the Spring as the weather gets noticeably warmer here much earlier than in other parts of Britain. The golden sand and turquoise water rivals that of the Caribbean. The quaint fishing villages and stunning beaches make for the perfect family break. During the summer months there will be ice cream on almost every corner, restaurants with delicious locally sourced fish dishes and coves to explore at low tide. It is beautiful corner of England that also offers fantastic car free biking trails (The Camel Trail) ideal for all ages and abilities. Coastal walks providing dramatic cliff tops, film locations from Poldark and more miles of sandy beaches for sandcastles or sunbathing! Quote from Gaby Cecil, Commercial ... |
Hi there, I'm looking for a telecoms engineer to discuss ways to connect to a satellite during a service outage, and share are more similar tips. |
Looking for a telecoms engineer | Hi Maria, Cool story you're working on here. I work with Benchmark Electronics, an advanced manufacturing and engineering company based in Arizona. They do A LOT of telecom work (https://www.bench.com/next-gen-communications) and I'd love to find an engineer for you to speak with there. I have one question for you on this though, is the listed deadline you have for collecting sources or is it for getting answers to the questions you have? If its the former, I can package these up for some folks and work to get them to you but if its the latter the turn around may be too tight. Please let me know either way. |
CosineSimilarityLoss with these parameters:{
"loss_fct": "torch.nn.modules.loss.MSELoss"
}
eval_strategy: stepsper_device_train_batch_size: 32per_device_eval_batch_size: 64gradient_accumulation_steps: 2learning_rate: 0.0001num_train_epochs: 7warmup_ratio: 0.2load_best_model_at_end: Trueoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 64per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 2eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 0.0001weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 7max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.2warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Falsefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Trueignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters: auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | sts-dev_spearman_cosine |
|---|---|---|---|---|
| -1 | -1 | - | - | 0.7685 |
| 0.3333 | 10 | 11.2084 | 0.0593 | 0.7714 |
| 0.6667 | 20 | 0.0316 | 0.0308 | 0.7794 |
| 1.0 | 30 | 0.0245 | 0.0334 | 0.7870 |
| 1.3333 | 40 | 0.0136 | 0.0246 | 0.7978 |
| 1.6667 | 50 | 11.0605 | 0.0233 | 0.8154 |
| 2.0 | 60 | 0.0155 | 0.0234 | 0.8161 |
| 2.3333 | 70 | 0.0125 | 0.0244 | 0.8331 |
| 2.6667 | 80 | 11.0853 | 0.0230 | 0.8264 |
| 3.0 | 90 | 0.0116 | 0.0225 | 0.8261 |
| 3.3333 | 100 | 0.0071 | 0.0226 | 0.8279 |
| 3.6667 | 110 | 11.0368 | 0.0227 | 0.8165 |
| 4.0 | 120 | 0.0072 | 0.0226 | 0.8145 |
| 4.3333 | 130 | 0.005 | 0.0222 | 0.8194 |
| 4.6667 | 140 | 0.0054 | 0.0225 | 0.8193 |
| 5.0 | 150 | 11.034 | 0.0226 | 0.8103 |
| 5.3333 | 160 | 0.0036 | 0.0225 | 0.8150 |
| 5.6667 | 170 | 0.0038 | 0.0228 | 0.8193 |
| 6.0 | 180 | 11.0309 | 0.0224 | 0.8168 |
| 6.3333 | 190 | 11.0297 | 0.0224 | 0.8163 |
| 6.6667 | 200 | 0.0029 | 0.0225 | 0.8165 |
| 7.0 | 210 | 0.0026 | 0.0225 | 0.8171 |
@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",
}
Base model
sentence-transformers/all-MiniLM-L6-v2