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-v1_0")
# 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 |
科目:共通仮設費。名称:電動パネルゲート。 |
1 |
科目:共通仮設費。名称:タワークレーン。 |
2 |
BatchAllTripletLossper_device_train_batch_size: 256per_device_eval_batch_size: 256learning_rate: 1e-05weight_decay: 0.01num_train_epochs: 200warmup_ratio: 0.1fp16: Truebatch_sampler: group_by_labeloverwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 256per_device_eval_batch_size: 256per_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: 200max_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 |
|---|---|---|
| 3.0870 | 20 | 0.8892 |
| 6.1739 | 40 | 0.8935 |
| 9.2609 | 60 | 0.862 |
| 13.0870 | 80 | 0.803 |
| 16.1739 | 100 | 0.8154 |
| 19.2609 | 120 | 0.7741 |
| 23.0870 | 140 | 0.7383 |
| 26.1739 | 160 | 0.7381 |
| 29.2609 | 180 | 0.7082 |
| 33.0870 | 200 | 0.6593 |
| 36.1739 | 220 | 0.6816 |
| 39.2609 | 240 | 0.6507 |
| 43.0870 | 260 | 0.6357 |
| 46.1739 | 280 | 0.643 |
| 49.2609 | 300 | 0.6336 |
| 53.0870 | 320 | 0.6392 |
| 56.1739 | 340 | 0.6153 |
| 59.2609 | 360 | 0.6385 |
| 63.0870 | 380 | 0.6034 |
| 66.1739 | 400 | 0.6194 |
| 69.2609 | 420 | 0.6334 |
| 73.0870 | 440 | 0.5934 |
| 76.1739 | 460 | 0.6216 |
| 79.2609 | 480 | 0.6211 |
| 83.0870 | 500 | 0.5974 |
| 86.1739 | 520 | 0.6612 |
| 89.2609 | 540 | 0.5143 |
| 93.0870 | 560 | 0.5871 |
| 96.1739 | 580 | 0.5752 |
| 99.2609 | 600 | 0.5661 |
| 103.0870 | 620 | 0.5879 |
| 106.1739 | 640 | 0.5866 |
| 109.2609 | 660 | 0.5677 |
| 113.0870 | 680 | 0.4864 |
| 116.1739 | 700 | 0.5891 |
| 119.2609 | 720 | 0.617 |
| 123.0870 | 740 | 0.5785 |
| 126.1739 | 760 | 0.534 |
| 129.2609 | 780 | 0.5854 |
| 133.0870 | 800 | 0.5971 |
| 136.1739 | 820 | 0.5309 |
| 139.2609 | 840 | 0.5514 |
| 143.0870 | 860 | 0.5656 |
| 146.1739 | 880 | 0.5106 |
| 149.2609 | 900 | 0.4831 |
| 153.0870 | 920 | 0.497 |
| 156.1739 | 940 | 0.4606 |
| 159.2609 | 960 | 0.4699 |
| 163.0870 | 980 | 0.5007 |
| 166.1739 | 1000 | 0.5483 |
| 169.2609 | 1020 | 0.4527 |
| 173.0870 | 1040 | 0.448 |
| 176.1739 | 1060 | 0.4639 |
| 179.2609 | 1080 | 0.6067 |
| 183.0870 | 1100 | 0.4516 |
| 186.1739 | 1120 | 0.4747 |
| 189.2609 | 1140 | 0.4732 |
| 193.0870 | 1160 | 0.5844 |
| 196.1739 | 1180 | 0.4461 |
| 199.2609 | 1200 | 0.4609 |
@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