Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 12
This is a sentence-transformers model finetuned from cl-nagoya/sup-simcse-ja-base. 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-for-standard-name-v0_9_6")
# Run inference
sentences = [
'科目:タイル。名称:床磁器質タイル。',
'科目:ユニット及びその他。名称:#救助袋サイン(ガラス面)。',
'科目:ユニット及びその他。名称:案内スタンドサイン。',
]
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 |
科目:コンクリート。名称:コンクリートポンプ圧送。 |
1 |
BatchAllTripletLossper_device_train_batch_size: 512per_device_eval_batch_size: 512learning_rate: 1e-05weight_decay: 0.01num_train_epochs: 500warmup_ratio: 0.1fp16: 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: 500max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_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: Nonedispatch_batches: Nonesplit_batches: 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.8889 | 50 | 0.7963 |
| 5.8333 | 100 | 0.7067 |
| 8.7778 | 150 | 0.6532 |
| 11.7222 | 200 | 0.6806 |
| 14.6667 | 250 | 0.652 |
| 17.6111 | 300 | 0.6508 |
| 20.5556 | 350 | 0.6566 |
| 23.5 | 400 | 0.6237 |
| 26.4444 | 450 | 0.6363 |
| 29.3889 | 500 | 0.6554 |
| 32.3333 | 550 | 0.6007 |
| 35.2778 | 600 | 0.6016 |
| 38.2222 | 650 | 0.5687 |
| 2.8889 | 50 | 0.5655 |
| 5.8333 | 100 | 0.6139 |
| 8.7778 | 150 | 0.514 |
| 11.7222 | 200 | 0.5867 |
| 14.6667 | 250 | 0.5699 |
| 17.6111 | 300 | 0.5472 |
| 20.5556 | 350 | 0.5793 |
| 23.5 | 400 | 0.5196 |
| 26.4444 | 450 | 0.5572 |
| 29.3889 | 500 | 0.5279 |
| 32.3333 | 550 | 0.5095 |
| 35.2778 | 600 | 0.4488 |
| 38.2222 | 650 | 0.4189 |
| 41.1667 | 700 | 0.5164 |
| 44.1111 | 750 | 0.591 |
| 47.0556 | 800 | 0.52 |
| 49.9444 | 850 | 0.5235 |
| 52.8889 | 900 | 0.5317 |
| 55.8333 | 950 | 0.5517 |
| 58.7778 | 1000 | 0.5618 |
| 61.7222 | 1050 | 0.5318 |
| 64.6667 | 1100 | 0.4685 |
| 67.6111 | 1150 | 0.4836 |
| 70.5556 | 1200 | 0.5426 |
| 73.5 | 1250 | 0.5356 |
| 76.4444 | 1300 | 0.4231 |
| 79.3889 | 1350 | 0.5104 |
| 82.3333 | 1400 | 0.4944 |
| 85.2778 | 1450 | 0.5301 |
| 88.2222 | 1500 | 0.4499 |
| 91.1667 | 1550 | 0.4745 |
| 94.1111 | 1600 | 0.4432 |
| 97.0556 | 1650 | 0.3892 |
| 99.9444 | 1700 | 0.4429 |
| 102.8889 | 1750 | 0.4973 |
| 105.8333 | 1800 | 0.5222 |
| 108.7778 | 1850 | 0.4502 |
| 111.7222 | 1900 | 0.4073 |
| 114.6667 | 1950 | 0.408 |
| 117.6111 | 2000 | 0.403 |
| 120.5556 | 2050 | 0.4122 |
| 123.5 | 2100 | 0.4357 |
| 126.4444 | 2150 | 0.4765 |
| 129.3889 | 2200 | 0.4069 |
| 132.3333 | 2250 | 0.388 |
| 135.2778 | 2300 | 0.341 |
| 138.2222 | 2350 | 0.333 |
| 141.1667 | 2400 | 0.4587 |
| 144.1111 | 2450 | 0.355 |
| 147.0556 | 2500 | 0.3552 |
| 149.9444 | 2550 | 0.3804 |
| 152.8889 | 2600 | 0.3692 |
| 155.8333 | 2650 | 0.3367 |
| 158.7778 | 2700 | 0.3662 |
| 161.7222 | 2750 | 0.3089 |
| 164.6667 | 2800 | 0.3016 |
| 167.6111 | 2850 | 0.3252 |
| 170.5556 | 2900 | 0.3409 |
| 173.5 | 2950 | 0.3128 |
| 176.4444 | 3000 | 0.3287 |
| 179.3889 | 3050 | 0.3148 |
| 182.3333 | 3100 | 0.3843 |
| 185.2778 | 3150 | 0.2281 |
| 188.2222 | 3200 | 0.2973 |
| 191.1667 | 3250 | 0.2891 |
| 194.1111 | 3300 | 0.3623 |
| 197.0556 | 3350 | 0.3626 |
| 199.9444 | 3400 | 0.2931 |
| 202.8889 | 3450 | 0.2755 |
| 205.8333 | 3500 | 0.2849 |
| 208.7778 | 3550 | 0.2608 |
| 211.7222 | 3600 | 0.3081 |
| 214.6667 | 3650 | 0.2724 |
| 217.6111 | 3700 | 0.2583 |
| 220.5556 | 3750 | 0.3132 |
| 223.5 | 3800 | 0.196 |
| 226.4444 | 3850 | 0.2554 |
| 229.3889 | 3900 | 0.2 |
| 232.3333 | 3950 | 0.2936 |
| 235.2778 | 4000 | 0.2326 |
| 238.2222 | 4050 | 0.2031 |
| 241.1667 | 4100 | 0.2492 |
| 244.1111 | 4150 | 0.2234 |
| 247.0556 | 4200 | 0.3034 |
| 249.9444 | 4250 | 0.2325 |
| 252.8889 | 4300 | 0.2453 |
| 255.8333 | 4350 | 0.2848 |
| 258.7778 | 4400 | 0.2447 |
| 261.7222 | 4450 | 0.2599 |
| 264.6667 | 4500 | 0.2073 |
| 267.6111 | 4550 | 0.2134 |
| 270.5556 | 4600 | 0.1886 |
| 273.5 | 4650 | 0.1229 |
| 276.4444 | 4700 | 0.2147 |
| 279.3889 | 4750 | 0.1993 |
| 282.3333 | 4800 | 0.1814 |
| 285.2778 | 4850 | 0.202 |
| 288.2222 | 4900 | 0.1947 |
| 291.1667 | 4950 | 0.14 |
| 294.1111 | 5000 | 0.2394 |
| 297.0556 | 5050 | 0.1798 |
| 299.9444 | 5100 | 0.1534 |
| 302.8889 | 5150 | 0.2622 |
| 305.8333 | 5200 | 0.1636 |
| 308.7778 | 5250 | 0.1966 |
| 311.7222 | 5300 | 0.1365 |
| 314.6667 | 5350 | 0.1501 |
| 317.6111 | 5400 | 0.1494 |
| 320.5556 | 5450 | 0.1341 |
| 323.5 | 5500 | 0.1791 |
| 326.4444 | 5550 | 0.1609 |
| 329.3889 | 5600 | 0.2268 |
| 332.3333 | 5650 | 0.2145 |
| 335.2778 | 5700 | 0.095 |
| 338.2222 | 5750 | 0.1161 |
| 341.1667 | 5800 | 0.1615 |
| 344.1111 | 5850 | 0.1261 |
| 347.0556 | 5900 | 0.2022 |
| 349.9444 | 5950 | 0.1503 |
| 352.8889 | 6000 | 0.1473 |
| 355.8333 | 6050 | 0.1703 |
| 358.7778 | 6100 | 0.1441 |
| 361.7222 | 6150 | 0.1439 |
| 364.6667 | 6200 | 0.1192 |
| 367.6111 | 6250 | 0.1312 |
| 370.5556 | 6300 | 0.0933 |
| 373.5 | 6350 | 0.1281 |
| 376.4444 | 6400 | 0.1516 |
| 379.3889 | 6450 | 0.1819 |
| 382.3333 | 6500 | 0.1877 |
| 385.2778 | 6550 | 0.1372 |
| 388.2222 | 6600 | 0.1551 |
| 391.1667 | 6650 | 0.1343 |
| 394.1111 | 6700 | 0.2394 |
| 397.0556 | 6750 | 0.1882 |
| 399.9444 | 6800 | 0.1786 |
| 402.8889 | 6850 | 0.125 |
| 405.8333 | 6900 | 0.1059 |
| 408.7778 | 6950 | 0.1414 |
| 411.7222 | 7000 | 0.0593 |
| 414.6667 | 7050 | 0.1037 |
| 417.6111 | 7100 | 0.098 |
| 420.5556 | 7150 | 0.1457 |
| 423.5 | 7200 | 0.1193 |
| 426.4444 | 7250 | 0.1061 |
| 429.3889 | 7300 | 0.1305 |
| 432.3333 | 7350 | 0.1416 |
| 435.2778 | 7400 | 0.1117 |
| 438.2222 | 7450 | 0.1003 |
| 441.1667 | 7500 | 0.1217 |
| 444.1111 | 7550 | 0.0872 |
| 447.0556 | 7600 | 0.1219 |
| 449.9444 | 7650 | 0.1061 |
| 452.8889 | 7700 | 0.1559 |
| 455.8333 | 7750 | 0.1599 |
| 458.7778 | 7800 | 0.1436 |
| 461.7222 | 7850 | 0.1207 |
| 464.6667 | 7900 | 0.1272 |
| 467.6111 | 7950 | 0.1048 |
| 470.5556 | 8000 | 0.1216 |
| 473.5 | 8050 | 0.133 |
| 476.4444 | 8100 | 0.0971 |
| 479.3889 | 8150 | 0.154 |
| 482.3333 | 8200 | 0.0697 |
| 485.2778 | 8250 | 0.136 |
| 488.2222 | 8300 | 0.1315 |
| 491.1667 | 8350 | 0.1103 |
| 494.1111 | 8400 | 0.1065 |
| 497.0556 | 8450 | 0.0784 |
| 499.9444 | 8500 | 0.134 |
@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}
}
Base model
cl-nagoya/sup-simcse-ja-base