Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
• 1908.10084 • Published
• 12
This is a sentence-transformers model finetuned from sentence-transformers/gtr-t5-base. 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': False}) with Transformer model: T5EncoderModel
(1): Pooling({'word_embedding_dimension': 768, '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': 768, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
(3): 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 = [
'The travel agent secured the best possible deals for the group tour.',
'negotiate tourism rates',
'work with cultural venue specialists',
]
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]
sentence_0, sentence_1, and label| sentence_0 | sentence_1 | label | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| sentence_0 | sentence_1 | label |
|---|---|---|
This role involves planning delivery schedules. |
handle carriers |
1.0 |
This module focuses on automating ASP.NET deployments using Octopus Deploy. |
Octopus Deploy |
1.0 |
The team will transport the necessary tools to the designated location. |
move rigging equipment |
1.0 |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
per_device_train_batch_size: 16per_device_eval_batch_size: 16fp16: Truemulti_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1num_train_epochs: 3max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_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: Nonehub_always_push: Falsegradient_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: 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: Falseuse_liger_kernel: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robin| Epoch | Step | Training Loss |
|---|---|---|
| 0.0112 | 500 | 0.0 |
| 0.0224 | 1000 | 0.0 |
| 0.0336 | 1500 | 0.0 |
| 0.0448 | 2000 | 0.0 |
| 0.0560 | 2500 | 0.0 |
| 0.0673 | 3000 | 0.0 |
| 0.0785 | 3500 | 0.0 |
| 0.0897 | 4000 | 0.0 |
| 0.1009 | 4500 | 0.0 |
| 0.1121 | 5000 | 0.0 |
| 0.1233 | 5500 | 0.0 |
| 0.1345 | 6000 | 0.0 |
| 0.1457 | 6500 | 0.0 |
| 0.1569 | 7000 | 0.0 |
| 0.1681 | 7500 | 0.0 |
| 0.1794 | 8000 | 0.0 |
| 0.1906 | 8500 | 0.0 |
| 0.2018 | 9000 | 0.0 |
| 0.2130 | 9500 | 0.0 |
| 0.2242 | 10000 | 0.0 |
| 0.2354 | 10500 | 0.0 |
| 0.2466 | 11000 | 0.0 |
| 0.2578 | 11500 | 0.0 |
| 0.2690 | 12000 | 0.0 |
| 0.2802 | 12500 | 0.0 |
| 0.2915 | 13000 | 0.0 |
| 0.3027 | 13500 | 0.0 |
| 0.3139 | 14000 | 0.0 |
| 0.3251 | 14500 | 0.0 |
| 0.3363 | 15000 | 0.0 |
| 0.3475 | 15500 | 0.0 |
| 0.3587 | 16000 | 0.0 |
| 0.3699 | 16500 | 0.0 |
| 0.3811 | 17000 | 0.0 |
| 0.3923 | 17500 | 0.0 |
| 0.4036 | 18000 | 0.0 |
| 0.4148 | 18500 | 0.0 |
| 0.4260 | 19000 | 0.0 |
| 0.4372 | 19500 | 0.0 |
| 0.4484 | 20000 | 0.0 |
| 0.4596 | 20500 | 0.0 |
| 0.4708 | 21000 | 0.0 |
| 0.4820 | 21500 | 0.0 |
| 0.4932 | 22000 | 0.0 |
| 0.5044 | 22500 | 0.0 |
| 0.5156 | 23000 | 0.0 |
| 0.5269 | 23500 | 0.0 |
| 0.5381 | 24000 | 0.0 |
| 0.5493 | 24500 | 0.0 |
| 0.5605 | 25000 | 0.0 |
| 0.5717 | 25500 | 0.0 |
| 0.5829 | 26000 | 0.0 |
| 0.5941 | 26500 | 0.0 |
| 0.6053 | 27000 | 0.0 |
| 0.6165 | 27500 | 0.0 |
| 0.6277 | 28000 | 0.0 |
| 0.6390 | 28500 | 0.0 |
| 0.6502 | 29000 | 0.0 |
| 0.6614 | 29500 | 0.0 |
| 0.6726 | 30000 | 0.0 |
| 0.6838 | 30500 | 0.0 |
| 0.6950 | 31000 | 0.0 |
| 0.7062 | 31500 | 0.0 |
| 0.7174 | 32000 | 0.0 |
| 0.7286 | 32500 | 0.0 |
| 0.7398 | 33000 | 0.0 |
| 0.7511 | 33500 | 0.0 |
| 0.7623 | 34000 | 0.0 |
| 0.7735 | 34500 | 0.0 |
| 0.7847 | 35000 | 0.0 |
| 0.7959 | 35500 | 0.0 |
| 0.8071 | 36000 | 0.0 |
| 0.8183 | 36500 | 0.0 |
| 0.8295 | 37000 | 0.0 |
| 0.8407 | 37500 | 0.0 |
| 0.8519 | 38000 | 0.0 |
| 0.8632 | 38500 | 0.0 |
| 0.8744 | 39000 | 0.0 |
| 0.8856 | 39500 | 0.0 |
| 0.8968 | 40000 | 0.0 |
| 0.9080 | 40500 | 0.0 |
| 0.9192 | 41000 | 0.0 |
| 0.9304 | 41500 | 0.0 |
| 0.9416 | 42000 | 0.0 |
| 0.9528 | 42500 | 0.0 |
| 0.9640 | 43000 | 0.0 |
| 0.9752 | 43500 | 0.0 |
| 0.9865 | 44000 | 0.0 |
| 0.9977 | 44500 | 0.0 |
| 1.0089 | 45000 | 0.0 |
| 1.0201 | 45500 | 0.0 |
| 1.0313 | 46000 | 0.0 |
| 1.0425 | 46500 | 0.0 |
| 1.0537 | 47000 | 0.0 |
| 1.0649 | 47500 | 0.0 |
| 1.0761 | 48000 | 0.0 |
| 1.0873 | 48500 | 0.0 |
| 1.0986 | 49000 | 0.0 |
| 1.1098 | 49500 | 0.0 |
| 1.1210 | 50000 | 0.0 |
| 1.1322 | 50500 | 0.0 |
| 1.1434 | 51000 | 0.0 |
| 1.1546 | 51500 | 0.0 |
| 1.1658 | 52000 | 0.0 |
| 1.1770 | 52500 | 0.0 |
| 1.1882 | 53000 | 0.0 |
| 1.1994 | 53500 | 0.0 |
| 1.2107 | 54000 | 0.0 |
| 1.2219 | 54500 | 0.0 |
| 1.2331 | 55000 | 0.0 |
| 1.2443 | 55500 | 0.0 |
| 1.2555 | 56000 | 0.0 |
| 1.2667 | 56500 | 0.0 |
| 1.2779 | 57000 | 0.0 |
| 1.2891 | 57500 | 0.0 |
| 1.3003 | 58000 | 0.0 |
| 1.3115 | 58500 | 0.0 |
| 1.3228 | 59000 | 0.0 |
| 1.3340 | 59500 | 0.0 |
| 1.3452 | 60000 | 0.0 |
| 1.3564 | 60500 | 0.0 |
| 1.3676 | 61000 | 0.0 |
| 1.3788 | 61500 | 0.0 |
| 1.3900 | 62000 | 0.0 |
| 1.4012 | 62500 | 0.0 |
| 1.4124 | 63000 | 0.0 |
| 1.4236 | 63500 | 0.0 |
| 1.4348 | 64000 | 0.0 |
| 1.4461 | 64500 | 0.0 |
| 1.4573 | 65000 | 0.0 |
| 1.4685 | 65500 | 0.0 |
| 1.4797 | 66000 | 0.0 |
| 1.4909 | 66500 | 0.0 |
| 1.5021 | 67000 | 0.0 |
| 1.5133 | 67500 | 0.0 |
| 1.5245 | 68000 | 0.0 |
| 1.5357 | 68500 | 0.0 |
| 1.5469 | 69000 | 0.0 |
| 1.5582 | 69500 | 0.0 |
| 1.5694 | 70000 | 0.0 |
| 1.5806 | 70500 | 0.0 |
| 1.5918 | 71000 | 0.0 |
| 1.6030 | 71500 | 0.0 |
| 1.6142 | 72000 | 0.0 |
| 1.6254 | 72500 | 0.0 |
| 1.6366 | 73000 | 0.0 |
| 1.6478 | 73500 | 0.0 |
| 1.6590 | 74000 | 0.0 |
| 1.6703 | 74500 | 0.0 |
| 1.6815 | 75000 | 0.0 |
| 1.6927 | 75500 | 0.0 |
| 1.7039 | 76000 | 0.0 |
| 1.7151 | 76500 | 0.0 |
| 1.7263 | 77000 | 0.0 |
| 1.7375 | 77500 | 0.0 |
| 1.7487 | 78000 | 0.0 |
| 1.7599 | 78500 | 0.0 |
| 1.7711 | 79000 | 0.0 |
| 1.7824 | 79500 | 0.0 |
| 1.7936 | 80000 | 0.0 |
| 1.8048 | 80500 | 0.0 |
| 1.8160 | 81000 | 0.0 |
| 1.8272 | 81500 | 0.0 |
| 1.8384 | 82000 | 0.0 |
| 1.8496 | 82500 | 0.0 |
| 1.8608 | 83000 | 0.0 |
| 1.8720 | 83500 | 0.0 |
| 1.8832 | 84000 | 0.0 |
| 1.8944 | 84500 | 0.0 |
| 1.9057 | 85000 | 0.0 |
| 1.9169 | 85500 | 0.0 |
| 1.9281 | 86000 | 0.0 |
| 1.9393 | 86500 | 0.0 |
| 1.9505 | 87000 | 0.0 |
| 1.9617 | 87500 | 0.0 |
| 1.9729 | 88000 | 0.0 |
| 1.9841 | 88500 | 0.0 |
| 1.9953 | 89000 | 0.0 |
| 2.0065 | 89500 | 0.0 |
| 2.0178 | 90000 | 0.0 |
| 2.0290 | 90500 | 0.0 |
| 2.0402 | 91000 | 0.0 |
| 2.0514 | 91500 | 0.0 |
| 2.0626 | 92000 | 0.0 |
| 2.0738 | 92500 | 0.0 |
| 2.0850 | 93000 | 0.0 |
| 2.0962 | 93500 | 0.0 |
| 2.1074 | 94000 | 0.0 |
| 2.1186 | 94500 | 0.0 |
| 2.1299 | 95000 | 0.0 |
| 2.1411 | 95500 | 0.0 |
| 2.1523 | 96000 | 0.0 |
| 2.1635 | 96500 | 0.0 |
| 2.1747 | 97000 | 0.0 |
| 2.1859 | 97500 | 0.0 |
| 2.1971 | 98000 | 0.0 |
| 2.2083 | 98500 | 0.0 |
| 2.2195 | 99000 | 0.0 |
| 2.2307 | 99500 | 0.0 |
| 2.2420 | 100000 | 0.0 |
| 2.2532 | 100500 | 0.0 |
| 2.2644 | 101000 | 0.0 |
| 2.2756 | 101500 | 0.0 |
| 2.2868 | 102000 | 0.0 |
| 2.2980 | 102500 | 0.0 |
| 2.3092 | 103000 | 0.0 |
| 2.3204 | 103500 | 0.0 |
| 2.3316 | 104000 | 0.0 |
| 2.3428 | 104500 | 0.0 |
| 2.3540 | 105000 | 0.0 |
| 2.3653 | 105500 | 0.0 |
| 2.3765 | 106000 | 0.0 |
| 2.3877 | 106500 | 0.0 |
| 2.3989 | 107000 | 0.0 |
| 2.4101 | 107500 | 0.0 |
| 2.4213 | 108000 | 0.0 |
| 2.4325 | 108500 | 0.0 |
| 2.4437 | 109000 | 0.0 |
| 2.4549 | 109500 | 0.0 |
| 2.4661 | 110000 | 0.0 |
| 2.4774 | 110500 | 0.0 |
| 2.4886 | 111000 | 0.0 |
| 2.4998 | 111500 | 0.0 |
| 2.5110 | 112000 | 0.0 |
| 2.5222 | 112500 | 0.0 |
| 2.5334 | 113000 | 0.0 |
| 2.5446 | 113500 | 0.0 |
| 2.5558 | 114000 | 0.0 |
| 2.5670 | 114500 | 0.0 |
| 2.5782 | 115000 | 0.0 |
| 2.5895 | 115500 | 0.0 |
| 2.6007 | 116000 | 0.0 |
| 2.6119 | 116500 | 0.0 |
| 2.6231 | 117000 | 0.0 |
| 2.6343 | 117500 | 0.0 |
| 2.6455 | 118000 | 0.0 |
| 2.6567 | 118500 | 0.0 |
| 2.6679 | 119000 | 0.0 |
| 2.6791 | 119500 | 0.0 |
| 2.6903 | 120000 | 0.0 |
| 2.7016 | 120500 | 0.0 |
| 2.7128 | 121000 | 0.0 |
| 2.7240 | 121500 | 0.0 |
| 2.7352 | 122000 | 0.0 |
| 2.7464 | 122500 | 0.0 |
| 2.7576 | 123000 | 0.0 |
| 2.7688 | 123500 | 0.0 |
| 2.7800 | 124000 | 0.0 |
| 2.7912 | 124500 | 0.0 |
| 2.8024 | 125000 | 0.0 |
| 2.8136 | 125500 | 0.0 |
| 2.8249 | 126000 | 0.0 |
| 2.8361 | 126500 | 0.0 |
| 2.8473 | 127000 | 0.0 |
| 2.8585 | 127500 | 0.0 |
| 2.8697 | 128000 | 0.0 |
| 2.8809 | 128500 | 0.0 |
| 2.8921 | 129000 | 0.0 |
| 2.9033 | 129500 | 0.0 |
| 2.9145 | 130000 | 0.0 |
| 2.9257 | 130500 | 0.0 |
| 2.9370 | 131000 | 0.0 |
| 2.9482 | 131500 | 0.0 |
| 2.9594 | 132000 | 0.0 |
| 2.9706 | 132500 | 0.0 |
| 2.9818 | 133000 | 0.0 |
| 2.9930 | 133500 | 0.0 |
@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
sentence-transformers/gtr-t5-base