Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
9
This is a sentence-transformers model finetuned from BAAI/bge-m3. It maps sentences & paragraphs to a 1024-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': 8192, 'do_lower_case': False}) with Transformer model: XLMRobertaModel
(1): Pooling({'word_embedding_dimension': 1024, '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("sentence_transformers_model_id")
# Run inference
sentences = [
'어린이 보조 좌석을 동승석에 설치하지 말아야 하는 이유는 무엇인가요?',
'어린이 보조 좌석 설치 금지: 승객 구분 센서의 유무와 상관없이 동승석에는 어린이 보조 좌석을 설치하지 마십시오. 동승석 에어백이 팽창할 때 보조 좌석이 적정한 위치에서 벗어나거나 제대로 고정되지 못해 어린이가 큰 부상을 입을 수 있습니다.',
'디지털 키가 등록되어 있습니다: 차량 스마트폰 키 또는 카드 키가 등록되어 있을 때 차량 전원을 켜면 이 경고문이 4초 동안 표시됩니다. 스마트폰 키 또는 카드 키가 등록되지 않은 경우는 경고문이 표시되지 않습니다.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
InformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.0289 |
| cosine_accuracy@3 | 0.7364 |
| cosine_accuracy@5 | 0.8496 |
| cosine_accuracy@10 | 0.9306 |
| cosine_precision@1 | 0.0289 |
| cosine_precision@3 | 0.2455 |
| cosine_precision@5 | 0.1699 |
| cosine_precision@10 | 0.0931 |
| cosine_recall@1 | 0.0289 |
| cosine_recall@3 | 0.7364 |
| cosine_recall@5 | 0.8496 |
| cosine_recall@10 | 0.9306 |
| cosine_ndcg@10 | 0.5506 |
| cosine_mrr@10 | 0.422 |
| cosine_map@100 | 0.4249 |
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
상향등을 자동으로 끄기 위해서는 스위치를 어떻게 조작해야 하나요? |
전조등 사용 시 주의사항: • 상향등 사용은 다른 운전자의 시야를 방해할 수 있으므로, 마주오는 차가 있거나 앞차가 있을 경우 사용하지 마십시오. • 상향등을 자동으로 끄려면 스위치를 계기판 방향으로 밀어 중앙 위치로 원위치시키십시오. |
비상 경보 버튼을 얼마나 길게 눌러야 비상 경고등과 경보음이 작동합니까? |
비상경보(알람) 기능: 비상 경보 버튼을 1초 이상 길게 누르면 비상 경고등 및 경보음이 약 30초 동안 작동합니다. 스마트 키 버튼 중 하나를 누르면 작동이 멈춥니다. |
LPI 차량의 엔진 시동을 걸기 전에 어떤 과정을 통해 연료펌프가 작동하는지 설명하시오. |
LPI 차량: LPI 차량은 시동 전에 액화된 LPG를 엔진에 원활하게 공급하기 위해 일정한 압력이 형성되면 시동을 걸어야 합니다. 다음과 같이 하십시오. 5-1. 엔진 시동 스위치를 ‘ON’ 위치로 하면 계기판의 표시등이 켜진 후 꺼집니다. 단, 시동 스위치 ‘OFF’ 후 짧은 시간 내에 다시 ‘ON’ 위치로 돌렸을 때는 켜지지 않을 수도 있습니다. 약 1 |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
eval_strategy: stepsper_device_train_batch_size: 5per_device_eval_batch_size: 5num_train_epochs: 40fp16: Truemulti_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 5per_device_eval_batch_size: 5per_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: 40max_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: 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 | cosine_ndcg@10 |
|---|---|---|---|
| 0.4587 | 50 | - | 0.5775 |
| 0.9174 | 100 | - | 0.5777 |
| 1.0 | 109 | - | 0.5778 |
| 1.3761 | 150 | - | 0.5794 |
| 1.8349 | 200 | - | 0.5862 |
| 2.0 | 218 | - | 0.5854 |
| 2.2936 | 250 | - | 0.5846 |
| 2.7523 | 300 | - | 0.5861 |
| 3.0 | 327 | - | 0.5856 |
| 3.2110 | 350 | - | 0.5810 |
| 3.6697 | 400 | - | 0.5813 |
| 4.0 | 436 | - | 0.5859 |
| 4.1284 | 450 | - | 0.5867 |
| 4.5872 | 500 | 0.0692 | 0.5870 |
| 5.0 | 545 | - | 0.5823 |
| 5.0459 | 550 | - | 0.5829 |
| 5.5046 | 600 | - | 0.5870 |
| 5.9633 | 650 | - | 0.5849 |
| 6.0 | 654 | - | 0.5863 |
| 6.4220 | 700 | - | 0.5856 |
| 6.8807 | 750 | - | 0.5722 |
| 7.0 | 763 | - | 0.5774 |
| 7.3394 | 800 | - | 0.5855 |
| 7.7982 | 850 | - | 0.5781 |
| 8.0 | 872 | - | 0.5821 |
| 8.2569 | 900 | - | 0.5798 |
| 8.7156 | 950 | - | 0.5827 |
| 9.0 | 981 | - | 0.5778 |
| 9.1743 | 1000 | 0.023 | 0.5701 |
| 9.6330 | 1050 | - | 0.5830 |
| 10.0 | 1090 | - | 0.5805 |
| 10.0917 | 1100 | - | 0.5801 |
| 10.5505 | 1150 | - | 0.5832 |
| 11.0 | 1199 | - | 0.5832 |
| 11.0092 | 1200 | - | 0.5859 |
| 11.4679 | 1250 | - | 0.5707 |
| 11.9266 | 1300 | - | 0.5739 |
| 12.0 | 1308 | - | 0.5774 |
| 12.3853 | 1350 | - | 0.5790 |
| 12.8440 | 1400 | - | 0.5762 |
| 13.0 | 1417 | - | 0.5785 |
| 13.3028 | 1450 | - | 0.5735 |
| 13.7615 | 1500 | 0.0184 | 0.5716 |
| 14.0 | 1526 | - | 0.5817 |
| 14.2202 | 1550 | - | 0.5706 |
| 14.6789 | 1600 | - | 0.5720 |
| 15.0 | 1635 | - | 0.5729 |
| 15.1376 | 1650 | - | 0.5681 |
| 15.5963 | 1700 | - | 0.5725 |
| 16.0 | 1744 | - | 0.5720 |
| 16.0550 | 1750 | - | 0.5691 |
| 16.5138 | 1800 | - | 0.5644 |
| 16.9725 | 1850 | - | 0.5637 |
| 17.0 | 1853 | - | 0.5633 |
| 17.4312 | 1900 | - | 0.5662 |
| 17.8899 | 1950 | - | 0.5580 |
| 18.0 | 1962 | - | 0.5674 |
| 18.3486 | 2000 | 0.0151 | 0.5707 |
| 18.8073 | 2050 | - | 0.5681 |
| 19.0 | 2071 | - | 0.5747 |
| 19.2661 | 2100 | - | 0.5653 |
| 19.7248 | 2150 | - | 0.5561 |
| 20.0 | 2180 | - | 0.5582 |
| 20.1835 | 2200 | - | 0.5657 |
| 20.6422 | 2250 | - | 0.5654 |
| 21.0 | 2289 | - | 0.5645 |
| 21.1009 | 2300 | - | 0.5613 |
| 21.5596 | 2350 | - | 0.5668 |
| 22.0 | 2398 | - | 0.5652 |
| 22.0183 | 2400 | - | 0.5666 |
| 22.4771 | 2450 | - | 0.5656 |
| 22.9358 | 2500 | 0.012 | 0.5581 |
| 23.0 | 2507 | - | 0.5613 |
| 23.3945 | 2550 | - | 0.5638 |
| 23.8532 | 2600 | - | 0.5666 |
| 24.0 | 2616 | - | 0.5574 |
| 24.3119 | 2650 | - | 0.5620 |
| 24.7706 | 2700 | - | 0.5657 |
| 25.0 | 2725 | - | 0.5601 |
| 25.2294 | 2750 | - | 0.5612 |
| 25.6881 | 2800 | - | 0.5610 |
| 26.0 | 2834 | - | 0.5631 |
| 26.1468 | 2850 | - | 0.5578 |
| 26.6055 | 2900 | - | 0.5596 |
| 27.0 | 2943 | - | 0.5602 |
| 27.0642 | 2950 | - | 0.5547 |
| 27.5229 | 3000 | 0.0108 | 0.5567 |
| 27.9817 | 3050 | - | 0.5609 |
| 28.0 | 3052 | - | 0.5635 |
| 28.4404 | 3100 | - | 0.5630 |
| 28.8991 | 3150 | - | 0.5547 |
| 29.0 | 3161 | - | 0.5531 |
| 29.3578 | 3200 | - | 0.5602 |
| 29.8165 | 3250 | - | 0.5496 |
| 30.0 | 3270 | - | 0.5463 |
| 30.2752 | 3300 | - | 0.5580 |
| 30.7339 | 3350 | - | 0.5532 |
| 31.0 | 3379 | - | 0.5540 |
| 31.1927 | 3400 | - | 0.5529 |
| 31.6514 | 3450 | - | 0.5478 |
| 32.0 | 3488 | - | 0.5520 |
| 32.1101 | 3500 | 0.01 | 0.5543 |
| 32.5688 | 3550 | - | 0.5507 |
| 33.0 | 3597 | - | 0.5425 |
| 33.0275 | 3600 | - | 0.5463 |
| 33.4862 | 3650 | - | 0.5608 |
| 33.9450 | 3700 | - | 0.5464 |
| 34.0 | 3706 | - | 0.5518 |
| 34.4037 | 3750 | - | 0.5572 |
| 34.8624 | 3800 | - | 0.5571 |
| 35.0 | 3815 | - | 0.5517 |
| 35.3211 | 3850 | - | 0.5497 |
| 35.7798 | 3900 | - | 0.5540 |
| 36.0 | 3924 | - | 0.5483 |
| 36.2385 | 3950 | - | 0.5499 |
| 36.6972 | 4000 | 0.0107 | 0.5523 |
| 37.0 | 4033 | - | 0.5547 |
| 37.1560 | 4050 | - | 0.5488 |
| 37.6147 | 4100 | - | 0.5435 |
| 38.0 | 4142 | - | 0.5534 |
| 38.0734 | 4150 | - | 0.5511 |
| 38.5321 | 4200 | - | 0.5506 |
| 38.9908 | 4250 | - | 0.5467 |
| 39.0 | 4251 | - | 0.5485 |
| 39.4495 | 4300 | - | 0.5460 |
| 39.9083 | 4350 | - | 0.5469 |
| 40.0 | 4360 | - | 0.5506 |
@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-m3