Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
9
This is a sentence-transformers model finetuned from sentence-transformers/LaBSE. 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': 256, 'do_lower_case': False}) 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): Dense({'in_features': 768, 'out_features': 768, 'bias': True, 'activation_function': 'torch.nn.modules.activation.Tanh'})
(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("codersan/validadted_faLabse_withCosSim")
# Run inference
sentences = [
'داشتن هزاران دنبال کننده در Quora چگونه است؟',
'چه چیزی است که ده ها هزار دنبال کننده در Quora داشته باشید؟',
'چگونه Airprint HP OfficeJet 4620 با HP LaserJet Enterprise M606X مقایسه می شود؟',
]
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]
sentence1, sentence2, and score| sentence1 | sentence2 | score | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| sentence1 | sentence2 | score |
|---|---|---|
تفاوت بین تحلیلگر تحقیقات بازار و تحلیلگر تجارت چیست؟ |
تفاوت بین تحقیقات بازاریابی و تحلیلگر تجارت چیست؟ |
0.982593297958374 |
خوردن چه چیزی باعث دل درد میشود؟ |
چه چیزی باعث رفع دل درد میشود؟ |
0.9582258462905884 |
بهترین نرم افزار ویرایش ویدیویی کدام است؟ |
بهترین نرم افزار برای ویرایش ویدیو چیست؟ |
0.9890836477279663 |
CosineSimilarityLoss with these parameters:{
"loss_fct": "torch.nn.modules.loss.MSELoss"
}
eval_strategy: stepsper_device_train_batch_size: 12learning_rate: 5e-06weight_decay: 0.01num_train_epochs: 1warmup_ratio: 0.1push_to_hub: Truehub_model_id: codersan/validadted_faLabse_withCosSimeval_on_start: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 12per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-06weight_decay: 0.01adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1num_train_epochs: 1max_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: 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: 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: Trueresume_from_checkpoint: Nonehub_model_id: codersan/validadted_faLabse_withCosSimhub_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: Trueuse_liger_kernel: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss |
|---|---|---|
| 0 | 0 | - |
| 0.0069 | 100 | 0.0299 |
| 0.0139 | 200 | 0.0185 |
| 0.0208 | 300 | 0.0063 |
| 0.0278 | 400 | 0.0021 |
| 0.0347 | 500 | 0.0009 |
| 0.0417 | 600 | 0.0006 |
| 0.0486 | 700 | 0.0006 |
| 0.0555 | 800 | 0.0005 |
| 0.0625 | 900 | 0.0005 |
| 0.0694 | 1000 | 0.0005 |
| 0.0764 | 1100 | 0.0005 |
| 0.0833 | 1200 | 0.0004 |
| 0.0903 | 1300 | 0.0004 |
| 0.0972 | 1400 | 0.0004 |
| 0.1041 | 1500 | 0.0004 |
| 0.1111 | 1600 | 0.0004 |
| 0.1180 | 1700 | 0.0004 |
| 0.1250 | 1800 | 0.0003 |
| 0.1319 | 1900 | 0.0003 |
| 0.1389 | 2000 | 0.0003 |
| 0.1458 | 2100 | 0.0003 |
| 0.1527 | 2200 | 0.0003 |
| 0.1597 | 2300 | 0.0003 |
| 0.1666 | 2400 | 0.0003 |
| 0.1736 | 2500 | 0.0003 |
| 0.1805 | 2600 | 0.0003 |
| 0.1875 | 2700 | 0.0003 |
| 0.1944 | 2800 | 0.0003 |
| 0.2013 | 2900 | 0.0003 |
| 0.2083 | 3000 | 0.0003 |
| 0.2152 | 3100 | 0.0003 |
| 0.2222 | 3200 | 0.0002 |
| 0.2291 | 3300 | 0.0003 |
| 0.2361 | 3400 | 0.0003 |
| 0.2430 | 3500 | 0.0002 |
| 0.2499 | 3600 | 0.0003 |
| 0.2569 | 3700 | 0.0003 |
| 0.2638 | 3800 | 0.0003 |
| 0.2708 | 3900 | 0.0002 |
| 0.2777 | 4000 | 0.0003 |
| 0.2847 | 4100 | 0.0003 |
| 0.2916 | 4200 | 0.0002 |
| 0.2985 | 4300 | 0.0002 |
| 0.3055 | 4400 | 0.0002 |
| 0.3124 | 4500 | 0.0002 |
| 0.3194 | 4600 | 0.0002 |
| 0.3263 | 4700 | 0.0002 |
| 0.3333 | 4800 | 0.0003 |
| 0.3402 | 4900 | 0.0002 |
| 0.3471 | 5000 | 0.0002 |
| 0.3541 | 5100 | 0.0002 |
| 0.3610 | 5200 | 0.0002 |
| 0.3680 | 5300 | 0.0002 |
| 0.3749 | 5400 | 0.0002 |
| 0.3819 | 5500 | 0.0002 |
| 0.3888 | 5600 | 0.0002 |
| 0.3958 | 5700 | 0.0002 |
| 0.4027 | 5800 | 0.0002 |
| 0.4096 | 5900 | 0.0002 |
| 0.4166 | 6000 | 0.0002 |
| 0.4235 | 6100 | 0.0002 |
| 0.4305 | 6200 | 0.0002 |
| 0.4374 | 6300 | 0.0002 |
| 0.4444 | 6400 | 0.0002 |
| 0.4513 | 6500 | 0.0002 |
| 0.4582 | 6600 | 0.0002 |
| 0.4652 | 6700 | 0.0002 |
| 0.4721 | 6800 | 0.0002 |
| 0.4791 | 6900 | 0.0002 |
| 0.4860 | 7000 | 0.0002 |
| 0.4930 | 7100 | 0.0002 |
| 0.4999 | 7200 | 0.0002 |
| 0.5068 | 7300 | 0.0002 |
| 0.5138 | 7400 | 0.0002 |
| 0.5207 | 7500 | 0.0002 |
| 0.5277 | 7600 | 0.0002 |
| 0.5346 | 7700 | 0.0002 |
| 0.5416 | 7800 | 0.0002 |
| 0.5485 | 7900 | 0.0002 |
| 0.5554 | 8000 | 0.0002 |
| 0.5624 | 8100 | 0.0002 |
| 0.5693 | 8200 | 0.0002 |
| 0.5763 | 8300 | 0.0002 |
| 0.5832 | 8400 | 0.0002 |
| 0.5902 | 8500 | 0.0002 |
| 0.5971 | 8600 | 0.0002 |
| 0.6040 | 8700 | 0.0002 |
| 0.6110 | 8800 | 0.0002 |
| 0.6179 | 8900 | 0.0002 |
| 0.6249 | 9000 | 0.0002 |
| 0.6318 | 9100 | 0.0002 |
| 0.6388 | 9200 | 0.0002 |
| 0.6457 | 9300 | 0.0002 |
| 0.6526 | 9400 | 0.0002 |
| 0.6596 | 9500 | 0.0002 |
| 0.6665 | 9600 | 0.0002 |
| 0.6735 | 9700 | 0.0002 |
| 0.6804 | 9800 | 0.0002 |
| 0.6874 | 9900 | 0.0002 |
| 0.6943 | 10000 | 0.0002 |
| 0.7012 | 10100 | 0.0002 |
| 0.7082 | 10200 | 0.0002 |
| 0.7151 | 10300 | 0.0002 |
| 0.7221 | 10400 | 0.0002 |
| 0.7290 | 10500 | 0.0002 |
| 0.7360 | 10600 | 0.0002 |
| 0.7429 | 10700 | 0.0002 |
| 0.7498 | 10800 | 0.0002 |
| 0.7568 | 10900 | 0.0002 |
| 0.7637 | 11000 | 0.0002 |
| 0.7707 | 11100 | 0.0002 |
| 0.7776 | 11200 | 0.0002 |
| 0.7846 | 11300 | 0.0002 |
| 0.7915 | 11400 | 0.0002 |
| 0.7984 | 11500 | 0.0002 |
| 0.8054 | 11600 | 0.0002 |
| 0.8123 | 11700 | 0.0002 |
| 0.8193 | 11800 | 0.0002 |
| 0.8262 | 11900 | 0.0002 |
| 0.8332 | 12000 | 0.0002 |
| 0.8401 | 12100 | 0.0002 |
| 0.8470 | 12200 | 0.0002 |
| 0.8540 | 12300 | 0.0002 |
| 0.8609 | 12400 | 0.0002 |
| 0.8679 | 12500 | 0.0002 |
| 0.8748 | 12600 | 0.0002 |
| 0.8818 | 12700 | 0.0002 |
| 0.8887 | 12800 | 0.0002 |
| 0.8956 | 12900 | 0.0002 |
| 0.9026 | 13000 | 0.0002 |
| 0.9095 | 13100 | 0.0002 |
| 0.9165 | 13200 | 0.0002 |
| 0.9234 | 13300 | 0.0002 |
| 0.9304 | 13400 | 0.0002 |
| 0.9373 | 13500 | 0.0002 |
| 0.9442 | 13600 | 0.0002 |
| 0.9512 | 13700 | 0.0002 |
| 0.9581 | 13800 | 0.0002 |
| 0.9651 | 13900 | 0.0002 |
| 0.9720 | 14000 | 0.0002 |
| 0.9790 | 14100 | 0.0002 |
| 0.9859 | 14200 | 0.0002 |
| 0.9928 | 14300 | 0.0002 |
| 0.9998 | 14400 | 0.0002 |
@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/LaBSE