Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 17
How to use aritrasen/bge-base-en-v1.5-finetuned_ragds with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("aritrasen/bge-base-en-v1.5-finetuned_ragds")
sentences = [
"Tummy time is recommended from birth to strengthen baby's arms, back and neck muscles and prevent the back of his head becoming flat. Jay L. Hoecker, M.D, of the Mayo Clinic, says babies should not sleep or be left unattended on tummies, but the position will help move them toward milestones of rolling and crawling. If your baby does not like lying on his tummy, there are ways you can help him learn to enjoy it.\nComfort\nMake sure baby is nice and comfortable by using a soft surface like a bed and a fleecy blanket. Your baby may feel more comfortable on his tummy if you take his clothes and diaper off, making sure the room is nice and warm. This way he will not have anything pressing into his tummy and the feeling of being naked may add to his enjoyment. It is best not to make tummy time straight after a feed as his full tummy may not feel comfortable. Try to position his arms in front of him as he can eventually start to use them to lean on. Don't make tummy time too long to begin with; HealthyChildren.org advises that a newborn only needs three to five minutes two or three times a day, which can gradually be increased.\nTouching\nYour baby may enjoy the sensation of your fingers running gently down her back while she lies on her tummy -- this works better on bare skin. You can also stroke her cheeks, tickle her toes and gently massage her hands, feet and legs. If she is feeling a bit uncomfortable or unsure, this touching may help to put her at ease. Massage will also relax her muscles, helping her whole body feel more comfortable.\nStimulation\nKeep your baby stimulated with lots of visual aids. Dr. Sears says young babies like to look at bright colors, stripes and black and white objects, so place some of these around your baby to catch his attention. Wave noisy toys, such as rattles or scrunchy toys for him to look at, or wiggle your fingers in front of him. You could also play some music during tummy time, as this sound stimulation may be another way of distracting him from any anxiety about this new position.\nInteraction\nYour baby loves listening to your voice, so try reclining beside her and singing or talking. You could also place her on a bed and sit on the floor so your face is level with hers. Tummy time can also work if you lie on your back with baby on her tummy on your tummy. You make a warm and soft surface, and she will love being that close to you and looking into your face. Another way of introducing tummy time is by laying her across your lap on her front.\nReferences\nPhoto Credits\n- BananaStock/BananaStock/Getty Images",
"Why is tummy time recommended for babies from birth?",
"How many bodies have been recovered from the mass grave found near Tomašica, Bosnia and Herzegovina in 2013?",
"What is considered the \"real flower\" of Austria according to the context?"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from BAAI/bge-base-en-v1.5. It maps sentences & paragraphs to a 768-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': True}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, '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("aritrasen/bge-base-en-v1.5-finetuned_ragds")
# Run inference
sentences = [
'Early this year, there was a buzz on Motorola inviting T-Mobile Moto X owners to take part in a soak test for possible future update. Motorola seemed skeptical in disclosing facts at that point of time but since Moto G was recently upgraded to Android 4.4.2; enthusiasts anticipated the same for T-Mobile Moto X. And it turned out to be true.\nNews Update\nThis T-Mobile version of Moto X is now receiving the upgrade which is a file size of 147.6 MB. The Android 4.4.2 is the latest version of KitKat that includes all the goodies from the earlier installments, plus a few additions. The good news is, Motorola has customized the whole package and made a few tweaks into the update. The Software Version bumped to 161.44.25 and the notable changes are listed as below:\n- It added substantial support for services like printing photos, Google Docs, Gmail messages and other such content via Wi-Fi, Bluetooth and hosted services such as HP ePrinters and Google Cloud Print.\n- It fixed all the bugs identified during the preliminary runs, including the ones that caused a few users to experience short battery life after upgrading to KitKat.\n- Another bug that caused delays in synchronizing email services like Microsoft Exchange was resolved, thus adding to the convenience of the user.\nThis is a noteworthy upgrade, considering the fact that bugs and errors were fixed. Mobile addicts across the world will rejoice, for they can experience the smartness of Android KitKat flawlessly in their devices. This is significant development in terms of update.\nThis variant is an unlocked GSM device so chances are, you can use it on networks of other service providers. In all probability, the update should not be affected and the installation should hardly take much time. The T-Mobile Moto X Android update is now available for manual download. It is accessible in the following sequential way:\n- Click on Settings\n- Click on About Phone\n- Click on System Updates\n- Click on Download\nRecommendations\nFor ensuring a successful installation, it is highly recommended to install this update with at least 50% battery and a strong connectivity; preferably Wi-Fi. Follow the notification message and select download-> once the download is over, select Install-> Once the installation is over, and the phone will automatically restart. This marks the completion of the installation process. The phone is now updated to 161.44.25 – This build is same as the soak test.\nThis upgrade is free in the carrier network and Motorola and Google has collaborated for a back up service for those in trouble. In case of distress, a user can contact them through the Moto X web interface and avail the service. There is still no news on other carrier variants of this update but we can safely hope that it will roll out very soon. Though the upgrade doesn’t appeal in terms of version number but it is definitely significant for users to live with the latest KitKat.',
'What are some of the notable changes in the T-Mobile Moto X update?',
'Who is the editor of "The Routledge Handbook of Tourism Geographies"?',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
positive and anchor| positive | anchor | |
|---|---|---|
| type | string | string |
| details |
|
|
| positive | anchor |
|---|---|
Caption: Tasmanian berry grower Nic Hansen showing Macau chef Antimo Merone around his property as part of export engagement activities. |
What is the Berry Export Summary 2028 and what is its purpose? |
RWSN Collaborations |
What are some of the benefits reported from having access to Self-supply water sources? |
All Android applications categories |
What are the unique features of the Coolands for Twitter app? |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
positive and anchor| positive | anchor | |
|---|---|---|
| type | string | string |
| details |
|
|
| positive | anchor |
|---|---|
Perhaps Not such a Good Idea |
What is the author's personal view on DaveScot's blog persona? |
Age reduction Academic atmosphere Beef tendon bottom Straight buckle low-heel cowhide Lefu shoes Mary Jane shoes Spring and summer Women's shoes 0.73 |
What type of shoes are mentioned as being suitable for both men and women? |
I just started a new blog on my ultralight gear. My gear list in all it's glory is located on: each item of gear, I'm writing an in-depth review for the item and how we have used it. Would love to get feedback and the site and our gear and/or comments from people on how we can fine tune.Currently my wifes pack is 7.5 lbs base weight, and mine is 10.5 lbs.Thanks!-Brett |
What are the base weights of the blogger's and his wife's packs? |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
eval_strategy: stepsper_device_train_batch_size: 10per_device_eval_batch_size: 10num_train_epochs: 5warmup_ratio: 0.1fp16: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 10per_device_eval_batch_size: 10per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 5max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_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: Truefp16_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: Falseignore_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: Falsehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseeval_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: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falsebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | loss |
|---|---|---|---|
| 0.0521 | 50 | 0.1175 | - |
| 0.1042 | 100 | 0.079 | 0.0237 |
| 0.1562 | 150 | 0.0426 | - |
| 0.2083 | 200 | 0.0572 | 0.0136 |
| 0.2604 | 250 | 0.0571 | - |
| 0.3125 | 300 | 0.0455 | 0.0143 |
| 0.3646 | 350 | 0.0524 | - |
| 0.4167 | 400 | 0.0571 | 0.0226 |
| 0.4688 | 450 | 0.0407 | - |
| 0.5208 | 500 | 0.0354 | 0.0156 |
| 0.5729 | 550 | 0.0461 | - |
| 0.625 | 600 | 0.0356 | 0.0214 |
| 0.6771 | 650 | 0.0418 | - |
| 0.7292 | 700 | 0.0483 | 0.0167 |
| 0.7812 | 750 | 0.0322 | - |
| 0.8333 | 800 | 0.031 | 0.0135 |
| 0.8854 | 850 | 0.0658 | - |
| 0.9375 | 900 | 0.0503 | 0.0187 |
| 0.9896 | 950 | 0.0343 | - |
| 1.0417 | 1000 | 0.0288 | 0.0178 |
| 1.0938 | 1050 | 0.0169 | - |
| 1.1458 | 1100 | 0.0179 | 0.0167 |
| 1.1979 | 1150 | 0.0192 | - |
| 1.25 | 1200 | 0.0108 | 0.0167 |
| 1.3021 | 1250 | 0.0062 | - |
| 1.3542 | 1300 | 0.0037 | 0.0177 |
| 1.4062 | 1350 | 0.008 | - |
| 1.4583 | 1400 | 0.0029 | 0.0194 |
| 1.5104 | 1450 | 0.0021 | - |
| 1.5625 | 1500 | 0.0042 | 0.0160 |
| 1.6146 | 1550 | 0.0019 | - |
| 1.6667 | 1600 | 0.0113 | 0.0167 |
| 1.7188 | 1650 | 0.0017 | - |
| 1.7708 | 1700 | 0.0016 | 0.0136 |
| 1.8229 | 1750 | 0.0023 | - |
| 1.875 | 1800 | 0.0109 | 0.0212 |
| 1.9271 | 1850 | 0.0051 | - |
| 1.9792 | 1900 | 0.0013 | 0.0196 |
| 2.0312 | 1950 | 0.0017 | - |
| 2.0833 | 2000 | 0.0017 | 0.0234 |
| 2.1354 | 2050 | 0.0012 | - |
| 2.1875 | 2100 | 0.0016 | 0.0226 |
| 2.2396 | 2150 | 0.0007 | - |
| 2.2917 | 2200 | 0.0023 | 0.0239 |
| 2.3438 | 2250 | 0.0006 | - |
| 2.3958 | 2300 | 0.0006 | 0.0241 |
| 2.4479 | 2350 | 0.0006 | - |
| 2.5 | 2400 | 0.0005 | 0.0256 |
| 2.5521 | 2450 | 0.0004 | - |
| 2.6042 | 2500 | 0.0004 | 0.0251 |
| 2.6562 | 2550 | 0.0006 | - |
| 2.7083 | 2600 | 0.0004 | 0.0251 |
| 2.7604 | 2650 | 0.0005 | - |
| 2.8125 | 2700 | 0.0003 | 0.0240 |
| 2.8646 | 2750 | 0.0028 | - |
| 2.9167 | 2800 | 0.0014 | 0.0246 |
| 2.9688 | 2850 | 0.0004 | - |
| 3.0208 | 2900 | 0.0003 | 0.0217 |
| 3.0729 | 2950 | 0.0004 | - |
| 3.125 | 3000 | 0.0003 | 0.0220 |
| 3.1771 | 3050 | 0.0003 | - |
| 3.2292 | 3100 | 0.0004 | 0.0226 |
| 3.2812 | 3150 | 0.0003 | - |
| 3.3333 | 3200 | 0.0003 | 0.0245 |
| 3.3854 | 3250 | 0.0003 | - |
| 3.4375 | 3300 | 0.0003 | 0.0247 |
| 3.4896 | 3350 | 0.0002 | - |
| 3.5417 | 3400 | 0.0002 | 0.0240 |
| 3.5938 | 3450 | 0.0002 | - |
| 3.6458 | 3500 | 0.0002 | 0.0239 |
| 3.6979 | 3550 | 0.0002 | - |
| 3.75 | 3600 | 0.0003 | 0.0237 |
| 3.8021 | 3650 | 0.0002 | - |
| 3.8542 | 3700 | 0.0002 | 0.0234 |
| 3.9062 | 3750 | 0.0003 | - |
| 3.9583 | 3800 | 0.0002 | 0.0232 |
| 4.0104 | 3850 | 0.0002 | - |
| 4.0625 | 3900 | 0.0002 | 0.0235 |
| 4.1146 | 3950 | 0.0002 | - |
| 4.1667 | 4000 | 0.0002 | 0.0238 |
| 4.2188 | 4050 | 0.0002 | - |
| 4.2708 | 4100 | 0.0002 | 0.0241 |
| 4.3229 | 4150 | 0.0002 | - |
| 4.375 | 4200 | 0.0002 | 0.0248 |
| 4.4271 | 4250 | 0.0002 | - |
| 4.4792 | 4300 | 0.0002 | 0.0248 |
| 4.5312 | 4350 | 0.0002 | - |
| 4.5833 | 4400 | 0.0002 | 0.0248 |
| 4.6354 | 4450 | 0.0002 | - |
| 4.6875 | 4500 | 0.0002 | 0.0249 |
| 4.7396 | 4550 | 0.0002 | - |
| 4.7917 | 4600 | 0.0002 | 0.0247 |
| 4.8438 | 4650 | 0.0002 | - |
| 4.8958 | 4700 | 0.0002 | 0.0246 |
| 4.9479 | 4750 | 0.0002 | - |
| 5.0 | 4800 | 0.0002 | 0.0246 |
@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
BAAI/bge-base-en-v1.5
from sentence_transformers import SentenceTransformer model = SentenceTransformer("aritrasen/bge-base-en-v1.5-finetuned_ragds") sentences = [ "Tummy time is recommended from birth to strengthen baby's arms, back and neck muscles and prevent the back of his head becoming flat. Jay L. Hoecker, M.D, of the Mayo Clinic, says babies should not sleep or be left unattended on tummies, but the position will help move them toward milestones of rolling and crawling. If your baby does not like lying on his tummy, there are ways you can help him learn to enjoy it.\nComfort\nMake sure baby is nice and comfortable by using a soft surface like a bed and a fleecy blanket. Your baby may feel more comfortable on his tummy if you take his clothes and diaper off, making sure the room is nice and warm. This way he will not have anything pressing into his tummy and the feeling of being naked may add to his enjoyment. It is best not to make tummy time straight after a feed as his full tummy may not feel comfortable. Try to position his arms in front of him as he can eventually start to use them to lean on. Don't make tummy time too long to begin with; HealthyChildren.org advises that a newborn only needs three to five minutes two or three times a day, which can gradually be increased.\nTouching\nYour baby may enjoy the sensation of your fingers running gently down her back while she lies on her tummy -- this works better on bare skin. You can also stroke her cheeks, tickle her toes and gently massage her hands, feet and legs. If she is feeling a bit uncomfortable or unsure, this touching may help to put her at ease. Massage will also relax her muscles, helping her whole body feel more comfortable.\nStimulation\nKeep your baby stimulated with lots of visual aids. Dr. Sears says young babies like to look at bright colors, stripes and black and white objects, so place some of these around your baby to catch his attention. Wave noisy toys, such as rattles or scrunchy toys for him to look at, or wiggle your fingers in front of him. You could also play some music during tummy time, as this sound stimulation may be another way of distracting him from any anxiety about this new position.\nInteraction\nYour baby loves listening to your voice, so try reclining beside her and singing or talking. You could also place her on a bed and sit on the floor so your face is level with hers. Tummy time can also work if you lie on your back with baby on her tummy on your tummy. You make a warm and soft surface, and she will love being that close to you and looking into your face. Another way of introducing tummy time is by laying her across your lap on her front.\nReferences\nPhoto Credits\n- BananaStock/BananaStock/Getty Images", "Why is tummy time recommended for babies from birth?", "How many bodies have been recovered from the mass grave found near Tomašica, Bosnia and Herzegovina in 2013?", "What is considered the \"real flower\" of Austria according to the context?" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4]