Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
9
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': 512, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 768, '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})
)
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("Detomo/cl-nagoya-sup-simcse-ja-nss-v_1_0_6")
# Run inference
sentences = [
'科目:ユニット及びその他。名称:テラス床再生木デッキ。',
'科目:ユニット及びその他。名称:駐車ゾーンサイン。',
'科目:ユニット及びその他。名称:#階 MWC、WWC他姿見鏡。',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
sentence and label| sentence | label | |
|---|---|---|
| type | string | int |
| details |
|
|
| sentence | label |
|---|---|
科目:コンクリート。名称:免震基礎天端グラウト注入。 |
0 |
科目:コンクリート。名称:免震基礎天端グラウト注入。 |
0 |
科目:コンクリート。名称:免震基礎天端グラウト注入。 |
0 |
sentence_transformer_lib.custom_batch_all_trip_loss.CustomBatchAllTripletLossper_device_train_batch_size: 512per_device_eval_batch_size: 512learning_rate: 1e-05weight_decay: 0.01num_train_epochs: 250warmup_ratio: 0.2fp16: Truebatch_sampler: group_by_labeloverwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 512per_device_eval_batch_size: 512per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 1e-05weight_decay: 0.01adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 250max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.2warmup_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}tp_size: 0fsdp_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: group_by_labelmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss |
|---|---|---|
| 2.16 | 50 | 0.0584 |
| 4.32 | 100 | 0.0591 |
| 6.48 | 150 | 0.0675 |
| 8.64 | 200 | 0.0637 |
| 10.8 | 250 | 0.0637 |
| 13.04 | 300 | 0.0647 |
| 15.2 | 350 | 0.0656 |
| 17.36 | 400 | 0.0578 |
| 19.52 | 450 | 0.0585 |
| 21.68 | 500 | 0.0546 |
| 23.84 | 550 | 0.0523 |
| 26.08 | 600 | 0.0563 |
| 28.24 | 650 | 0.0526 |
| 30.4 | 700 | 0.0532 |
| 32.56 | 750 | 0.0546 |
| 34.72 | 800 | 0.0483 |
| 36.88 | 850 | 0.0566 |
| 39.12 | 900 | 0.0482 |
| 41.28 | 950 | 0.0508 |
| 43.44 | 1000 | 0.05 |
| 45.6 | 1050 | 0.0471 |
| 47.76 | 1100 | 0.0502 |
| 49.92 | 1150 | 0.0477 |
| 52.16 | 1200 | 0.0429 |
| 54.32 | 1250 | 0.0415 |
| 56.48 | 1300 | 0.0433 |
| 58.64 | 1350 | 0.0489 |
| 60.8 | 1400 | 0.0494 |
| 63.04 | 1450 | 0.0412 |
| 65.2 | 1500 | 0.0447 |
| 67.36 | 1550 | 0.0379 |
| 69.52 | 1600 | 0.0401 |
| 71.68 | 1650 | 0.0449 |
| 73.84 | 1700 | 0.0377 |
| 76.08 | 1750 | 0.0375 |
| 78.24 | 1800 | 0.0394 |
| 80.4 | 1850 | 0.0392 |
| 82.56 | 1900 | 0.0404 |
| 84.72 | 1950 | 0.0392 |
| 86.88 | 2000 | 0.0427 |
| 89.12 | 2050 | 0.0357 |
| 91.28 | 2100 | 0.0339 |
| 93.44 | 2150 | 0.0443 |
| 95.6 | 2200 | 0.0405 |
| 97.76 | 2250 | 0.0362 |
| 99.92 | 2300 | 0.0323 |
| 102.16 | 2350 | 0.0335 |
| 104.32 | 2400 | 0.0408 |
| 106.48 | 2450 | 0.034 |
| 108.64 | 2500 | 0.0383 |
| 110.8 | 2550 | 0.0299 |
| 113.04 | 2600 | 0.0306 |
| 115.2 | 2650 | 0.0351 |
| 117.36 | 2700 | 0.0322 |
| 119.52 | 2750 | 0.041 |
| 121.68 | 2800 | 0.0292 |
| 123.84 | 2850 | 0.027 |
| 126.08 | 2900 | 0.0323 |
| 128.24 | 2950 | 0.0355 |
| 130.4 | 3000 | 0.0366 |
| 132.56 | 3050 | 0.0312 |
| 134.72 | 3100 | 0.0279 |
| 136.88 | 3150 | 0.0306 |
| 139.12 | 3200 | 0.0245 |
| 141.28 | 3250 | 0.0325 |
| 143.44 | 3300 | 0.0356 |
| 145.6 | 3350 | 0.0362 |
| 147.76 | 3400 | 0.0287 |
| 149.92 | 3450 | 0.0339 |
| 1.6389 | 50 | 0.0386 |
| 3.5278 | 100 | 0.0366 |
| 5.4167 | 150 | 0.0364 |
| 7.3056 | 200 | 0.0394 |
| 9.1944 | 250 | 0.0387 |
| 11.0833 | 300 | 0.0407 |
| 12.7222 | 350 | 0.0392 |
| 14.6111 | 400 | 0.0395 |
| 16.5 | 450 | 0.0393 |
| 18.3889 | 500 | 0.0361 |
| 20.2778 | 550 | 0.0347 |
| 22.1667 | 600 | 0.0346 |
| 24.0556 | 650 | 0.0371 |
| 25.6944 | 700 | 0.0411 |
| 27.5833 | 750 | 0.0329 |
| 29.4722 | 800 | 0.0337 |
| 31.3611 | 850 | 0.0325 |
| 33.25 | 900 | 0.034 |
| 35.1389 | 950 | 0.0352 |
| 37.0278 | 1000 | 0.0305 |
| 38.6667 | 1050 | 0.0311 |
| 40.5556 | 1100 | 0.0314 |
| 42.4444 | 1150 | 0.0307 |
| 44.3333 | 1200 | 0.0324 |
| 46.2222 | 1250 | 0.0355 |
| 48.1111 | 1300 | 0.0306 |
| 49.75 | 1350 | 0.027 |
| 51.6389 | 1400 | 0.0282 |
| 53.5278 | 1450 | 0.0318 |
| 55.4167 | 1500 | 0.0314 |
| 57.3056 | 1550 | 0.0323 |
| 59.1944 | 1600 | 0.0286 |
| 61.0833 | 1650 | 0.0338 |
| 62.7222 | 1700 | 0.0287 |
| 64.6111 | 1750 | 0.0309 |
| 66.5 | 1800 | 0.0287 |
| 68.3889 | 1850 | 0.028 |
| 70.2778 | 1900 | 0.026 |
| 72.1667 | 1950 | 0.0269 |
| 74.0556 | 2000 | 0.0295 |
| 75.6944 | 2050 | 0.0257 |
| 77.5833 | 2100 | 0.0261 |
| 79.4722 | 2150 | 0.0304 |
| 81.3611 | 2200 | 0.0265 |
| 83.25 | 2250 | 0.0274 |
| 85.1389 | 2300 | 0.0276 |
| 87.0278 | 2350 | 0.0325 |
| 88.6667 | 2400 | 0.0233 |
| 90.5556 | 2450 | 0.0212 |
| 92.4444 | 2500 | 0.0243 |
| 94.3333 | 2550 | 0.0288 |
| 96.2222 | 2600 | 0.026 |
| 98.1111 | 2650 | 0.029 |
| 99.75 | 2700 | 0.0228 |
| 101.6389 | 2750 | 0.0265 |
| 103.5278 | 2800 | 0.017 |
| 105.4167 | 2850 | 0.026 |
| 107.3056 | 2900 | 0.0257 |
| 109.1944 | 2950 | 0.0237 |
| 111.0833 | 3000 | 0.0261 |
| 112.7222 | 3050 | 0.0204 |
| 114.6111 | 3100 | 0.0186 |
| 116.5 | 3150 | 0.0206 |
| 118.3889 | 3200 | 0.0233 |
| 120.2778 | 3250 | 0.0235 |
| 122.1667 | 3300 | 0.0232 |
| 124.0556 | 3350 | 0.0194 |
| 125.6944 | 3400 | 0.0242 |
| 127.5833 | 3450 | 0.0234 |
| 129.4722 | 3500 | 0.023 |
| 131.3611 | 3550 | 0.0187 |
| 133.25 | 3600 | 0.0208 |
| 135.1389 | 3650 | 0.0201 |
| 137.0278 | 3700 | 0.024 |
| 138.6667 | 3750 | 0.0255 |
| 140.5556 | 3800 | 0.0201 |
| 142.4444 | 3850 | 0.0231 |
| 144.3333 | 3900 | 0.0199 |
| 146.2222 | 3950 | 0.018 |
| 148.1111 | 4000 | 0.0228 |
| 149.75 | 4050 | 0.0204 |
| 151.6389 | 4100 | 0.025 |
| 153.5278 | 4150 | 0.0163 |
| 155.4167 | 4200 | 0.0157 |
| 157.3056 | 4250 | 0.0189 |
| 159.1944 | 4300 | 0.0176 |
| 161.0833 | 4350 | 0.03 |
| 162.7222 | 4400 | 0.0197 |
| 164.6111 | 4450 | 0.0207 |
| 166.5 | 4500 | 0.0189 |
| 168.3889 | 4550 | 0.0132 |
| 170.2778 | 4600 | 0.0178 |
| 172.1667 | 4650 | 0.0216 |
| 174.0556 | 4700 | 0.0174 |
| 175.6944 | 4750 | 0.0229 |
| 177.5833 | 4800 | 0.0181 |
| 179.4722 | 4850 | 0.0161 |
| 181.3611 | 4900 | 0.0236 |
| 183.25 | 4950 | 0.0185 |
| 185.1389 | 5000 | 0.02 |
| 187.0278 | 5050 | 0.0147 |
| 188.6667 | 5100 | 0.0203 |
| 190.5556 | 5150 | 0.0159 |
| 192.4444 | 5200 | 0.0133 |
| 194.3333 | 5250 | 0.0192 |
| 196.2222 | 5300 | 0.0162 |
| 198.1111 | 5350 | 0.0183 |
| 199.75 | 5400 | 0.015 |
| 201.6389 | 5450 | 0.0145 |
| 203.5278 | 5500 | 0.017 |
| 205.4167 | 5550 | 0.0219 |
| 207.3056 | 5600 | 0.0195 |
| 209.1944 | 5650 | 0.0186 |
| 211.0833 | 5700 | 0.0142 |
| 212.7222 | 5750 | 0.0191 |
| 214.6111 | 5800 | 0.0167 |
| 216.5 | 5850 | 0.013 |
| 218.3889 | 5900 | 0.0154 |
| 220.2778 | 5950 | 0.0135 |
| 222.1667 | 6000 | 0.0139 |
| 224.0556 | 6050 | 0.0203 |
| 225.6944 | 6100 | 0.0169 |
| 227.5833 | 6150 | 0.0146 |
| 229.4722 | 6200 | 0.0206 |
| 231.3611 | 6250 | 0.0149 |
| 233.25 | 6300 | 0.014 |
| 235.1389 | 6350 | 0.0174 |
| 237.0278 | 6400 | 0.0191 |
| 238.6667 | 6450 | 0.0137 |
| 240.5556 | 6500 | 0.0125 |
| 242.4444 | 6550 | 0.0081 |
| 244.3333 | 6600 | 0.0145 |
| 246.2222 | 6650 | 0.0116 |
| 248.1111 | 6700 | 0.0154 |
| 249.75 | 6750 | 0.0179 |
@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{hermans2017defense,
title={In Defense of the Triplet Loss for Person Re-Identification},
author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
year={2017},
eprint={1703.07737},
archivePrefix={arXiv},
primaryClass={cs.CV}
}