Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper
•
1908.10084
•
Published
•
9
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_11")
# Run inference
sentences = [
'埋込み(B種)(損料・手間)',
'埋戻し(A種)(損料)',
'埋戻し(B種)(手間)',
]
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 |
BatchAllTripletLossper_device_train_batch_size: 512per_device_eval_batch_size: 512learning_rate: 1e-05weight_decay: 0.01num_train_epochs: 250warmup_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: 250max_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}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: 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 |
|---|---|---|
| 10.0 | 10 | 1.6508 |
| 20.0 | 20 | 1.2554 |
| 30.0 | 30 | 0.8495 |
| 40.0 | 40 | 0.7182 |
| 50.0 | 50 | 0.6614 |
| 60.0 | 60 | 0.575 |
| 70.0 | 70 | 0.5027 |
| 80.0 | 80 | 0.32 |
| 90.0 | 90 | 0.1543 |
| 100.0 | 100 | 0.0102 |
| 110.0 | 110 | 0.012 |
| 120.0 | 120 | 0.1164 |
| 130.0 | 130 | 0.0 |
| 140.0 | 140 | 0.0 |
| 150.0 | 150 | 0.0 |
| 160.0 | 160 | 0.0157 |
| 170.0 | 170 | 0.0794 |
| 180.0 | 180 | 0.0 |
| 190.0 | 190 | 0.0 |
| 200.0 | 200 | 0.0141 |
| 210.0 | 210 | 0.0 |
| 220.0 | 220 | 0.0 |
| 230.0 | 230 | 0.1115 |
| 240.0 | 240 | 0.0 |
| 250.0 | 250 | 0.0 |
| 260.0 | 260 | 0.0 |
| 270.0 | 270 | 0.0 |
| 280.0 | 280 | 0.0 |
| 290.0 | 290 | 0.0 |
| 300.0 | 300 | 0.0 |
| 310.0 | 310 | 0.0 |
| 320.0 | 320 | 0.0 |
| 330.0 | 330 | 0.0 |
| 340.0 | 340 | 0.0 |
| 350.0 | 350 | 0.0 |
| 360.0 | 360 | 0.0197 |
| 370.0 | 370 | 0.0649 |
| 380.0 | 380 | 0.0 |
| 390.0 | 390 | 0.0 |
| 400.0 | 400 | 0.0 |
| 410.0 | 410 | 0.0 |
| 420.0 | 420 | 0.0 |
| 430.0 | 430 | 0.0 |
| 440.0 | 440 | 0.0 |
| 450.0 | 450 | 0.0 |
| 460.0 | 460 | 0.0 |
| 470.0 | 470 | 0.0 |
| 480.0 | 480 | 0.0 |
| 490.0 | 490 | 0.0 |
| 500.0 | 500 | 0.0 |
| 3.1842 | 100 | 0.6748 |
| 6.3684 | 200 | 0.5883 |
| 9.5526 | 300 | 0.5815 |
| 12.7368 | 400 | 0.5338 |
| 16.1053 | 500 | 0.5498 |
| 19.2895 | 600 | 0.5359 |
| 22.4737 | 700 | 0.5359 |
| 25.6579 | 800 | 0.4893 |
| 29.0263 | 900 | 0.4665 |
| 32.2105 | 1000 | 0.4205 |
| 35.3947 | 1100 | 0.4383 |
| 38.5789 | 1200 | 0.4552 |
| 41.7632 | 1300 | 0.4003 |
| 45.1316 | 1400 | 0.3816 |
| 48.3158 | 1500 | 0.3744 |
| 51.5 | 1600 | 0.3504 |
| 54.6842 | 1700 | 0.359 |
| 58.0526 | 1800 | 0.3019 |
| 61.2368 | 1900 | 0.3109 |
| 64.4211 | 2000 | 0.3151 |
| 67.6053 | 2100 | 0.3292 |
| 70.7895 | 2200 | 0.2813 |
| 74.1579 | 2300 | 0.2697 |
| 77.3421 | 2400 | 0.1975 |
| 80.5263 | 2500 | 0.2492 |
| 83.7105 | 2600 | 0.2608 |
| 87.0789 | 2700 | 0.2401 |
| 90.2632 | 2800 | 0.2265 |
| 93.4474 | 2900 | 0.2032 |
| 96.6316 | 3000 | 0.2368 |
| 99.8158 | 3100 | 0.2066 |
| 103.1842 | 3200 | 0.1558 |
| 106.3684 | 3300 | 0.2029 |
| 109.5526 | 3400 | 0.244 |
| 112.7368 | 3500 | 0.1894 |
| 116.1053 | 3600 | 0.193 |
| 119.2895 | 3700 | 0.1769 |
| 122.4737 | 3800 | 0.1821 |
| 125.6579 | 3900 | 0.0912 |
| 129.0263 | 4000 | 0.1834 |
| 132.2105 | 4100 | 0.1391 |
| 135.3947 | 4200 | 0.1718 |
| 138.5789 | 4300 | 0.1585 |
| 141.7632 | 4400 | 0.1829 |
| 145.1316 | 4500 | 0.1246 |
| 148.3158 | 4600 | 0.1327 |
| 151.5 | 4700 | 0.1396 |
| 154.6842 | 4800 | 0.1028 |
| 158.0526 | 4900 | 0.0907 |
| 161.2368 | 5000 | 0.1179 |
| 164.4211 | 5100 | 0.1496 |
| 167.6053 | 5200 | 0.1156 |
| 170.7895 | 5300 | 0.1148 |
| 174.1579 | 5400 | 0.1275 |
| 177.3421 | 5500 | 0.1354 |
| 180.5263 | 5600 | 0.1334 |
| 183.7105 | 5700 | 0.0874 |
| 187.0789 | 5800 | 0.0922 |
| 190.2632 | 5900 | 0.1109 |
| 193.4474 | 6000 | 0.0708 |
| 196.6316 | 6100 | 0.0943 |
| 199.8158 | 6200 | 0.1164 |
| 203.1842 | 6300 | 0.0785 |
| 206.3684 | 6400 | 0.0853 |
| 209.5526 | 6500 | 0.0674 |
| 212.7368 | 6600 | 0.1009 |
| 216.1053 | 6700 | 0.0846 |
| 219.2895 | 6800 | 0.078 |
| 222.4737 | 6900 | 0.0958 |
| 225.6579 | 7000 | 0.0811 |
| 229.0263 | 7100 | 0.0452 |
| 232.2105 | 7200 | 0.0705 |
| 235.3947 | 7300 | 0.0664 |
| 238.5789 | 7400 | 0.0501 |
| 241.7632 | 7500 | 0.0696 |
| 245.1316 | 7600 | 0.0736 |
| 248.3158 | 7700 | 0.08 |
@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