Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 13
How to use JLee0/rag-embedder-grand-30epochs with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("JLee0/rag-embedder-grand-30epochs")
sentences = [
"후석 승객 알림 시스템에서 뒷좌석 도어의 열림과 닫힘 기록은 언제 초기화되나요?",
"빌트인 캠 녹화 해제 조건\n• 주차 중 녹화 기능이 설정되어 있으나 주차\n녹화 설정 시간이 초과된 경우\n• 주차 중 녹화 기능이 설정되어 있으나 12 V\n리튬 보조 배터리 충전량이 부족한 경우\n• SD 메모리 수명이 다했거나 고장으로 녹화\n를 할 수 없는 경우\n주차 중 녹화 종료 휴대폰 알림\n• 주차 중 녹화가 작동 중 녹화 해제 조건에 의\n해 녹화가 종료되는 경우에 블루링크 앱으로\n녹화 종료를 알립니다.\n• 주차 중 녹화 종료 휴대폰 알림은 블루링크\n서비스에 가입한 경우에만 사용할 수 있습니\n다.\n• 정품 12 V 리튬 보조 배터리를 장착해야만 빌\n트인 캠 주차 중 녹화 기능을 사용할 수 있습\n니다.",
"후석 승객 알림 시스템\n뒷좌석에 탑승자를 두고 내리는 것을 방지하기\n위한 시스템입니다.\n시스템 설정\n클러스터 내 사용자 설정 모드에서 편의 > 후석\n승객 알림 기능을 설정 또는 해제할 수 있습니\n다.\n내비게이션 사양의 경우 별도로 지급되는 인포\n테인먼트 시스템 간편 설명서의 QR 코드로 웹\n에 접속하여 설정 방법을 확인할 수 있습니다.\n• 알림\n뒷좌석 도어를 열고 닫은 후에 시동을 끄고\n운전석 도어를 열면, 클러스터에 \"뒷좌석 탑\n승자 또는 소지품을 확인하십시오\" 경고문\n이 표시됩니다. \n\n 후석 승객 알림 시스템은 뒷좌석 도어를 열고\n닫았을 때 운전자에게 뒷좌석을 확인하도록 정\n보를 주지만 실제로 뒷좌석에 물건 또는 탑승자\n가 있는지 감지할 수 없습니다. 차량에서 내릴\n때는 항상 뒷좌석에 탑승자가 있는지 확인하시\n기 바랍니다.\n뒷좌석 도어가 열리고 닫힌 기록은 운전자가 시\n동을 끄고 차량 도어를 잠그는 경우 초기화됩니\n다. 뒷좌석 도어가 다시 열리지 않았더라도, 이\n전 기록이 남아 있는 경우 알림이 발생할 수 있\n습니다. 예를 들어 후석 승객 알림 발생 후 운전\n자가 차량 도어를 잠그지 않고 다시 도어를 열\n고 내리는 경우 알림이 다시 발생할 수 있습니다.",
"선루프 열림 경고\n선루프 글라스가 완전히 닫히지 않은 상태에서\n시동을 끄면 클러스터에 경고문이 표시되고,\n경고음이 수초 동안 울립니다. 차에서 떠날 때\n는 반드시 글라스를 완전히 닫으십시오.\n차에서 내릴 때는 반드시 선루프 글라스를 완전\n히 닫으십시오. 그렇지 않을 경우 비나 눈이 실\n내에 들어올 수 있으며 도난의 위험도 있습니\n다."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]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 = [
'차량 외관 점검 시 완충 스프링과 관련하여 어떤 점을 확인해야 하나요?',
'일상 점검\n일상 점검이란 운전자가 매번 차량을 운전하기 전에 행하는 점검입니다. 안전 운전에 필수인 최소한\n의 점검이며 의무이니 반드시 실시하십시오. \n\n 이상 유무 확인 : • 전일 운전 시 이상이 있던 부분은 정상인가\n엔진룸-엔진 : • 시동이 잘 걸리고 연료, 냉각수가 충분한가 • 누수, 누유가 없는가 • 구동 벨트의 장력은 적당하고 손상된 곳은 없는가\n엔진룸-기타 : • 브레이크 오일, 워셔액이 충분하고 누유는 없는가\n차량 외관-엔진 : • 배기가스의 색이 깨끗하고 유독가스 매연의 배출이 없는가\n차량 외관-완충 스프링 : • 스프링의 연결 부위에 손상이나 균열이 없는가\n차량 외관-변속기 : • 누유는 없는가\n차량 외관-램프 : • 깜빡임이 확실하고 파손되지 않았는가\n차량 외관-차량 번호판 : • 번호판이 파손되지 않았는가\n운전석-엔진 : • 연료가 충분하고 시동이 잘 걸리는가\n운전석-스티어링 휠 : • 흔들림이나 움직임이 없는가 조작이 수월한가\n운전석-브레이크 : • 페달의 유격과 자유간극이 적당한가 • 브레이크의 작동이 양호한가 • 주차 브레이크가 정상적으로 작동하는가\n운전석-변속기 : • 변속 다이얼 조작이 용이한가 • 심한 진동은 없는가\n운전석-실외 미러/실내 미러 : • 비침 상태가 양호한가\n운전석-경음기 : • 작동이 양호한가\n운전석-와이퍼 : • 작동이 양호하고 워셔액이 충분한가\n운전석-각종 계기 및 스위치 : • 작동이 양호한가',
"경고 방식\n경고 방식은 시동 'ON' 상태에서 설정할 수 있\n습니다.\n• 경고 음량: 인포테인먼트 시스템의 설정 > 차\n량 > 운전자 보조 > 경고 방식 > 경고 음량에\n서 변경할 수 있습니다.\n경고 음량을 ‘0’으로 변경해도 경고음은 ‘1’\n로 설정했을 때의 음량으로 울립니다(사양\n적용 시).\n• 핸들 진동 경고: 인포테인먼트 시스템의 설\n정 > 차량 > 운전자 보조 > 경고 방식 > 핸들\n진동 경고에서 설정할 수 있습니다(사양 적\n용 시).\n• 주행 안전 우선: 인포테인먼트 시스템의 설\n정 > 차량 > 운전자 보조 > 경고 방식 > 주행\n안전 우선을 설정하면 안전한 주행을 위하여\n경고음 발생 시 오디오 음량을 줄입니다.\n• 경고 방식을 변경하면 다른 운전자 보조 시\n스템의 경고 방식도 같이 변경될 수 있습니\n다. 고려하여 변경하십시오.\n• 경고 음량이 '0'인 상태에서 핸들 진동 경고\n를 해제하면, 경고 음량이 활성화 되며 '2'로\n설정 됩니다.\n• 핸들 진동 경고가 해제된 상태에서 경고 음\n량을 '0'으로 조절하면, 핸들 진동 경고가 활\n성화 됩니다.\n• 시동을 껐다가 걸어도 경고 방식 설정은 유\n지됩니다.\n• 차량 사양에 따라 설정 메뉴가 없을 수 있습\n니다.",
]
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.0367 |
| cosine_accuracy@3 | 0.7007 |
| cosine_accuracy@5 | 0.8256 |
| cosine_accuracy@10 | 0.9204 |
| cosine_precision@1 | 0.0367 |
| cosine_precision@3 | 0.2336 |
| cosine_precision@5 | 0.1651 |
| cosine_precision@10 | 0.092 |
| cosine_recall@1 | 0.0367 |
| cosine_recall@3 | 0.7007 |
| cosine_recall@5 | 0.8256 |
| cosine_recall@10 | 0.9204 |
| cosine_ndcg@10 | 0.5401 |
| cosine_mrr@10 | 0.4125 |
| cosine_map@100 | 0.416 |
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
차량 배터리가 저전압 상태일 때 운전석 도어의 자동 비상 모드 작동 시 어떤 소리가 날 수 있나요? |
• 차량 배터리의 전압이 떨어지면 운전석 도어 |
승객 구분 시스템이 있는 차량에서 특정 조건에서 동승석 에어백이 작동하지 않는 이유는 무엇인가요? |
어드밴스드 에어백 (Advanced Air Bag) |
가솔린 연료의 용량은 몇 리터입니까? |
연료 |
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: 30fp16: 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: 30max_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.6173 | 50 | - | 0.5761 |
| 1.0 | 81 | - | 0.5703 |
| 1.2346 | 100 | - | 0.5723 |
| 1.8519 | 150 | - | 0.5772 |
| 2.0 | 162 | - | 0.5784 |
| 2.4691 | 200 | - | 0.5743 |
| 3.0 | 243 | - | 0.5768 |
| 3.0864 | 250 | - | 0.5765 |
| 3.7037 | 300 | - | 0.5763 |
| 4.0 | 324 | - | 0.5769 |
| 4.3210 | 350 | - | 0.5753 |
| 4.9383 | 400 | - | 0.5633 |
| 5.0 | 405 | - | 0.5644 |
| 5.5556 | 450 | - | 0.5652 |
| 6.0 | 486 | - | 0.5759 |
| 6.1728 | 500 | 0.0707 | 0.5724 |
| 6.7901 | 550 | - | 0.5693 |
| 7.0 | 567 | - | 0.5712 |
| 7.4074 | 600 | - | 0.5686 |
| 8.0 | 648 | - | 0.5667 |
| 8.0247 | 650 | - | 0.5684 |
| 8.6420 | 700 | - | 0.5637 |
| 9.0 | 729 | - | 0.5628 |
| 9.2593 | 750 | - | 0.5616 |
| 9.8765 | 800 | - | 0.5659 |
| 10.0 | 810 | - | 0.5626 |
| 10.4938 | 850 | - | 0.5630 |
| 11.0 | 891 | - | 0.5667 |
| 11.1111 | 900 | - | 0.5599 |
| 11.7284 | 950 | - | 0.5563 |
| 12.0 | 972 | - | 0.5469 |
| 12.3457 | 1000 | 0.0272 | 0.5535 |
| 12.9630 | 1050 | - | 0.5436 |
| 13.0 | 1053 | - | 0.5458 |
| 13.5802 | 1100 | - | 0.5518 |
| 14.0 | 1134 | - | 0.5547 |
| 14.1975 | 1150 | - | 0.5522 |
| 14.8148 | 1200 | - | 0.5479 |
| 15.0 | 1215 | - | 0.5521 |
| 15.4321 | 1250 | - | 0.5504 |
| 16.0 | 1296 | - | 0.5510 |
| 16.0494 | 1300 | - | 0.5492 |
| 16.6667 | 1350 | - | 0.5509 |
| 17.0 | 1377 | - | 0.5583 |
| 17.2840 | 1400 | - | 0.5451 |
| 17.9012 | 1450 | - | 0.5560 |
| 18.0 | 1458 | - | 0.5521 |
| 18.5185 | 1500 | 0.0163 | 0.5424 |
| 19.0 | 1539 | - | 0.5579 |
| 19.1358 | 1550 | - | 0.5489 |
| 19.7531 | 1600 | - | 0.5389 |
| 20.0 | 1620 | - | 0.5410 |
| 20.3704 | 1650 | - | 0.5326 |
| 20.9877 | 1700 | - | 0.5427 |
| 21.0 | 1701 | - | 0.5430 |
| 21.6049 | 1750 | - | 0.5446 |
| 22.0 | 1782 | - | 0.5488 |
| 22.2222 | 1800 | - | 0.5429 |
| 22.8395 | 1850 | - | 0.5464 |
| 23.0 | 1863 | - | 0.5441 |
| 23.4568 | 1900 | - | 0.5478 |
| 24.0 | 1944 | - | 0.5417 |
| 24.0741 | 1950 | - | 0.5380 |
| 24.6914 | 2000 | 0.0162 | 0.5386 |
| 25.0 | 2025 | - | 0.5428 |
| 25.3086 | 2050 | - | 0.5397 |
| 25.9259 | 2100 | - | 0.5436 |
| 26.0 | 2106 | - | 0.5429 |
| 26.5432 | 2150 | - | 0.5427 |
| 27.0 | 2187 | - | 0.5335 |
| 27.1605 | 2200 | - | 0.5306 |
| 27.7778 | 2250 | - | 0.5333 |
| 28.0 | 2268 | - | 0.5333 |
| 28.3951 | 2300 | - | 0.5447 |
| 29.0 | 2349 | - | 0.5419 |
| 29.0123 | 2350 | - | 0.5413 |
| 29.6296 | 2400 | - | 0.5485 |
| 30.0 | 2430 | - | 0.5401 |
@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