Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
9
This is a sentence-transformers model finetuned from intfloat/multilingual-e5-small. 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': 512, 'do_lower_case': False}) with Transformer model: 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("codersan/validadted_e5SmallFa_onV9f")
# Run inference
sentences = [
'برای تبدیل شدن به نویسنده برتر Quora ، چند بازدید و پاسخ لازم است؟',
'چگونه می توانم نویسنده برتر Quora شوم ، از صعود بیشتر و آمار بهتر استفاده کنم؟',
'من به دنبال خرید دوچرخه جدید هستم.Suzuki Gixxer 155 یا Honda Hornet 160r.کدام یک را بخرید؟',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| details |
|
|
| anchor | positive |
|---|---|
وقتی سوال من به عنوان "این سوال ممکن است به ویرایش نیاز داشته باشد" چه کاری باید انجام دهم ، اما نمی توانم دلیل آن را پیدا کنم؟ |
چرا سوال من به عنوان نیاز به پیشرفت مشخص شده است؟ |
چگونه می توانید یک فایل رمزگذاری شده را با دانستن اینکه این یک فایل تصویری است بدون دانستن گسترش پرونده یا کلید ، رمزگشایی کنید؟ |
چگونه می توانید یک فایل رمزگذاری شده را رمزگشایی کنید و بدانید که این یک فایل تصویری است بدون اینکه از پسوند پرونده اطلاع داشته باشید؟ |
احساس می کنم خودکشی می کنم ، چگونه باید با آن برخورد کنم؟ |
احساس می کنم خودکشی می کنم.چه کاری باید انجام دهم؟ |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
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_e5SmallFa_onV9feval_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_e5SmallFa_onV9fhub_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.0091 | 100 | 0.7601 |
| 0.0183 | 200 | 0.4791 |
| 0.0274 | 300 | 0.1641 |
| 0.0366 | 400 | 0.0654 |
| 0.0457 | 500 | 0.0514 |
| 0.0549 | 600 | 0.0365 |
| 0.0640 | 700 | 0.0483 |
| 0.0732 | 800 | 0.0221 |
| 0.0823 | 900 | 0.0202 |
| 0.0915 | 1000 | 0.029 |
| 0.1006 | 1100 | 0.0215 |
| 0.1098 | 1200 | 0.0377 |
| 0.1189 | 1300 | 0.0351 |
| 0.1281 | 1400 | 0.034 |
| 0.1372 | 1500 | 0.0385 |
| 0.1464 | 1600 | 0.019 |
| 0.1555 | 1700 | 0.0314 |
| 0.1647 | 1800 | 0.0272 |
| 0.1738 | 1900 | 0.0363 |
| 0.1830 | 2000 | 0.0161 |
| 0.1921 | 2100 | 0.0315 |
| 0.2013 | 2200 | 0.0156 |
| 0.2104 | 2300 | 0.0327 |
| 0.2196 | 2400 | 0.0447 |
| 0.2287 | 2500 | 0.0251 |
| 0.2379 | 2600 | 0.0179 |
| 0.2470 | 2700 | 0.0185 |
| 0.2562 | 2800 | 0.0239 |
| 0.2653 | 2900 | 0.0268 |
| 0.2745 | 3000 | 0.0289 |
| 0.2836 | 3100 | 0.0312 |
| 0.2928 | 3200 | 0.0177 |
| 0.3019 | 3300 | 0.0283 |
| 0.3111 | 3400 | 0.0295 |
| 0.3202 | 3500 | 0.0335 |
| 0.3294 | 3600 | 0.0276 |
| 0.3385 | 3700 | 0.0232 |
| 0.3477 | 3800 | 0.0257 |
| 0.3568 | 3900 | 0.0164 |
| 0.3660 | 4000 | 0.0168 |
| 0.3751 | 4100 | 0.014 |
| 0.3843 | 4200 | 0.024 |
| 0.3934 | 4300 | 0.0169 |
| 0.4026 | 4400 | 0.0327 |
| 0.4117 | 4500 | 0.0269 |
| 0.4209 | 4600 | 0.0218 |
| 0.4300 | 4700 | 0.0399 |
| 0.4392 | 4800 | 0.0204 |
| 0.4483 | 4900 | 0.0183 |
| 0.4575 | 5000 | 0.0248 |
| 0.4666 | 5100 | 0.0171 |
| 0.4758 | 5200 | 0.0144 |
| 0.4849 | 5300 | 0.0255 |
| 0.4941 | 5400 | 0.0297 |
| 0.5032 | 5500 | 0.0186 |
| 0.5124 | 5600 | 0.0277 |
| 0.5215 | 5700 | 0.0187 |
| 0.5306 | 5800 | 0.028 |
| 0.5398 | 5900 | 0.0246 |
| 0.5489 | 6000 | 0.021 |
| 0.5581 | 6100 | 0.0186 |
| 0.5672 | 6200 | 0.0312 |
| 0.5764 | 6300 | 0.024 |
| 0.5855 | 6400 | 0.0273 |
| 0.5947 | 6500 | 0.0282 |
| 0.6038 | 6600 | 0.0177 |
| 0.6130 | 6700 | 0.012 |
| 0.6221 | 6800 | 0.0183 |
| 0.6313 | 6900 | 0.0186 |
| 0.6404 | 7000 | 0.0151 |
| 0.6496 | 7100 | 0.0233 |
| 0.6587 | 7200 | 0.0235 |
| 0.6679 | 7300 | 0.0249 |
| 0.6770 | 7400 | 0.0209 |
| 0.6862 | 7500 | 0.0195 |
| 0.6953 | 7600 | 0.0213 |
| 0.7045 | 7700 | 0.0298 |
| 0.7136 | 7800 | 0.0199 |
| 0.7228 | 7900 | 0.0183 |
| 0.7319 | 8000 | 0.0186 |
| 0.7411 | 8100 | 0.02 |
| 0.7502 | 8200 | 0.0232 |
| 0.7594 | 8300 | 0.0197 |
| 0.7685 | 8400 | 0.034 |
| 0.7777 | 8500 | 0.0153 |
| 0.7868 | 8600 | 0.0262 |
| 0.7960 | 8700 | 0.0218 |
| 0.8051 | 8800 | 0.0308 |
| 0.8143 | 8900 | 0.032 |
| 0.8234 | 9000 | 0.0131 |
| 0.8326 | 9100 | 0.018 |
| 0.8417 | 9200 | 0.0264 |
| 0.8509 | 9300 | 0.0208 |
| 0.8600 | 9400 | 0.0163 |
| 0.8692 | 9500 | 0.0158 |
| 0.8783 | 9600 | 0.0321 |
| 0.8875 | 9700 | 0.0238 |
| 0.8966 | 9800 | 0.0192 |
| 0.9058 | 9900 | 0.0148 |
| 0.9149 | 10000 | 0.0324 |
| 0.9241 | 10100 | 0.0254 |
| 0.9332 | 10200 | 0.0229 |
| 0.9424 | 10300 | 0.0132 |
| 0.9515 | 10400 | 0.0226 |
| 0.9607 | 10500 | 0.0213 |
| 0.9698 | 10600 | 0.022 |
| 0.9790 | 10700 | 0.0276 |
| 0.9881 | 10800 | 0.0312 |
| 0.9973 | 10900 | 0.0115 |
@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
intfloat/multilingual-e5-small