SentenceTransformer(
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("sentence_transformers_model_id")
5# Run inference
6sentences = [
7 'gravel parking',
8 'asfalterad uppfart',
9 'rauhallinen naapurusto',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 384]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities.shape)
18# [3, 3]trait-evalEmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.7845 |
| spearman_cosine | 0.8182 |
sentence_0, sentence_1, and label| sentence_0 | sentence_1 | label | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| sentence_0 | sentence_1 | label |
|---|---|---|
kerrostalo | puuaita | 0.1 |
corner unit | large yard | 0.3 |
easy access to highway | oma pysäköinti | 0.3 |
[object Object].TemperatureScaledCosineSimilarityLoss with these parameters:
1{
2 "loss_fct": "torch.nn.modules.loss.MSELoss"
3}eval_strategy: stepsper_device_train_batch_size: 64per_device_eval_batch_size: 64num_train_epochs: 5multi_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 64per_device_eval_batch_size: 64per_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: 5max_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: Falsefp16_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: batch_samplermulti_dataset_batch_sampler: round_robin| Epoch | Step | Training Loss | trait-eval_spearman_cosine |
|---|---|---|---|
| 0.0248 | 500 | 0.1261 | - |
| 0.0496 | 1000 | 0.1155 | 0.2026 |
| 0.0744 | 1500 | 0.119 | - |
| 0.0992 | 2000 | 0.1193 | 0.2516 |
| 0.1240 | 2500 | 0.118 | - |
| 0.1488 | 3000 | 0.1151 | 0.2638 |
| 0.1736 | 3500 | 0.1152 | - |
| 0.1984 | 4000 | 0.1093 | 0.2700 |
| 0.2232 | 4500 | 0.1077 | - |
| 0.2480 | 5000 | 0.109 | 0.2942 |
| 0.2728 | 5500 | 0.1015 | - |
| 0.2976 | 6000 | 0.1059 | 0.3171 |
| 0.3224 | 6500 | 0.1052 | - |
| 0.3472 | 7000 | 0.1042 | 0.3114 |
| 0.3720 | 7500 | 0.1006 | - |
| 0.3968 | 8000 | 0.1007 | 0.3328 |
| 0.4216 | 8500 | 0.1013 | - |
| 0.4464 | 9000 | 0.0938 | 0.3407 |
| 0.4712 | 9500 | 0.0971 | - |
| 0.4960 | 10000 | 0.0976 | 0.3430 |
| 0.5208 | 10500 | 0.0945 | - |
| 0.5456 | 11000 | 0.0937 | 0.3603 |
| 0.5704 | 11500 | 0.0919 | - |
| 0.5952 | 12000 | 0.0893 | 0.3916 |
| 0.6200 | 12500 | 0.0904 | - |
| 0.6448 | 13000 | 0.0866 | 0.3931 |
| 0.6696 | 13500 | 0.087 | - |
| 0.6944 | 14000 | 0.0848 | 0.4178 |
| 0.7192 | 14500 | 0.087 | - |
| 0.7440 | 15000 | 0.0827 | 0.4218 |
| 0.7688 | 15500 | 0.0851 | - |
| 0.7936 | 16000 | 0.0807 | 0.4414 |
| 0.8184 | 16500 | 0.0803 | - |
| 0.8432 | 17000 | 0.0803 | 0.4526 |
| 0.8680 | 17500 | 0.0784 | - |
| 0.8928 | 18000 | 0.0776 | 0.4592 |
| 0.9176 | 18500 | 0.0761 | - |
| 0.9424 | 19000 | 0.0739 | 0.4856 |
| 0.9672 | 19500 | 0.0724 | - |
| 0.9920 | 20000 | 0.0738 | 0.4928 |
| 1.0 | 20161 | - | 0.4863 |
| 1.0168 | 20500 | 0.0707 | - |
| 1.0416 | 21000 | 0.0699 | 0.4950 |
| 1.0664 | 21500 | 0.0637 | - |
| 1.0912 | 22000 | 0.0677 | 0.5000 |
| 1.1160 | 22500 | 0.0638 | - |
| 1.1408 | 23000 | 0.0653 | 0.5306 |
| 1.1656 | 23500 | 0.0661 | - |
| 1.1904 | 24000 | 0.0679 | 0.5292 |
| 1.2152 | 24500 | 0.0618 | - |
| 1.2400 | 25000 | 0.0616 | 0.5253 |
| 1.2648 | 25500 | 0.0626 | - |
| 1.2896 | 26000 | 0.0624 | 0.5422 |
| 1.3144 | 26500 | 0.0613 | - |
| 1.3392 | 27000 | 0.0623 | 0.5515 |
| 1.3640 | 27500 | 0.0601 | - |
| 1.3888 | 28000 | 0.0589 | 0.5606 |
| 1.4136 | 28500 | 0.06 | - |
| 1.4384 | 29000 | 0.0598 | 0.5774 |
| 1.4632 | 29500 | 0.0553 | - |
| 1.4880 | 30000 | 0.0596 | 0.5812 |
| 1.5128 | 30500 | 0.0547 | - |
| 1.5376 | 31000 | 0.0542 | 0.5956 |
| 1.5624 | 31500 | 0.0547 | - |
| 1.5872 | 32000 | 0.0545 | 0.6053 |
| 1.6120 | 32500 | 0.0525 | - |
| 1.6368 | 33000 | 0.0545 | 0.6137 |
| 1.6616 | 33500 | 0.0532 | - |
| 1.6864 | 34000 | 0.0525 | 0.6213 |
| 1.7112 | 34500 | 0.0529 | - |
| 1.7360 | 35000 | 0.0515 | 0.6152 |
| 1.7608 | 35500 | 0.0506 | - |
| 1.7856 | 36000 | 0.0502 | 0.6211 |
| 1.8104 | 36500 | 0.0513 | - |
| 1.8352 | 37000 | 0.0476 | 0.6344 |
| 1.8600 | 37500 | 0.0491 | - |
| 1.8848 | 38000 | 0.0485 | 0.6438 |
| 1.9096 | 38500 | 0.0488 | - |
| 1.9344 | 39000 | 0.0471 | 0.6591 |
| 1.9592 | 39500 | 0.049 | - |
| 1.9840 | 40000 | 0.0486 | 0.6692 |
| 2.0 | 40322 | - | 0.6619 |
| 2.0088 | 40500 | 0.044 | - |
| 2.0336 | 41000 | 0.0407 | 0.6729 |
| 2.0584 | 41500 | 0.0422 | - |
| 2.0832 | 42000 | 0.0427 | 0.6775 |
| 2.1080 | 42500 | 0.0425 | - |
| 2.1328 | 43000 | 0.043 | 0.6772 |
| 2.1576 | 43500 | 0.0426 | - |
| 2.1824 | 44000 | 0.04 | 0.6877 |
| 2.2072 | 44500 | 0.041 | - |
| 2.2320 | 45000 | 0.0422 | 0.6885 |
| 2.2568 | 45500 | 0.04 | - |
| 2.2816 | 46000 | 0.0399 | 0.6903 |
| 2.3064 | 46500 | 0.0414 | - |
| 2.3312 | 47000 | 0.0397 | 0.7008 |
| 2.3560 | 47500 | 0.0406 | - |
| 2.3808 | 48000 | 0.0395 | 0.7004 |
| 2.4056 | 48500 | 0.0375 | - |
| 2.4304 | 49000 | 0.0391 | 0.6964 |
| 2.4552 | 49500 | 0.0378 | - |
| 2.4800 | 50000 | 0.0379 | 0.7092 |
| 2.5048 | 50500 | 0.0394 | - |
| 2.5296 | 51000 | 0.0399 | 0.7122 |
| 2.5544 | 51500 | 0.0357 | - |
| 2.5792 | 52000 | 0.0362 | 0.7170 |
| 2.6040 | 52500 | 0.0383 | - |
| 2.6288 | 53000 | 0.0396 | 0.7218 |
| 2.6536 | 53500 | 0.037 | - |
| 2.6784 | 54000 | 0.0372 | 0.7312 |
| 2.7032 | 54500 | 0.0372 | - |
| 2.7280 | 55000 | 0.0365 | 0.7303 |
| 2.7528 | 55500 | 0.0364 | - |
| 2.7776 | 56000 | 0.0356 | 0.7366 |
| 2.8024 | 56500 | 0.034 | - |
| 2.8272 | 57000 | 0.036 | 0.7415 |
| 2.8520 | 57500 | 0.035 | - |
| 2.8768 | 58000 | 0.0355 | 0.7402 |
| 2.9016 | 58500 | 0.0331 | - |
| 2.9264 | 59000 | 0.0345 | 0.7475 |
| 2.9512 | 59500 | 0.0345 | - |
| 2.9760 | 60000 | 0.0348 | 0.7489 |
| 3.0 | 60483 | - | 0.7500 |
| 3.0008 | 60500 | 0.0351 | - |
| 3.0256 | 61000 | 0.0294 | 0.7537 |
| 3.0504 | 61500 | 0.0297 | - |
| 3.0752 | 62000 | 0.0301 | 0.7557 |
| 3.1000 | 62500 | 0.0311 | - |
| 3.1248 | 63000 | 0.0314 | 0.7628 |
| 3.1496 | 63500 | 0.0288 | - |
| 3.1744 | 64000 | 0.0311 | 0.7713 |
| 3.1992 | 64500 | 0.03 | - |
| 3.2240 | 65000 | 0.0307 | 0.7728 |
| 3.2488 | 65500 | 0.0321 | - |
| 3.2736 | 66000 | 0.028 | 0.7726 |
| 3.2984 | 66500 | 0.031 | - |
| 3.3232 | 67000 | 0.0283 | 0.7717 |
| 3.3480 | 67500 | 0.0302 | - |
| 3.3728 | 68000 | 0.0302 | 0.7808 |
| 3.3976 | 68500 | 0.0303 | - |
| 3.4224 | 69000 | 0.0285 | 0.7790 |
| 3.4472 | 69500 | 0.0304 | - |
| 3.4720 | 70000 | 0.0287 | 0.7856 |
| 3.4969 | 70500 | 0.0301 | - |
| 3.5217 | 71000 | 0.0285 | 0.7886 |
| 3.5465 | 71500 | 0.0295 | - |
| 3.5713 | 72000 | 0.0296 | 0.7899 |
| 3.5961 | 72500 | 0.0269 | - |
| 3.6209 | 73000 | 0.0278 | 0.7911 |
| 3.6457 | 73500 | 0.0299 | - |
| 3.6705 | 74000 | 0.0285 | 0.7898 |
| 3.6953 | 74500 | 0.0286 | - |
| 3.7201 | 75000 | 0.0281 | 0.7891 |
| 3.7449 | 75500 | 0.0308 | - |
| 3.7697 | 76000 | 0.0288 | 0.7893 |
| 3.7945 | 76500 | 0.0283 | - |
| 3.8193 | 77000 | 0.0264 | 0.7953 |
| 3.8441 | 77500 | 0.0265 | - |
| 3.8689 | 78000 | 0.0271 | 0.7942 |
| 3.8937 | 78500 | 0.0263 | - |
| 3.9185 | 79000 | 0.0278 | 0.7932 |
| 3.9433 | 79500 | 0.0258 | - |
| 3.9681 | 80000 | 0.028 | 0.7996 |
| 3.9929 | 80500 | 0.0284 | - |
| 4.0 | 80644 | - | 0.8017 |
| 4.0177 | 81000 | 0.0258 | 0.8022 |
| 4.0425 | 81500 | 0.027 | - |
| 4.0673 | 82000 | 0.0228 | 0.8034 |
| 4.0921 | 82500 | 0.0259 | - |
| 4.1169 | 83000 | 0.0257 | 0.8057 |
| 4.1417 | 83500 | 0.0248 | - |
| 4.1665 | 84000 | 0.025 | 0.8060 |
| 4.1913 | 84500 | 0.024 | - |
| 4.2161 | 85000 | 0.0267 | 0.8084 |
| 4.2409 | 85500 | 0.0244 | - |
| 4.2657 | 86000 | 0.0261 | 0.8058 |
| 4.2905 | 86500 | 0.0256 | - |
| 4.3153 | 87000 | 0.0252 | 0.8061 |
| 4.3401 | 87500 | 0.0246 | - |
| 4.3649 | 88000 | 0.0243 | 0.8095 |
| 4.3897 | 88500 | 0.0243 | - |
| 4.4145 | 89000 | 0.0251 | 0.8113 |
| 4.4393 | 89500 | 0.0247 | - |
| 4.4641 | 90000 | 0.0239 | 0.8109 |
| 4.4889 | 90500 | 0.0248 | - |
| 4.5137 | 91000 | 0.0235 | 0.8129 |
| 4.5385 | 91500 | 0.0246 | - |
| 4.5633 | 92000 | 0.0231 | 0.8132 |
| 4.5881 | 92500 | 0.0254 | - |
| 4.6129 | 93000 | 0.0249 | 0.8140 |
| 4.6377 | 93500 | 0.0229 | - |
| 4.6625 | 94000 | 0.025 | 0.8143 |
| 4.6873 | 94500 | 0.0244 | - |
| 4.7121 | 95000 | 0.0227 | 0.8158 |
| 4.7369 | 95500 | 0.0223 | - |
| 4.7617 | 96000 | 0.0232 | 0.8166 |
| 4.7865 | 96500 | 0.024 | - |
| 4.8113 | 97000 | 0.0243 | 0.8170 |
| 4.8361 | 97500 | 0.0229 | - |
| 4.8609 | 98000 | 0.0243 | 0.8172 |
| 4.8857 | 98500 | 0.0223 | - |
| 4.9105 | 99000 | 0.0252 | 0.8176 |
| 4.9353 | 99500 | 0.0242 | - |
| 4.9601 | 100000 | 0.0221 | 0.8182 |
| 4.9849 | 100500 | 0.022 | - |
| 5.0 | 100805 | - | 0.8182 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}