Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 13
How to use JLee0/rag-embedder-staria-20epochs with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("JLee0/rag-embedder-staria-20epochs")
sentences = [
"스마트 키의 비상경보 기능을 활성화하려면 어떻게 해야 하나요?",
"경고: • 좌석이 작동 중일 때에 신체나 물건이 끼이지 않도록 주의하십시오. • 프리미엄 릴렉션 좌석 및 레그레스트(종아리 지지대)가 작동된 상태에서 충돌 시 부상의 위험이 증가할 수 있으므로 가급적 주정차 시 또는 휴식 중일 때만 사용하십시오. • 안전벨트를 착용한 채로 좌석을 작동할 경우 가슴 쪽 안전벨트가 몸에 완전히 밀착되지 않을 수 있으므로 가급적 주정차 시 또는 휴식 중일 때만 사용하십시오.",
"스마트 키 사용 방법: 스마트 키는 휴대만으로 도어(테일게이트 포함)를 잠그거나 열고, 엔진 시동을 걸 수 있도록 고안된 장치입니다. • 도어 잠금 버튼: 앞좌석 도어의 바깥 손잡이에 있는 버튼을 누르면 도어가 잠깁니다. • 도어 잠금 해제 버튼: 도어 잠금 해제 버튼을 누르면 도어가 잠금 해제됩니다. • 비상경보(알람): 비상경보 버튼을 길게 누르면 경고등 및 경고음이 작동합니다. • 원격 시동 버튼(사양 적용 시): 원격으로 엔진 시동을 걸 수 있습니다. • 파워 테일게이트 열림/닫힘 버튼(사양 적용 시): 테일게이트를 열거나 닫을 수 있습니다. • 파워 슬라이딩 도어 열림/닫힘: 슬라이딩 도어를 열거나 닫을 수 있습니다.터치 타입 도어 잠금 방법: • 모든 도어를 닫은 후 스마트 키를 휴대하고 앞좌석 도어의 바깥손잡이에 도어 잠금 센서부(음각 부분)를 약 1초 동안 터치하십시오. • 도어가 잠김 상태가 되며, 비상 경고등이 1회 깜빡이고 알림음이 울립니다. • 차량 내 설정 메뉴에서 실외 미러 자동 접힘 기능을 선택하면 실외 미러도 동시에 접힙니다. • 도어 잠금/잠금 해제 장치는 스마트 키가 앞좌석 도어의 바깥 손잡이와 70~100 cm 이내의 거리에 있어야 감지되어 작동합니다. • 바깥 손잡이에서 도어를 잠그면, 바깥 손잡이에서 3초 동안은 도어를 잠금 해제할 수 없습니다.",
"경 고 가파르거나 긴 내리막길을 내려올 때 브레이크 페달을 계속 밟으면 브레이크가 과열되어 브레이크 제동력의 급격한 저하를 일으킬 수 있으므로 저단 기어를 사용하거나 속도를 서서히 줄이면서 차례대로 저단으로 변속하는 엔진 브레이크를 함께 사용하여 속도를 줄이십시오 브레이크 장치가 젖을 정도로 깊은 물이 있는 곳을 주행하는 것은 정상적인 브레이크 작동을 방해합니다 브레이크 장치가 젖어 제동 효과가 떨어졌을 때는 안전거리를 유지한 상태에서 정상적으로 브레이크가 작동될 때까지 여러 차례 가볍게 브레이크 페달을 밟아 브레이크를 건조하십시오"
]
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 = [
'ELR(Emergency Locking Retractor) 3점식 안전벨트는 어떤 상황에서 작동하여 안전벨트를 고정하게 되나요?',
'3점식 안전벨트: • ELR(Emergency Locking Retractor): 모든 좌석에는 ELR 3점식 안전벨트가 장착되어 있습니다. 정상 주행 중에는 안전벨트를 착용해도 어느 정도 움직일 수 있고, 급정차, 급회전, 충돌과 같은 갑작스러운 변화가 발생하면 관성 잠금 장치가 작동해 안전벨트를 고정합니다.',
'사이드 에어백: 사이드 에어백은 앞좌석 바깥쪽에 내장되어 있습니다. 에어백 작동 조건(측면 충돌, 전복 사고 등)에 해당하면 탑승자의 측면을 보호하기 위해 작동합니다. 앞좌석 센터 에어백은 운전석 오른쪽에 내장되어 있습니다. 사고가 났을 때 운전자와 동승자가 부딪히는 것을 방지하고 차량 내장 부품과의 충돌도 줄이기 위해 작동합니다.',
]
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.0256 |
| cosine_accuracy@3 | 0.7926 |
| cosine_accuracy@5 | 0.8917 |
| cosine_accuracy@10 | 0.9645 |
| cosine_precision@1 | 0.0256 |
| cosine_precision@3 | 0.2642 |
| cosine_precision@5 | 0.1783 |
| cosine_precision@10 | 0.0964 |
| cosine_recall@1 | 0.0256 |
| cosine_recall@3 | 0.7926 |
| cosine_recall@5 | 0.8917 |
| cosine_recall@10 | 0.9645 |
| cosine_ndcg@10 | 0.5756 |
| cosine_mrr@10 | 0.4433 |
| cosine_map@100 | 0.4449 |
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
좌석을 작동할 때 안전벨트를 착용하면 어떤 문제가 발생할 수 있나요? |
경고: • 좌석이 작동 중일 때에 신체나 물건이 끼이지 않도록 주의하십시오. • 프리미엄 릴렉션 좌석 및 레그레스트(종아리 지지대)가 작동된 상태에서 충돌 시 부상의 위험이 증가할 수 있으므로 가급적 주정차 시 또는 휴식 중일 때만 사용하십시오. • 안전벨트를 착용한 채로 좌석을 작동할 경우 가슴 쪽 안전벨트가 몸에 완전히 밀착되지 않을 수 있으므로 가급적 주정차 시 또는 휴식 중일 때만 사용하십시오. |
타임랩스 녹화 중 버튼 표시등의 깜빡임 주기는 몇 초인가요? |
빌트인 캠 수동 녹화 및 표시등: • 빌트인 캠 수동 녹화 버튼을 통해 운전자가 원하는 시점의 영상을 저장할 수 있습니다. • 표시등이 켜짐, 깜빡임 등의 상태로 작동 상태를 알려줍니다. 상시 저장은 버튼 표시등 켜짐. 수동 버튼 이벤트 녹화 중은 버튼 표시등 깜빡임 (1초 주기). 충격 감지 이벤트 녹화 중은 버튼 표시등 깜빡임 (1초 주기.) 타임랩스 녹화 중은 버튼 표시등 깜빡임 (2초 주기) • 타임랩스 녹화는 최대 20분/40분/100분 동안 저장 가능합니다. |
경음기의 작동영역에 대해 주의해야 하는 이유는 무엇인가요? |
경음기: 경음기의 작동영역을 누르면 경적음이 납니다. 과도한 사용은 피하고, 강한 힘으로 누르지 마십시오. 경음기를 주먹으로 내려치거나 뾰족한 물체로 누르는 경우 오작동할 수 있습니다. 주의사항: 경음기 작동 영역을 정확히 숙지하여 필요한 순간에 사용할 수 있도록 하십시오. |
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: 20fp16: 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: 20max_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.5800 |
| 1.0 | 109 | - | 0.5788 |
| 1.3761 | 150 | - | 0.5807 |
| 1.8349 | 200 | - | 0.5892 |
| 2.0 | 218 | - | 0.5856 |
| 2.2936 | 250 | - | 0.5838 |
| 2.7523 | 300 | - | 0.5862 |
| 3.0 | 327 | - | 0.5887 |
| 3.2110 | 350 | - | 0.5822 |
| 3.6697 | 400 | - | 0.5953 |
| 4.0 | 436 | - | 0.5902 |
| 4.1284 | 450 | - | 0.5924 |
| 4.5872 | 500 | 0.0556 | 0.5794 |
| 5.0 | 545 | - | 0.5848 |
| 5.0459 | 550 | - | 0.5841 |
| 5.5046 | 600 | - | 0.5831 |
| 5.9633 | 650 | - | 0.5766 |
| 6.0 | 654 | - | 0.5798 |
| 6.4220 | 700 | - | 0.5717 |
| 6.8807 | 750 | - | 0.5770 |
| 7.0 | 763 | - | 0.5767 |
| 7.3394 | 800 | - | 0.5708 |
| 7.7982 | 850 | - | 0.5774 |
| 8.0 | 872 | - | 0.5756 |
| 8.2569 | 900 | - | 0.5805 |
| 8.7156 | 950 | - | 0.5863 |
| 9.0 | 981 | - | 0.5757 |
| 9.1743 | 1000 | 0.0244 | 0.5751 |
| 9.6330 | 1050 | - | 0.5712 |
| 10.0 | 1090 | - | 0.5810 |
| 10.0917 | 1100 | - | 0.5711 |
| 10.5505 | 1150 | - | 0.5741 |
| 11.0 | 1199 | - | 0.5805 |
| 11.0092 | 1200 | - | 0.5797 |
| 11.4679 | 1250 | - | 0.5791 |
| 11.9266 | 1300 | - | 0.5817 |
| 12.0 | 1308 | - | 0.5764 |
| 12.3853 | 1350 | - | 0.5694 |
| 12.8440 | 1400 | - | 0.5818 |
| 13.0 | 1417 | - | 0.5811 |
| 13.3028 | 1450 | - | 0.5773 |
| 13.7615 | 1500 | 0.0183 | 0.5747 |
| 14.0 | 1526 | - | 0.5679 |
| 14.2202 | 1550 | - | 0.5771 |
| 14.6789 | 1600 | - | 0.5764 |
| 15.0 | 1635 | - | 0.5618 |
| 15.1376 | 1650 | - | 0.5701 |
| 15.5963 | 1700 | - | 0.5692 |
| 16.0 | 1744 | - | 0.5698 |
| 16.0550 | 1750 | - | 0.5678 |
| 16.5138 | 1800 | - | 0.5697 |
| 16.9725 | 1850 | - | 0.5696 |
| 17.0 | 1853 | - | 0.5699 |
| 17.4312 | 1900 | - | 0.5763 |
| 17.8899 | 1950 | - | 0.5720 |
| 18.0 | 1962 | - | 0.5695 |
| 18.3486 | 2000 | 0.0127 | 0.5695 |
| 18.8073 | 2050 | - | 0.5721 |
| 19.0 | 2071 | - | 0.5737 |
| 19.2661 | 2100 | - | 0.5662 |
| 19.7248 | 2150 | - | 0.5705 |
| 20.0 | 2180 | - | 0.5756 |
@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