Matryoshka Representation Learning
Paper
•
2205.13147
•
Published
•
25
This is a sentence-transformers model finetuned from intfloat/multilingual-e5-large on the data dataset. It maps sentences & paragraphs to a 1024-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: XLMRobertaModel
(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})
(2): Normalize()
)
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("mik3ml/multilingual-e5-large-ita")
# Run inference
sentences = [
"Precipitine sieriche contro i microbi nel fieno ammuffito rispetto all'età, al sesso, all'atopia e al fumo degli agricoltori.Questo studio si è basato su un campione di 3.065 agricoltori su una popolazione più ampia di 12.056 agricoltori finlandesi. I dati sono stati raccolti in un'indagine postale condotta dall'Istituto di previdenza sociale della Finlandia. Campioni di siero per la determinazione degli anticorpi precipitanti sono stati prelevati presso i centri sanitari locali. Le precipitazioni sono state determinate con il metodo della micropiastra diffusione immunitaria. Il pannello dell'antigene era costituito da antigeni miceliali di Micropolyspora faeni, Thermoactinomyces vulgaris, Aspergillus fumigatus e Aspergillus umbrosus. Precipitine a uno qualsiasi dei quattro microbi sono state rilevate nell'8,6% dei sieri. Le cause più comuni di test di precipitina positivi erano Aspergillus umbrosus e Thermoactinomyces vulgaris, che concorda con i risultati precedenti riportati dalla Finlandia In generale, le precipitine erano più prevalenti tra le donne, il che corrisponde alle tradizioni culturali locali e negli agricoltori più anziani. La prevalenza delle precipitine non differiva tra i soggetti non atopici e atopici (definiti come coesistenza passata o presente di dermatite atopica inclusi eczema infantile e/o febbre da fieno o altre riniti allergiche). Al contrario, la prevalenza delle precipitine era circa 1,5-2 volte maggiore tra i non fumatori rispetto ai fumatori, il che conferma i risultati dei rapporti precedenti. Negli studi futuri sulla presenza di precipitine, i dati dovrebbero essere controllati rispetto all'età, al sesso e al fumo. ",
'Quali sono i quattro microbi che sono stati utilizzati per la determinazione delle precipitine nel siero degli agricoltori?',
'Le strutture tricline delle proteine bovine a basso pH e ovine ad alto pH sono simili nonostante la transizione conformazionale pH-dipendente delle proteine bovina e suina?',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
dim_1024, dim_768, dim_512, dim_256, dim_128 and dim_64InformationRetrievalEvaluator| Metric | dim_1024 | dim_768 | dim_512 | dim_256 | dim_128 | dim_64 |
|---|---|---|---|---|---|---|
| cosine_accuracy@1 | 0.7948 | 0.7928 | 0.7922 | 0.7871 | 0.7779 | 0.7548 |
| cosine_accuracy@3 | 0.9205 | 0.9199 | 0.9188 | 0.9129 | 0.9046 | 0.8832 |
| cosine_accuracy@5 | 0.9347 | 0.9341 | 0.9316 | 0.9268 | 0.9178 | 0.8993 |
| cosine_accuracy@10 | 0.9474 | 0.9466 | 0.9447 | 0.9414 | 0.9329 | 0.918 |
| cosine_precision@1 | 0.7948 | 0.7928 | 0.7922 | 0.7871 | 0.7779 | 0.7548 |
| cosine_precision@3 | 0.3068 | 0.3066 | 0.3063 | 0.3043 | 0.3015 | 0.2944 |
| cosine_precision@5 | 0.1869 | 0.1868 | 0.1863 | 0.1854 | 0.1836 | 0.1799 |
| cosine_precision@10 | 0.0947 | 0.0947 | 0.0945 | 0.0941 | 0.0933 | 0.0918 |
| cosine_recall@1 | 0.7948 | 0.7928 | 0.7922 | 0.7871 | 0.7779 | 0.7548 |
| cosine_recall@3 | 0.9205 | 0.9199 | 0.9188 | 0.9129 | 0.9046 | 0.8832 |
| cosine_recall@5 | 0.9347 | 0.9341 | 0.9316 | 0.9268 | 0.9178 | 0.8993 |
| cosine_recall@10 | 0.9474 | 0.9466 | 0.9447 | 0.9414 | 0.9329 | 0.918 |
| cosine_ndcg@10 | 0.8818 | 0.8805 | 0.8793 | 0.8747 | 0.8658 | 0.8459 |
| cosine_mrr@10 | 0.8597 | 0.8582 | 0.8572 | 0.8522 | 0.8432 | 0.8219 |
| cosine_map@100 | 0.8611 | 0.8596 | 0.8586 | 0.8537 | 0.8449 | 0.8238 |
positive and anchor| positive | anchor | |
|---|---|---|
| type | string | string |
| details |
|
|
| positive | anchor |
|---|---|
Thomas Poulsen |
In quale categoria ha vinto la sua unica medaglia olimpica? |
Porta di Saint Denis |
Quali elementi architettonici e decorativi sono presenti nell'arco di trionfo di Saint Denis? |
Provincia di Venezia |
Chi sostituì l'omonimo ente amministrativo austriaco? |
MatryoshkaLoss with these parameters:{
"loss": "MultipleNegativesRankingLoss",
"matryoshka_dims": [
1024,
768,
512,
256,
128,
64
],
"matryoshka_weights": [
1,
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
eval_strategy: epochper_device_train_batch_size: 32per_device_eval_batch_size: 16gradient_accumulation_steps: 16learning_rate: 2e-05lr_scheduler_type: cosinewarmup_ratio: 0.1bf16: Truetf32: Trueload_best_model_at_end: Trueoptim: adamw_torch_fusedbatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: epochprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 16per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 16eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 3max_steps: -1lr_scheduler_type: cosinelr_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: Truefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Truelocal_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: Trueignore_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_torch_fusedoptim_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: 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: Falseprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | dim_1024_cosine_ndcg@10 | dim_768_cosine_ndcg@10 | dim_512_cosine_ndcg@10 | dim_256_cosine_ndcg@10 | dim_128_cosine_ndcg@10 | dim_64_cosine_ndcg@10 |
|---|---|---|---|---|---|---|---|---|
| 0.0281 | 10 | 136.2519 | - | - | - | - | - | - |
| 0.0562 | 20 | 93.5635 | - | - | - | - | - | - |
| 0.0843 | 30 | 39.1184 | - | - | - | - | - | - |
| 0.1124 | 40 | 19.4777 | - | - | - | - | - | - |
| 0.1405 | 50 | 10.0755 | - | - | - | - | - | - |
| 0.1686 | 60 | 7.4115 | - | - | - | - | - | - |
| 0.1967 | 70 | 5.8366 | - | - | - | - | - | - |
| 0.2248 | 80 | 5.6908 | - | - | - | - | - | - |
| 0.2529 | 90 | 5.6481 | - | - | - | - | - | - |
| 0.2809 | 100 | 4.8332 | - | - | - | - | - | - |
| 0.3090 | 110 | 5.2106 | - | - | - | - | - | - |
| 0.3371 | 120 | 5.2924 | - | - | - | - | - | - |
| 0.3652 | 130 | 4.2509 | - | - | - | - | - | - |
| 0.3933 | 140 | 4.0525 | - | - | - | - | - | - |
| 0.4214 | 150 | 3.7339 | - | - | - | - | - | - |
| 0.4495 | 160 | 3.4459 | - | - | - | - | - | - |
| 0.4776 | 170 | 3.4454 | - | - | - | - | - | - |
| 0.5057 | 180 | 3.5051 | - | - | - | - | - | - |
| 0.5338 | 190 | 3.1434 | - | - | - | - | - | - |
| 0.5619 | 200 | 3.4567 | - | - | - | - | - | - |
| 0.5900 | 210 | 3.7854 | - | - | - | - | - | - |
| 0.6181 | 220 | 3.7576 | - | - | - | - | - | - |
| 0.6462 | 230 | 3.2254 | - | - | - | - | - | - |
| 0.6743 | 240 | 3.5808 | - | - | - | - | - | - |
| 0.7024 | 250 | 3.7216 | - | - | - | - | - | - |
| 0.7305 | 260 | 2.9924 | - | - | - | - | - | - |
| 0.7586 | 270 | 3.4136 | - | - | - | - | - | - |
| 0.7867 | 280 | 3.4912 | - | - | - | - | - | - |
| 0.8147 | 290 | 3.1589 | - | - | - | - | - | - |
| 0.8428 | 300 | 3.1169 | - | - | - | - | - | - |
| 0.8709 | 310 | 3.2492 | - | - | - | - | - | - |
| 0.8990 | 320 | 3.0045 | - | - | - | - | - | - |
| 0.9271 | 330 | 3.424 | - | - | - | - | - | - |
| 0.9552 | 340 | 3.0119 | - | - | - | - | - | - |
| 0.9833 | 350 | 2.8333 | - | - | - | - | - | - |
| 0.9974 | 355 | - | 0.8821 | 0.8805 | 0.8795 | 0.8720 | 0.8617 | 0.8327 |
| 1.0114 | 360 | 3.1381 | - | - | - | - | - | - |
| 1.0395 | 370 | 2.7908 | - | - | - | - | - | - |
| 1.0676 | 380 | 2.5703 | - | - | - | - | - | - |
| 1.0957 | 390 | 2.5087 | - | - | - | - | - | - |
| 1.1238 | 400 | 2.3044 | - | - | - | - | - | - |
| 1.1519 | 410 | 2.0035 | - | - | - | - | - | - |
| 1.1800 | 420 | 1.8526 | - | - | - | - | - | - |
| 1.2081 | 430 | 1.8608 | - | - | - | - | - | - |
| 1.2362 | 440 | 1.6593 | - | - | - | - | - | - |
| 1.2643 | 450 | 1.8343 | - | - | - | - | - | - |
| 1.2924 | 460 | 1.4608 | - | - | - | - | - | - |
| 1.3205 | 470 | 1.4987 | - | - | - | - | - | - |
| 1.3486 | 480 | 1.4047 | - | - | - | - | - | - |
| 1.3766 | 490 | 1.449 | - | - | - | - | - | - |
| 1.4047 | 500 | 1.2679 | - | - | - | - | - | - |
| 1.4328 | 510 | 1.3128 | - | - | - | - | - | - |
| 1.4609 | 520 | 1.1416 | - | - | - | - | - | - |
| 1.4890 | 530 | 1.1702 | - | - | - | - | - | - |
| 1.5171 | 540 | 0.875 | - | - | - | - | - | - |
| 1.5452 | 550 | 1.1781 | - | - | - | - | - | - |
| 1.5733 | 560 | 1.2128 | - | - | - | - | - | - |
| 1.6014 | 570 | 1.407 | - | - | - | - | - | - |
| 1.6295 | 580 | 1.0243 | - | - | - | - | - | - |
| 1.6576 | 590 | 1.2503 | - | - | - | - | - | - |
| 1.6857 | 600 | 1.1823 | - | - | - | - | - | - |
| 1.7138 | 610 | 0.9505 | - | - | - | - | - | - |
| 1.7419 | 620 | 1.1575 | - | - | - | - | - | - |
| 1.7700 | 630 | 1.1425 | - | - | - | - | - | - |
| 1.7981 | 640 | 1.2302 | - | - | - | - | - | - |
| 1.8262 | 650 | 1.2546 | - | - | - | - | - | - |
| 1.8543 | 660 | 1.1812 | - | - | - | - | - | - |
| 1.8824 | 670 | 1.2926 | - | - | - | - | - | - |
| 1.9104 | 680 | 1.2066 | - | - | - | - | - | - |
| 1.9385 | 690 | 1.2115 | - | - | - | - | - | - |
| 1.9666 | 700 | 1.0249 | - | - | - | - | - | - |
| 1.9947 | 710 | 1.1983 | - | - | - | - | - | - |
| 1.9975 | 711 | - | 0.8836 | 0.8823 | 0.8805 | 0.8752 | 0.8661 | 0.8446 |
| 2.0228 | 720 | 0.9967 | - | - | - | - | - | - |
| 2.0509 | 730 | 1.0107 | - | - | - | - | - | - |
| 2.0790 | 740 | 0.9413 | - | - | - | - | - | - |
| 2.1071 | 750 | 0.925 | - | - | - | - | - | - |
| 2.1352 | 760 | 0.5456 | - | - | - | - | - | - |
| 2.1633 | 770 | 0.6579 | - | - | - | - | - | - |
| 2.1914 | 780 | 0.6707 | - | - | - | - | - | - |
| 2.2195 | 790 | 0.6353 | - | - | - | - | - | - |
| 2.2476 | 800 | 0.5963 | - | - | - | - | - | - |
| 2.2757 | 810 | 0.6415 | - | - | - | - | - | - |
| 2.3038 | 820 | 0.5406 | - | - | - | - | - | - |
| 2.3319 | 830 | 0.6237 | - | - | - | - | - | - |
| 2.3600 | 840 | 0.624 | - | - | - | - | - | - |
| 2.3881 | 850 | 0.6492 | - | - | - | - | - | - |
| 2.4162 | 860 | 0.5391 | - | - | - | - | - | - |
| 2.4442 | 870 | 0.5127 | - | - | - | - | - | - |
| 2.4723 | 880 | 0.4845 | - | - | - | - | - | - |
| 2.5004 | 890 | 0.4985 | - | - | - | - | - | - |
| 2.5285 | 900 | 0.3705 | - | - | - | - | - | - |
| 2.5566 | 910 | 0.6361 | - | - | - | - | - | - |
| 2.5847 | 920 | 0.5917 | - | - | - | - | - | - |
| 2.6128 | 930 | 0.7143 | - | - | - | - | - | - |
| 2.6409 | 940 | 0.4301 | - | - | - | - | - | - |
| 2.6690 | 950 | 0.596 | - | - | - | - | - | - |
| 2.6971 | 960 | 0.5491 | - | - | - | - | - | - |
| 2.7252 | 970 | 0.4395 | - | - | - | - | - | - |
| 2.7533 | 980 | 0.5665 | - | - | - | - | - | - |
| 2.7814 | 990 | 0.6238 | - | - | - | - | - | - |
| 2.8095 | 1000 | 0.673 | - | - | - | - | - | - |
| 2.8376 | 1010 | 0.6221 | - | - | - | - | - | - |
| 2.8657 | 1020 | 0.8164 | - | - | - | - | - | - |
| 2.8938 | 1030 | 0.6686 | - | - | - | - | - | - |
| 2.9219 | 1040 | 0.8187 | - | - | - | - | - | - |
| 2.9500 | 1050 | 0.5303 | - | - | - | - | - | - |
| 2.9781 | 1060 | 0.6483 | - | - | - | - | - | - |
| 2.9921 | 1065 | - | 0.8818 | 0.8805 | 0.8793 | 0.8747 | 0.8658 | 0.8459 |
@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{kusupati2024matryoshka,
title={Matryoshka Representation Learning},
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},
year={2024},
eprint={2205.13147},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
@misc{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
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},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
Base model
intfloat/multilingual-e5-largeTotally Free + Zero Barriers + No Login Required