Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 12
This is a sentence-transformers model trained. 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, 'architecture': 'XLMRobertaModel'})
(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})
)
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("alakxender/e5-dhivehi-combined-trained-mnr-mx")
# Run inference
sentences = [
'query: ޔުމްނުގެ ބަޔާން ނަގަން ރަސްމީކޮށް ފުލުހުން އެދިފައެއް ނުވޭ: އާއިލާ',
'passage: އެ ސިޓީގައި، ފުލުހުން ނެރުނު ބަޔާނުގައި ހުރީ ހަގީގަތާ ހިލާފު ވާހަކަތަކެއް ކަމަށް ބުނެފައިވެ އެވެ. އަދި އެ މައްސަލައާ ގުޅިގެން މީގެ ކުރިން ވެސް ހަގީގަތާ ހިލާފު މައުލޫމާތު ފުލުހުން ހާމަކޮށްފައިވާ ކަމަށް ތުހުމަތުކޮށްފައިވެ އެވެ.\n\nހ. ފެންޓެނޯއީ ގޭގެ ނުވަވަނަ ފަންގިފިލާއިން ގުދަނެއްގެ ފުރާޅު މައްޗަށް ހައްވާ ޔުމްނު ރަޝީދުގެ ބަޔާން ނެގުމަށް ރަސްމީކޮށް ފުލުހުން އެދިފައި ނުވާ ކަމަށް އާއިލާއިން ބުނެފި އެވެ.\n\nމި މައްސަލައާ ގުޅިގެން ފުލުހުން މިދިޔަ ބުރާސްފަތި ދުވަހު ނެރުނު ބަޔާނެއްގައި ބުނެފައި ވަނީ ޔުމްނުގެ ބަޔާން ނެގުމަށް މަސައްކަތް ކުރަމުންދާ ކަމަށާއި ނަމަވެސް އާއިލާގެ އެއްބާރުލުން ނުލިބޭ ކަމަށެވެ. ޔުމްނު މެލޭޝިއާއަށް އިތުރު ފަރުވާއަށް ގެންދިޔަ ދުވަހުން ފެށިގެން ދެ ފުލުހުން އެ ގައުމުގައި ތިބި ކަމަށް ވެސް ފުލުހުން ބުންޏެވެ.ފުލުހުން ނެރުނު ބަޔާނާ ގުޅިގެން ޔުމްނުގެ އާއިލާއިން މިއަދު ވަނީ\xa0އެކްޓިން ޕޮލިސް ކޮމިޝަނަރު އިސްމާއީލް ނަވީނަށް ސިޓީއެއް ފޮނުވައިފަ އެވެ. އެ ސިޓީގައި، ފުލުހުން ނެރުނު ބަޔާނުގައި ހުރީ ހަގީގަތާ ހިލާފު ވާހަކަތަކެއް ކަމަށް ބުނެފައިވެ އެވެ. އަދި އެ މައްސަލައާ ގުޅިގެން މީގެ ކުރިން ވެސް ހަގީގަތާ ހިލާފު މައުލޫމާތު ފުލުހުން ހާމަކޮށްފައިވާ ކަމަށް ތުހުމަތުކޮށްފައިވެ އެވެ.އޭގެ އިތުރުން، ތަހުގީގަށް އެންމެ ނާޒުކު ދަނޑިވަޅުގައި ފުލުހުން އަމަލުކޮށްފައިވާ ގޮތުން، އިންސާފުވެރިކަމާއެކު ތަހުގީގު ކުރިއަށް ގެންދާނެ ކަމުގެ ޔަގީންކަން މިހާރު ނެތް ކަމަށާއި، ނަމަވެސް ރާއްޖޭގެ ގާނޫނުތަކާއި ގަވައިދުތަކަށް ތަބާވުމުގެ ގޮތުން ފުލުހުން ކުރިއަށް ގެންދާ އެއްވެސް ތަހުގީގަކަށް އާއިލާއިން ހުރަސް ނާޅާނެ ކަމަށް ސިޓީގައިވެ އެވެ.ޔުމްނުގެ ދައްތަ، އާއިޝަތު ނާއިޝާ އަހުމަދު ރަޝީދު ސޮއިކޮށް ފޮނުވި އެ ސިޓީގައި ވަނީ ޔުމްނުގެ ބަޔާން ނަގަން ފުލުހުން ރަސްމީކޮށް އެދިފައި ނުވާ ކަމަށާއި، ބަޔާނެއް ނަގަން ރަސްމީކޮށް ލިޔުމުން އަންގައިފިނަމަ، އެކަމަށް އާއިލާއިން ޖަވާބުދާރީވާނެ ކަމަށެވެ.\xa0\n\n"ހައްވާ ޔުމްނު ރަޝީދަށް ލިބިފައިވާ އަނިޔާތަކާ ގުޅިގެން އޭނާ މިވަގުުތު އޮތީ ތަހުގީގަށް ބަޔާން ދެވޭ ފަދަ ހާލަތެއްގައި ނޫންކަން ޑޮކްޓަރުންގެ ރަސްމީ ލިޔުންތަކުން ވެސް އެނގެން އޮތްކަމުގައި ދަންނަވަމެވެ." އެ ސިޓީގައިވެ އެވެ.ސިޓީގައި ބުނެފައި ވަނީ ޔުމްނުގެ ހާލަތާ ގުޅޭ އެއްވެސް މައުލޫމާތެއް އާއިލާއިން ފުލުހުންނާ ހިއްސާ ނުކުރާ ކަމަށް ފުލުހުން ބުނި ނަމަވެސް، އެފަދަ މައުލޫމާތެއް ހޯދަން ފުލުހުންގެ ފަރާތުން އެދިފައިވެސް ނުވާ ކަމަށެވެ. އަދި، ފުލުހުންގެ ތަހުގީގަށް އާއިލާއިން އެއްބާރުލުން ނުދޭ ކަމަށް ބުނާ ވާހަކަ ވެސް ދޮގުކޮށްފައިވެ އެވެ. އެގޮތުން، ޔުމްނުގެ އާއިލާއާ ޗީފް އިންސްޕެކްޓާ އޮފް ޕޮލިސް ޑރ. ހަސަން އުމައިރު، މެލޭޝިއާގައި ދޮޅުގަޑިއެއްހާއިރު ބައްދަލުވުމެއް ބާއްވައިފައިވާކަން އެ ސިޓީގައި ބަޔާންކޮށްފައިވެ އެވެ."އާއިލާގެ އެންމެ ބޮޑު މަސްލަހަތެއް މިވަގުތު އޮތީ އޭނާއަށް އެކަށީގެންވާ ފަރުވާ ލިބިދިނުމާއެކު، އޭނާއަށް އިންސާފު ހޯދުމަށް މަސައްކަތް ކުރުމުގައެވެ. އެކަމުގައި ގާނޫނުތަކާއި ގަވައިދުތަކާ އެއްގޮތްވާ ގޮތުގެ މަތީން ފުލުހުންނަށް ދޭން ޖެހޭ އެންމެހާ އެއްބާރުލުމެއް އާއިލާގެ ފަރާތުން ދޭނެކަމުގައި ދަންނަވަމެވެ." އެ ސިޓީގައިވެ އެވެ.\n\nމި މަސައްކަތުގައި އަހަރެމެން ހަމަ ހަމަ ވާނެ، އިންސާފުވެރި ވާނެ، އިތުބާރު ދަމަހައްޓާނެ',
'query: ޖެނުއަރީ 2008 ގައި ކޭބީޖީވައި އިން ވަނީ އެމްއެންގެ އަލްބަނީގައި ހުންނަ ކޭއެލްސީއައި 106.1 އާއި އެމްއެންގެ އެލްކް ރިވަރގައި ހުންނަ ކޭޑީޑީޖީ 105.5 އިން ހެނދުނުގެ ޝޯ އެއްފަހަރާ ކާސްޓް ކުރަން ފަށާފައެވެ .',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[ 1.0000, 0.7517, -0.0737],
# [ 0.7517, 1.0000, -0.0515],
# [-0.0737, -0.0515, 1.0000]])
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
query: މި މެހެމާންދާރީއަކީ ދިވެހި ޓޫރިޒަމްގެ ހާއްސަ ސިފައެއް، އެކަމަށް ހުރަސް އެޅުން ގޯސް |
passage: ދިވެހި ޓޫރިޒަމްގެ ތަޖުރިބާކާރަކަށް 'ދައުރު'ން ސުވާލުކުރީމެވެ. |
query: ރާއްޖެއަށް އެތެރެކުރަން އުޅުނު 3 ކިލޯގެ މަސްތުވާތަކެތި އަތުލައިގެންފި ވައިގެމަގުން ރާއްޖެ އެތެރެކުރަން އުޅުނު 2.4 ކިލޯގެ މަސްތުވާތަކެތި އަތުލައިގެންފި ރާއްޖެ އައި އިންޑިއާ ރައްޔިތެއްގެ ލަގެޖުން 235 ގްރާމްގެ މަސްތުވާތަކެތި އަތުލައިގެންފި ރާއްޖެއަށް އެތެރެކ |
passage: ވައިގެ މަގުން ރާއްޖެ އެތެރެކުރަން އުޅުނު 18 ކިލޯގެ މަސްތުވާތަކެތީގެ މައްސަލައިގައި، އެތަކެތި ބަލައިދިޔަ 35 އަހަރުގެ ބަންގްލަދޭޝް މީހަކު ހައްޔަރުކޮށްފިއެވެ. |
query: ޝަމްއާން ވަކިކުރުމުގެ މަސައްކަތް ފެށީ އޭނާ އަތުގައި އިހުސާންގެ ވީޑިއޯއެއް އޮތްކަން އެނގިގެން: ޝަމްއާންގެ އާއިލާ ޝަމްއާން ވަކިކުރުމުގެ މަސައްކަތް ފެށީ އޭނާ އަތުގައި އިހުސާންގެ ވީޑިއޯއެއް އޮތްކަން އެނގިގެން: ޝަމްއާންގެ އާއިލާ |
passage: އިމިގްރޭޝަނުގެ ކުރީގެ ކޮންޓްރޯލަރު، ޝަމްއާން ވަހީދު ހައްޔަރުކުރުމުގެ މަސައްކަތް ފެށީ ހޯމް މިނިސްޓަރު، އަލީ އިހުސާންގެ ވީޑިއޯއެއް ޝަމްއާންގެ އަތުގައި އޮތް ކަމުގެ މައުލޫމާތު އިހުސާންއަށް ލިބުމުން ކަމަށް ޝަމްއާންގެ އާއިލާއިން ބުނެފި އެވެ. |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
per_device_train_batch_size: 32per_device_eval_batch_size: 32num_train_epochs: 10multi_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 32per_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: 10max_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: 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: 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: 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_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.0866 | 500 | 0.375 |
| 0.1732 | 1000 | 0.2806 |
| 0.2597 | 1500 | 0.268 |
| 0.3463 | 2000 | 0.2511 |
| 0.4329 | 2500 | 0.2376 |
| 0.5195 | 3000 | 0.2261 |
| 0.6061 | 3500 | 0.2264 |
| 0.6926 | 4000 | 0.2109 |
| 0.7792 | 4500 | 0.2116 |
| 0.8658 | 5000 | 0.2054 |
| 0.9524 | 5500 | 0.1963 |
| 1.0390 | 6000 | 0.1863 |
| 1.1255 | 6500 | 0.1716 |
| 1.2121 | 7000 | 0.1632 |
| 1.2987 | 7500 | 0.1648 |
| 1.3853 | 8000 | 0.1628 |
| 1.4719 | 8500 | 0.1552 |
| 1.5584 | 9000 | 0.1565 |
| 1.6450 | 9500 | 0.1557 |
| 1.7316 | 10000 | 0.1508 |
| 1.8182 | 10500 | 0.1521 |
| 1.9048 | 11000 | 0.1409 |
| 1.9913 | 11500 | 0.1435 |
| 2.0779 | 12000 | 0.1265 |
| 2.1645 | 12500 | 0.1268 |
| 2.2511 | 13000 | 0.1193 |
| 2.3377 | 13500 | 0.1162 |
| 2.4242 | 14000 | 0.1209 |
| 2.5108 | 14500 | 0.1183 |
| 2.5974 | 15000 | 0.1214 |
| 2.6840 | 15500 | 0.1203 |
| 2.7706 | 16000 | 0.1143 |
| 2.8571 | 16500 | 0.1128 |
| 2.9437 | 17000 | 0.1158 |
| 3.0303 | 17500 | 0.101 |
| 3.1169 | 18000 | 0.0945 |
| 3.2035 | 18500 | 0.0954 |
| 3.2900 | 19000 | 0.0936 |
| 3.3766 | 19500 | 0.095 |
| 3.4632 | 20000 | 0.0975 |
| 3.5498 | 20500 | 0.0937 |
| 3.6364 | 21000 | 0.0961 |
| 3.7229 | 21500 | 0.0937 |
| 3.8095 | 22000 | 0.0887 |
| 3.8961 | 22500 | 0.0864 |
| 3.9827 | 23000 | 0.0912 |
| 4.0693 | 23500 | 0.0763 |
| 4.1558 | 24000 | 0.0761 |
| 4.2424 | 24500 | 0.0788 |
| 4.3290 | 25000 | 0.0772 |
| 4.4156 | 25500 | 0.0784 |
| 4.5022 | 26000 | 0.078 |
| 4.5887 | 26500 | 0.078 |
| 4.6753 | 27000 | 0.0784 |
| 4.7619 | 27500 | 0.0764 |
| 4.8485 | 28000 | 0.0715 |
| 4.9351 | 28500 | 0.0759 |
| 5.0216 | 29000 | 0.0707 |
| 5.1082 | 29500 | 0.0712 |
| 5.1948 | 30000 | 0.0643 |
| 5.2814 | 30500 | 0.0641 |
| 5.3680 | 31000 | 0.0656 |
| 5.4545 | 31500 | 0.0632 |
| 5.5411 | 32000 | 0.0682 |
| 5.6277 | 32500 | 0.0612 |
| 5.7143 | 33000 | 0.0624 |
| 5.8009 | 33500 | 0.0616 |
| 5.8874 | 34000 | 0.0606 |
| 5.9740 | 34500 | 0.0613 |
| 6.0606 | 35000 | 0.0572 |
| 6.1472 | 35500 | 0.0551 |
| 6.2338 | 36000 | 0.0575 |
| 6.3203 | 36500 | 0.0532 |
| 6.4069 | 37000 | 0.0554 |
| 6.4935 | 37500 | 0.051 |
| 6.5801 | 38000 | 0.0562 |
| 6.6667 | 38500 | 0.053 |
| 6.7532 | 39000 | 0.0552 |
| 6.8398 | 39500 | 0.0535 |
| 6.9264 | 40000 | 0.0549 |
| 7.0130 | 40500 | 0.0517 |
| 7.0996 | 41000 | 0.0453 |
| 7.1861 | 41500 | 0.0437 |
| 7.2727 | 42000 | 0.0498 |
| 7.3593 | 42500 | 0.0507 |
| 7.4459 | 43000 | 0.0471 |
| 7.5325 | 43500 | 0.0487 |
| 7.6190 | 44000 | 0.0477 |
| 7.7056 | 44500 | 0.0481 |
| 7.7922 | 45000 | 0.049 |
| 7.8788 | 45500 | 0.043 |
| 7.9654 | 46000 | 0.0429 |
| 8.0519 | 46500 | 0.0457 |
| 8.1385 | 47000 | 0.0412 |
| 8.2251 | 47500 | 0.0423 |
| 8.3117 | 48000 | 0.0409 |
| 8.3983 | 48500 | 0.0412 |
| 8.4848 | 49000 | 0.0435 |
| 8.5714 | 49500 | 0.0437 |
| 8.6580 | 50000 | 0.043 |
| 8.7446 | 50500 | 0.0433 |
| 8.8312 | 51000 | 0.0415 |
| 8.9177 | 51500 | 0.0407 |
| 9.0043 | 52000 | 0.0421 |
| 9.0909 | 52500 | 0.0376 |
| 9.1775 | 53000 | 0.0411 |
| 9.2641 | 53500 | 0.0367 |
| 9.3506 | 54000 | 0.0395 |
| 9.4372 | 54500 | 0.0398 |
| 9.5238 | 55000 | 0.0409 |
| 9.6104 | 55500 | 0.0373 |
| 9.6970 | 56000 | 0.0402 |
| 9.7835 | 56500 | 0.0371 |
| 9.8701 | 57000 | 0.0359 |
| 9.9567 | 57500 | 0.0376 |
@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-base