Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False, 'architecture': 'BertModel'})
(1): Pooling({'word_embedding_dimension': 1024, '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 'A construction worker peeking out of a manhole while his coworker sits on the sidewalk smiling.',
8 'A worker is looking out of a manhole.',
9 'The workers are both inside the manhole.',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 1024]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities)
18# tensor([[1.0000, 0.6295, 0.3819],
19# [0.6295, 1.0000, 0.5398],
20# [0.3819, 0.5398, 1.0000]])sts-devEmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.8272 |
| spearman_cosine | 0.8311 |
anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
A person on a horse jumps over a broken down airplane. | A person is outdoors, on a horse. | A person is at a diner, ordering an omelette. |
Children smiling and waving at camera | There are children present | The kids are frowning |
A boy is jumping on skateboard in the middle of a red bridge. | The boy does a skateboarding trick. | The boy skates down the sidewalk. |
MatryoshkaLoss with these parameters:
1{
2 "loss": "MultipleNegativesRankingLoss",
3 "matryoshka_dims": [
4 1024,
5 768,
6 512,
7 256,
8 128,
9 64
10 ],
11 "matryoshka_weights": [
12 1,
13 1,
14 1,
15 1,
16 1,
17 1
18 ],
19 "n_dims_per_step": -1
20}anchor, positive, and negative| anchor | positive | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative |
|---|---|---|
Two women are embracing while holding to go packages. | Two woman are holding packages. | The men are fighting outside a deli. |
Two young children in blue jerseys, one with the number 9 and one with the number 2 are standing on wooden steps in a bathroom and washing their hands in a sink. | Two kids in numbered jerseys wash their hands. | Two kids in jackets walk to school. |
A man selling donuts to a customer during a world exhibition event held in the city of Angeles | A man selling donuts to a customer. | A woman drinks her coffee in a small cafe. |
MatryoshkaLoss with these parameters:
1{
2 "loss": "MultipleNegativesRankingLoss",
3 "matryoshka_dims": [
4 1024,
5 768,
6 512,
7 256,
8 128,
9 64
10 ],
11 "matryoshka_weights": [
12 1,
13 1,
14 1,
15 1,
16 1,
17 1
18 ],
19 "n_dims_per_step": -1
20}eval_strategy: stepsper_device_train_batch_size: 32per_device_eval_batch_size: 32num_train_epochs: 15warmup_ratio: 0.1overwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 32per_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: 1.0num_train_epochs: 15max_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: 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}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_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: Falsehub_revision: Nonegradient_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: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | sts-dev_spearman_cosine |
|---|---|---|---|---|
| -1 | -1 | - | - | 0.5941 |
| 0.0287 | 500 | 12.3309 | 4.8243 | 0.8028 |
| 0.0574 | 1000 | 5.7408 | 3.2828 | 0.8332 |
| 0.0860 | 1500 | 4.4208 | 2.5177 | 0.8426 |
| 0.1147 | 2000 | 3.8188 | 2.1922 | 0.8427 |
| 0.1434 | 2500 | 3.4067 | 1.9693 | 0.8471 |
| 0.1721 | 3000 | 3.161 | 1.8886 | 0.8527 |
| 0.2008 | 3500 | 3.048 | 1.7894 | 0.8523 |
| 0.2294 | 4000 | 2.83 | 1.6946 | 0.8511 |
| 0.2581 | 4500 | 2.7922 | 1.6322 | 0.8568 |
| 0.2868 | 5000 | 2.66 | 1.6114 | 0.8507 |
| 0.3155 | 5500 | 2.5322 | 1.5624 | 0.8551 |
| 0.3442 | 6000 | 2.5291 | 1.5667 | 0.8537 |
| 0.3729 | 6500 | 2.4706 | 1.5957 | 0.8473 |
| 0.4015 | 7000 | 2.4384 | 1.4959 | 0.8548 |
| 0.4302 | 7500 | 2.3288 | 1.4871 | 0.8457 |
| 0.4589 | 8000 | 2.249 | 1.5136 | 0.8529 |
| 0.4876 | 8500 | 2.2898 | 1.4556 | 0.8518 |
| 0.5163 | 9000 | 2.2757 | 1.4641 | 0.8483 |
| 0.5449 | 9500 | 2.2078 | 1.4674 | 0.8499 |
| 0.5736 | 10000 | 2.0755 | 1.4469 | 0.8498 |
| 0.6023 | 10500 | 2.1229 | 1.4643 | 0.8504 |
| 0.6310 | 11000 | 2.0714 | 1.4029 | 0.8527 |
| 0.6597 | 11500 | 2.0637 | 1.3753 | 0.8536 |
| 0.6883 | 12000 | 2.0331 | 1.4564 | 0.8515 |
| 0.7170 | 12500 | 2.0375 | 1.4580 | 0.8540 |
| 0.7457 | 13000 | 1.998 | 1.4934 | 0.8446 |
| 0.7744 | 13500 | 1.9808 | 1.4717 | 0.8414 |
| 0.8031 | 14000 | 1.9537 | 1.4920 | 0.8431 |
| 0.8318 | 14500 | 1.9399 | 1.4552 | 0.8573 |
| 0.8604 | 15000 | 1.9195 | 1.4477 | 0.8528 |
| 0.8891 | 15500 | 1.955 | 1.4242 | 0.8516 |
| 0.9178 | 16000 | 1.9523 | 1.4594 | 0.8524 |
| 0.9465 | 16500 | 1.9603 | 1.5318 | 0.8463 |
| 0.9752 | 17000 | 1.8291 | 1.4828 | 0.8494 |
| 1.0038 | 17500 | 1.8289 | 1.4985 | 0.8432 |
| 1.0325 | 18000 | 1.5617 | 1.4900 | 0.8461 |
| 1.0612 | 18500 | 1.5373 | 1.5241 | 0.8424 |
| 1.0899 | 19000 | 1.6027 | 1.5171 | 0.8404 |
| 1.1186 | 19500 | 1.6143 | 1.5246 | 0.8423 |
| 1.1472 | 20000 | 1.6679 | 1.6454 | 0.8422 |
| 1.1759 | 20500 | 1.6553 | 1.5533 | 0.8402 |
| 1.2046 | 21000 | 1.6922 | 1.5917 | 0.8442 |
| 1.2333 | 21500 | 1.7051 | 1.5728 | 0.8420 |
| 1.2620 | 22000 | 1.6254 | 1.6627 | 0.8446 |
| 1.2907 | 22500 | 2.0703 | 2.5565 | 0.7872 |
| 1.3193 | 23000 | 1.6691 | 1.6753 | 0.8444 |
| 1.3480 | 23500 | 1.7672 | 1.5861 | 0.8429 |
| 1.3767 | 24000 | 1.7359 | 1.6675 | 0.8388 |
| 1.4054 | 24500 | 1.7338 | 1.6618 | 0.8346 |
| 1.4341 | 25000 | 1.7388 | 1.7489 | 0.8336 |
| 1.4627 | 25500 | 1.7896 | 1.7516 | 0.8380 |
| 1.4914 | 26000 | 1.8068 | 1.8055 | 0.8363 |
| 1.5201 | 26500 | 1.7511 | 1.6800 | 0.8303 |
| 1.5488 | 27000 | 1.7859 | 1.6957 | 0.8301 |
| 1.5775 | 27500 | 1.8165 | 1.7559 | 0.8330 |
| 1.6061 | 28000 | 1.7472 | 1.6984 | 0.8332 |
| 1.6348 | 28500 | 1.8047 | 1.7846 | 0.8307 |
| 1.6635 | 29000 | 1.7782 | 1.7620 | 0.8347 |
| 1.6922 | 29500 | 1.7694 | 1.6991 | 0.8285 |
| 1.7209 | 30000 | 1.7507 | 1.8106 | 0.8279 |
| 1.7496 | 30500 | 1.7115 | 1.7362 | 0.8260 |
| 1.7782 | 31000 | 1.723 | 1.6543 | 0.8277 |
| 1.8069 | 31500 | 1.7981 | 1.7660 | 0.8282 |
| 1.8356 | 32000 | 1.7095 | 1.7316 | 0.8253 |
| 1.8643 | 32500 | 1.7164 | 1.6817 | 0.8260 |
| 1.8930 | 33000 | 1.6533 | 1.7456 | 0.8282 |
| 1.9216 | 33500 | 1.5798 | 1.7598 | 0.8234 |
| 1.9503 | 34000 | 1.702 | 1.7936 | 0.8268 |
| 1.9790 | 34500 | 1.6545 | 1.7250 | 0.8306 |
| 2.0077 | 35000 | 1.6175 | 1.7120 | 0.8323 |
| 2.0364 | 35500 | 1.2541 | 1.7433 | 0.8298 |
| 2.0650 | 36000 | 1.3556 | 1.7550 | 0.8344 |
| 2.0937 | 36500 | 1.3191 | 1.7437 | 0.8366 |
| 2.1224 | 37000 | 1.3705 | 1.7690 | 0.8284 |
| 2.1511 | 37500 | 1.392 | 1.7890 | 0.8262 |
| 2.1798 | 38000 | 1.3958 | 1.8109 | 0.8270 |
| 2.2085 | 38500 | 1.3229 | 1.6708 | 0.8302 |
| 2.2371 | 39000 | 1.2834 | 1.7834 | 0.8281 |
| 2.2658 | 39500 | 1.3491 | 1.7583 | 0.8366 |
| 2.2945 | 40000 | 1.2732 | 1.7077 | 0.8334 |
| 2.3232 | 40500 | 1.336 | 1.7959 | 0.8374 |
| 2.3519 | 41000 | 1.3568 | 1.8937 | 0.8256 |
| 2.3805 | 41500 | 1.3773 | 1.7885 | 0.8344 |
| 2.4092 | 42000 | 1.3045 | 1.7292 | 0.8368 |
| 2.4379 | 42500 | 1.3896 | 1.7223 | 0.8394 |
| 2.4666 | 43000 | 1.3162 | 1.7438 | 0.8407 |
| 2.4953 | 43500 | 1.3224 | 1.7386 | 0.8410 |
| 2.5239 | 44000 | 1.3284 | 1.7562 | 0.8371 |
| 2.5526 | 44500 | 1.3392 | 1.7560 | 0.8366 |
| 2.5813 | 45000 | 1.3693 | 1.6666 | 0.8408 |
| 2.6100 | 45500 | 1.2828 | 1.6604 | 0.8424 |
| 2.6387 | 46000 | 1.3301 | 1.7175 | 0.8418 |
| 2.6674 | 46500 | 1.2404 | 1.6045 | 0.8385 |
| 2.6960 | 47000 | 1.2676 | 1.7110 | 0.8361 |
| 2.7247 | 47500 | 1.5642 | 1.7650 | 0.8306 |
| 2.7534 | 48000 | 1.3107 | 1.7877 | 0.8276 |
| 2.7821 | 48500 | 1.2128 | 1.8108 | 0.8218 |
| 2.8108 | 49000 | 1.2769 | 1.7714 | 0.8238 |
| 2.8394 | 49500 | 1.2652 | 1.7425 | 0.8283 |
| 2.8681 | 50000 | 1.2434 | 1.7581 | 0.8229 |
| 2.8968 | 50500 | 1.2944 | 1.6806 | 0.8373 |
| 2.9255 | 51000 | 1.2888 | 1.8191 | 0.8279 |
| 2.9542 | 51500 | 1.2362 | 1.7714 | 0.8363 |
| 2.9828 | 52000 | 1.3305 | 1.7598 | 0.8340 |
| 3.0115 | 52500 | 1.141 | 1.7253 | 0.8343 |
| 3.0402 | 53000 | 0.9836 | 1.6460 | 0.8397 |
| 3.0689 | 53500 | 0.9678 | 1.6445 | 0.8346 |
| 3.0976 | 54000 | 0.9987 | 1.7623 | 0.8376 |
| 3.1263 | 54500 | 1.0263 | 1.7402 | 0.8405 |
| 3.1549 | 55000 | 0.9794 | 1.6704 | 0.8387 |
| 3.1836 | 55500 | 1.0563 | 1.7274 | 0.8403 |
| 3.2123 | 56000 | 0.9664 | 1.6189 | 0.8323 |
| 3.2410 | 56500 | 1.0036 | 1.7204 | 0.8387 |
| 3.2697 | 57000 | 0.9786 | 1.6730 | 0.8286 |
| 3.2983 | 57500 | 0.9643 | 1.7107 | 0.8360 |
| 3.3270 | 58000 | 0.9855 | 1.6285 | 0.8353 |
| 3.3557 | 58500 | 1.0223 | 1.7390 | 0.8264 |
| 3.3844 | 59000 | 0.9838 | 1.7619 | 0.8355 |
| 3.4131 | 59500 | 1.0107 | 1.6764 | 0.8415 |
| 3.4417 | 60000 | 0.9608 | 1.7122 | 0.8297 |
| 3.4704 | 60500 | 0.9825 | 1.6489 | 0.8405 |
| 3.4991 | 61000 | 0.9784 | 1.7329 | 0.8385 |
| 3.5278 | 61500 | 0.97 | 1.6868 | 0.8352 |
| 3.5565 | 62000 | 1.0214 | 1.7853 | 0.8365 |
| 3.5852 | 62500 | 0.9951 | 1.7199 | 0.8313 |
| 3.6138 | 63000 | 0.983 | 1.6869 | 0.8289 |
| 3.6425 | 63500 | 1.055 | 1.7356 | 0.8347 |
| 3.6712 | 64000 | 0.9773 | 1.7737 | 0.8351 |
| 3.6999 | 64500 | 0.9556 | 1.7277 | 0.8365 |
| 3.7286 | 65000 | 0.953 | 1.7097 | 0.8316 |
| 3.7572 | 65500 | 1.021 | 1.6990 | 0.8413 |
| 3.7859 | 66000 | 1.0215 | 1.6130 | 0.8362 |
| 3.8146 | 66500 | 1.2675 | 1.6532 | 0.8289 |
| 3.8433 | 67000 | 1.0331 | 1.7486 | 0.8300 |
| 3.8720 | 67500 | 1.0075 | 1.7104 | 0.8342 |
| 3.9006 | 68000 | 0.9824 | 1.6450 | 0.8359 |
| 3.9293 | 68500 | 0.936 | 1.6791 | 0.8268 |
| 3.9580 | 69000 | 0.9343 | 1.7276 | 0.8287 |
| 3.9867 | 69500 | 0.9795 | 1.7192 | 0.8278 |
| 4.0154 | 70000 | 0.8587 | 1.6672 | 0.8355 |
| 4.0441 | 70500 | 0.7568 | 1.7530 | 0.8348 |
| 4.0727 | 71000 | 0.8025 | 1.7489 | 0.8310 |
| 4.1014 | 71500 | 0.779 | 1.6084 | 0.8424 |
| 4.1301 | 72000 | 0.7467 | 1.7105 | 0.8354 |
| 4.1588 | 72500 | 0.926 | 1.7702 | 0.8295 |
| 4.1875 | 73000 | 0.7987 | 1.7775 | 0.8300 |
| 4.2161 | 73500 | 0.828 | 1.7745 | 0.8361 |
| 4.2448 | 74000 | 0.7782 | 1.7310 | 0.8311 |
| 4.2735 | 74500 | 0.7496 | 1.7941 | 0.8329 |
| 4.3022 | 75000 | 0.7764 | 1.6934 | 0.8335 |
| 4.3309 | 75500 | 0.7783 | 1.7820 | 0.8288 |
| 4.3595 | 76000 | 0.8095 | 1.7752 | 0.8376 |
| 4.3882 | 76500 | 1.0525 | 1.6825 | 0.8376 |
| 4.4169 | 77000 | 0.7974 | 1.7435 | 0.8315 |
| 4.4456 | 77500 | 0.881 | 1.7374 | 0.8311 |
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}1@misc{kusupati2024matryoshka,
2 title={Matryoshka Representation Learning},
3 author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
4 year={2024},
5 eprint={2205.13147},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG}
8}1@misc{henderson2017efficient,
2 title={Efficient Natural Language Response Suggestion for Smart Reply},
3 author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
4 year={2017},
5 eprint={1705.00652},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}