Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: RobertaModel
(1): Pooling({'word_embedding_dimension': 768, '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("mrm8488/distilroberta-base-ft-allnli-matryoshka-768-16-1e-128bs")
5# Run inference
6sentences = [
7 'It is well.',
8 "That's convenient.",
9 'away from the children',
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 768]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities.shape)
18# [3, 3]sts-dev-768EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.8413 |
| spearman_cosine | 0.8478 |
| pearson_manhattan | 0.8414 |
| spearman_manhattan | 0.8395 |
| pearson_euclidean | 0.8423 |
| spearman_euclidean | 0.8401 |
| pearson_dot | 0.7855 |
| spearman_dot | 0.7814 |
| pearson_max | 0.8423 |
| spearman_max | 0.8478 |
sts-dev-512EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.8395 |
| spearman_cosine | 0.847 |
| pearson_manhattan | 0.8399 |
| spearman_manhattan | 0.8377 |
| pearson_euclidean | 0.8407 |
| spearman_euclidean | 0.838 |
| pearson_dot | 0.7811 |
| spearman_dot | 0.7777 |
| pearson_max | 0.8407 |
| spearman_max | 0.847 |
sts-dev-256EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.8327 |
| spearman_cosine | 0.8436 |
| pearson_manhattan | 0.8351 |
| spearman_manhattan | 0.8332 |
| pearson_euclidean | 0.836 |
| spearman_euclidean | 0.8338 |
| pearson_dot | 0.75 |
| spearman_dot | 0.7453 |
| pearson_max | 0.836 |
| spearman_max | 0.8436 |
sts-dev-128EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.8243 |
| spearman_cosine | 0.84 |
| pearson_manhattan | 0.8282 |
| spearman_manhattan | 0.827 |
| pearson_euclidean | 0.8282 |
| spearman_euclidean | 0.8267 |
| pearson_dot | 0.711 |
| spearman_dot | 0.705 |
| pearson_max | 0.8282 |
| spearman_max | 0.84 |
sts-dev-64EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.8116 |
| spearman_cosine | 0.8317 |
| pearson_manhattan | 0.8113 |
| spearman_manhattan | 0.8105 |
| pearson_euclidean | 0.8114 |
| spearman_euclidean | 0.8111 |
| pearson_dot | 0.6412 |
| spearman_dot | 0.6347 |
| pearson_max | 0.8116 |
| spearman_max | 0.8317 |
sts-dev-32EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.7834 |
| spearman_cosine | 0.8141 |
| pearson_manhattan | 0.7832 |
| spearman_manhattan | 0.786 |
| pearson_euclidean | 0.7869 |
| spearman_euclidean | 0.7894 |
| pearson_dot | 0.5534 |
| spearman_dot | 0.5449 |
| pearson_max | 0.7869 |
| spearman_max | 0.8141 |
sts-dev-16EmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.7259 |
| spearman_cosine | 0.7751 |
| pearson_manhattan | 0.7421 |
| spearman_manhattan | 0.7553 |
| pearson_euclidean | 0.7483 |
| spearman_euclidean | 0.7599 |
| pearson_dot | 0.4387 |
| spearman_dot | 0.4259 |
| pearson_max | 0.7483 |
| spearman_max | 0.7751 |
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 768,
5 512,
6 256,
7 128,
8 64,
9 32,
10 16
11 ],
12 "matryoshka_weights": [
13 1,
14 1,
15 1,
16 1,
17 1,
18 1,
19 1
20 ],
21 "n_dims_per_step": -1
22}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 768,
5 512,
6 256,
7 128,
8 64,
9 32,
10 16
11 ],
12 "matryoshka_weights": [
13 1,
14 1,
15 1,
16 1,
17 1,
18 1,
19 1
20 ],
21 "n_dims_per_step": -1
22}eval_strategy: stepsper_device_train_batch_size: 128per_device_eval_batch_size: 128num_train_epochs: 1warmup_ratio: 0.1fp16: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 128per_device_eval_batch_size: 128per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_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: Falsehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseeval_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: Falsebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | loss | sts-dev-128_spearman_cosine | sts-dev-16_spearman_cosine | sts-dev-256_spearman_cosine | sts-dev-32_spearman_cosine | sts-dev-512_spearman_cosine | sts-dev-64_spearman_cosine | sts-dev-768_spearman_cosine |
|---|---|---|---|---|---|---|---|---|---|---|
| 0.0229 | 100 | 29.0917 | 14.1514 | 0.7659 | 0.7440 | 0.7915 | 0.7749 | 0.7999 | 0.7909 | 0.7918 |
| 0.0459 | 200 | 15.6915 | 11.7031 | 0.7718 | 0.7487 | 0.7940 | 0.7776 | 0.8005 | 0.7931 | 0.7871 |
| 0.0688 | 300 | 14.3136 | 11.1970 | 0.7744 | 0.7389 | 0.7952 | 0.7728 | 0.8036 | 0.7925 | 0.7938 |
| 0.0918 | 400 | 12.8122 | 10.4416 | 0.7899 | 0.7536 | 0.8040 | 0.7764 | 0.8065 | 0.7953 | 0.8018 |
| 0.1147 | 500 | 12.1747 | 10.5491 | 0.7871 | 0.7513 | 0.8035 | 0.7785 | 0.8094 | 0.7978 | 0.8008 |
| 0.1376 | 600 | 11.6784 | 9.6618 | 0.7785 | 0.7465 | 0.7956 | 0.7762 | 0.8027 | 0.7953 | 0.7935 |
| 0.1606 | 700 | 11.9351 | 9.3279 | 0.7907 | 0.7403 | 0.7995 | 0.7706 | 0.8036 | 0.7894 | 0.7982 |
| 0.1835 | 800 | 10.4998 | 9.1538 | 0.7911 | 0.7516 | 0.8043 | 0.7820 | 0.8078 | 0.8025 | 0.8010 |
| 0.2065 | 900 | 10.6069 | 9.0531 | 0.7874 | 0.7371 | 0.7974 | 0.7704 | 0.8042 | 0.7910 | 0.8010 |
| 0.2294 | 1000 | 10.0316 | 8.9759 | 0.7842 | 0.7356 | 0.7981 | 0.7721 | 0.8024 | 0.7905 | 0.7955 |
| 0.2524 | 1100 | 10.199 | 8.5398 | 0.7863 | 0.7322 | 0.7961 | 0.7691 | 0.8002 | 0.7910 | 0.7936 |
| 0.2753 | 1200 | 9.9393 | 8.1356 | 0.7860 | 0.7304 | 0.7990 | 0.7682 | 0.8025 | 0.7908 | 0.7954 |
| 0.2982 | 1300 | 9.8711 | 7.9177 | 0.7932 | 0.7319 | 0.8028 | 0.7708 | 0.8067 | 0.7924 | 0.8013 |
| 0.3212 | 1400 | 9.3594 | 7.8870 | 0.7892 | 0.7296 | 0.8032 | 0.7710 | 0.8070 | 0.7961 | 0.8030 |
| 0.3441 | 1500 | 9.4534 | 7.5756 | 0.8003 | 0.7518 | 0.8078 | 0.7857 | 0.8112 | 0.8063 | 0.8068 |
| 0.3671 | 1600 | 8.9061 | 7.8164 | 0.7781 | 0.7390 | 0.7942 | 0.7761 | 0.8002 | 0.7968 | 0.7941 |
| 0.3900 | 1700 | 8.5164 | 7.4869 | 0.7934 | 0.7530 | 0.8063 | 0.7864 | 0.8120 | 0.8055 | 0.8080 |
| 0.4129 | 1800 | 8.9262 | 7.7155 | 0.7846 | 0.7301 | 0.7991 | 0.7728 | 0.8065 | 0.7945 | 0.8003 |
| 0.4359 | 1900 | 8.3242 | 7.3068 | 0.7850 | 0.7273 | 0.7976 | 0.7710 | 0.8020 | 0.7904 | 0.7976 |
| 0.4588 | 2000 | 8.5374 | 7.1026 | 0.7845 | 0.7272 | 0.7993 | 0.7717 | 0.8042 | 0.7925 | 0.7963 |
| 0.4818 | 2100 | 8.2304 | 7.1601 | 0.7879 | 0.7354 | 0.8015 | 0.7719 | 0.8059 | 0.7944 | 0.8029 |
| 0.5047 | 2200 | 8.1347 | 7.8267 | 0.7715 | 0.7230 | 0.7889 | 0.7626 | 0.7956 | 0.7849 | 0.7930 |
| 0.5276 | 2300 | 8.3057 | 8.0057 | 0.7622 | 0.7148 | 0.7814 | 0.7572 | 0.7881 | 0.7769 | 0.7836 |
| 0.5506 | 2400 | 8.215 | 7.6922 | 0.7772 | 0.7210 | 0.7929 | 0.7637 | 0.7995 | 0.7858 | 0.7956 |
| 0.5735 | 2500 | 8.4343 | 7.2104 | 0.7869 | 0.7307 | 0.8017 | 0.7707 | 0.8071 | 0.7929 | 0.8048 |
| 0.5965 | 2600 | 8.159 | 6.9977 | 0.7893 | 0.7297 | 0.8031 | 0.7733 | 0.8071 | 0.7928 | 0.8045 |
| 0.6194 | 2700 | 8.2048 | 6.9465 | 0.7859 | 0.7280 | 0.8006 | 0.7725 | 0.8052 | 0.7926 | 0.8004 |
| 0.6423 | 2800 | 8.187 | 7.3185 | 0.7790 | 0.7266 | 0.7960 | 0.7690 | 0.8018 | 0.7911 | 0.7964 |
| 0.6653 | 2900 | 8.4768 | 7.5535 | 0.7756 | 0.7192 | 0.7913 | 0.7618 | 0.7958 | 0.7827 | 0.7907 |
| 0.6882 | 3000 | 8.4153 | 7.3732 | 0.7825 | 0.7276 | 0.7988 | 0.7692 | 0.8029 | 0.7899 | 0.7988 |
| 0.7112 | 3100 | 7.9226 | 6.8469 | 0.7912 | 0.7311 | 0.8055 | 0.7765 | 0.8101 | 0.7977 | 0.8058 |
| 0.7341 | 3200 | 8.1155 | 6.7604 | 0.7880 | 0.7298 | 0.8024 | 0.7747 | 0.8071 | 0.7959 | 0.8025 |
| 0.7571 | 3300 | 6.8463 | 5.4863 | 0.8357 | 0.7638 | 0.8407 | 0.8085 | 0.8431 | 0.8283 | 0.8440 |
| 0.7800 | 3400 | 5.2008 | 5.2472 | 0.8362 | 0.7655 | 0.8401 | 0.8105 | 0.8429 | 0.8279 | 0.8445 |
| 0.8029 | 3500 | 4.5415 | 5.1649 | 0.8385 | 0.7700 | 0.8421 | 0.8138 | 0.8454 | 0.8304 | 0.8465 |
| 0.8259 | 3600 | 4.4474 | 5.0933 | 0.8371 | 0.7693 | 0.8410 | 0.8112 | 0.8443 | 0.8288 | 0.8451 |
| 0.8488 | 3700 | 4.12 | 5.0555 | 0.8396 | 0.7718 | 0.8439 | 0.8140 | 0.8463 | 0.8311 | 0.8471 |
| 0.8718 | 3800 | 3.9104 | 5.0147 | 0.8386 | 0.7749 | 0.8432 | 0.8129 | 0.8459 | 0.8304 | 0.8471 |
| 0.8947 | 3900 | 3.9054 | 4.9966 | 0.8379 | 0.7733 | 0.8424 | 0.8125 | 0.8456 | 0.8296 | 0.8464 |
| 0.9176 | 4000 | 3.757 | 4.9892 | 0.8407 | 0.7763 | 0.8447 | 0.8156 | 0.8478 | 0.8326 | 0.8488 |
| 0.9406 | 4100 | 3.7729 | 4.9859 | 0.8400 | 0.7751 | 0.8436 | 0.8141 | 0.8470 | 0.8317 | 0.8478 |
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}