CoolFace
Modelpublic

IoannisKat1/multilingual-e5-large-matryoshka

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
0likes110downloads
Model Card

multilingual-e5-large base Matryoshka

This is a sentence-transformers model finetuned from intfloat/multilingual-e5-large on the json dataset. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for retrieval.

Model Details

Model Description

  • —Model Type: Sentence Transformer
  • —Base model: intfloat/multilingual-e5-large <!-- at revision 3d7cfbdacd47fdda877c5cd8a79fbcc4f2a574f3 -->
  • —Maximum Sequence Length: 512 tokens
  • —Output Dimensionality: 1024 dimensions
  • —Similarity Function: Cosine Similarity
  • —Supported Modality: Text
  • —Training Dataset:
  • —json
  • —Language: en
  • —License: apache-2.0

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'XLMRobertaModel'})
  (1): Pooling({'embedding_dimension': 1024, 'pooling_mode': 'mean', 'include_prompt': True})
  (2): Normalize({})
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("IoannisKat1/multilingual-e5-large-matryoshka")
# Run inference
queries = [
    'Ποιες είναι οι δύο τύποι τροφοδοσίας που αναφέρονται;',
]
documents = [
    '. Ελεγκτές μεταβλητών στροφών και σχεδίαση σειριακού ελεγκτή με εσωτερικό βρόχο ρεύματος: ΑΜ διπλής τροφοδοσίας, ΑΜ ή ΣΜ με διασύνδεση συνεχούς ρεύματος, Γεννήτρια ΑΜ με ηλεκτρονικά μεταβαλλόμενη αντίσταση ρότορα. Έλεγχος πραγματικής και άεργου ισχύος. Έλεγχος βήματος πτερυγίου. Περιβαλλοντικές επιπτώσεις από την εγκατάσταση αιολικών συστημάτων και λοιπών ΑΠΕ. Σύνδεση με το δίκτυο',
    '. Τα υποχρεωτικά είναι συγκεκριμένα βασικά μαθήματα της επιστήμης του Ηλεκτρολόγου Μηχανικού και Μηχανικού Υπολογιστών, τα οποία πρέπει να παρακολουθήσει και εξεταστεί επιτυχώς κάθε φοιτητής. Τα κατ’ επιλογήν υποχρεωτικά είναι μαθήματα εμβάθυνσης σε διάφορους ειδικούς τομείς',
    'Η σελίδα παρουσιάζει τους Τομείς του Τμήματος Ηλεκτρολόγων Μηχανικών και Τεχνολογίας Υπολογιστών: Τηλεπικοινωνιών και Τεχνολογίας Πληροφορίας (Τ&ΤΠ), Συστημάτων Ηλεκτρικής Ενέργειας (ΣΗΕ), Ηλεκτρονικής και Υπολογιστών (Η&Υ) και Συστήματα και Αυτόματου Ελέγχου (Σ&ΑΕ)',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 1024] [3, 1024]

# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.3994, 0.0838, 0.1636]])

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Information Retrieval
json
  {
      "truncate_dim": 1024
  }
MetricValue
cosine_accuracy@10.5137
cosine_accuracy@30.5516
cosine_accuracy@50.6716
cosine_accuracy@100.7368
cosine_precision@10.5137
cosine_precision@30.5228
cosine_precision@50.4291
cosine_precision@100.2596
cosine_recall@10.1486
cosine_recall@30.4425
cosine_recall@50.5951
cosine_recall@100.717
cosine_ndcg@100.6257
cosine_mrr@100.5642
cosine_map@1000.6135
Information Retrieval
json
  {
      "truncate_dim": 768
  }
MetricValue
cosine_accuracy@10.5179
cosine_accuracy@30.5537
cosine_accuracy@50.6632
cosine_accuracy@100.7474
cosine_precision@10.5179
cosine_precision@30.527
cosine_precision@50.4299
cosine_precision@100.2636
cosine_recall@10.1495
cosine_recall@30.4454
cosine_recall@50.5926
cosine_recall@100.7281
cosine_ndcg@100.6323
cosine_mrr@100.5688
cosine_map@1000.6172
Information Retrieval
json
  {
      "truncate_dim": 512
  }
MetricValue
cosine_accuracy@10.4905
cosine_accuracy@30.5221
cosine_accuracy@50.6526
cosine_accuracy@100.7179
cosine_precision@10.4905
cosine_precision@30.4989
cosine_precision@50.4139
cosine_precision@100.2558
cosine_recall@10.1409
cosine_recall@30.4193
cosine_recall@50.57
cosine_recall@100.7042
cosine_ndcg@100.6075
cosine_mrr@100.542
cosine_map@1000.5927
Information Retrieval
json
  {
      "truncate_dim": 256
  }
MetricValue
cosine_accuracy@10.4758
cosine_accuracy@30.5095
cosine_accuracy@50.6168
cosine_accuracy@100.6968
cosine_precision@10.4758
cosine_precision@30.4856
cosine_precision@50.3966
cosine_precision@100.2455
cosine_recall@10.1375
cosine_recall@30.4098
cosine_recall@50.5477
cosine_recall@100.6763
cosine_ndcg@100.5852
cosine_mrr@100.5242
cosine_map@1000.5738
Information Retrieval
json
  {
      "truncate_dim": 128
  }
MetricValue
cosine_accuracy@10.4505
cosine_accuracy@30.4842
cosine_accuracy@50.5726
cosine_accuracy@100.6463
cosine_precision@10.4505
cosine_precision@30.4604
cosine_precision@50.3735
cosine_precision@100.2248
cosine_recall@10.1286
cosine_recall@30.3875
cosine_recall@50.5175
cosine_recall@100.623
cosine_ndcg@100.544
cosine_mrr@100.4933
cosine_map@1000.5404
Information Retrieval
json
  {
      "truncate_dim": 64
  }
MetricValue
cosine_accuracy@10.3705
cosine_accuracy@30.3937
cosine_accuracy@50.4842
cosine_accuracy@100.5747
cosine_precision@10.3705
cosine_precision@30.3754
cosine_precision@50.3099
cosine_precision@100.1989
cosine_recall@10.107
cosine_recall@30.3154
cosine_recall@50.4288
cosine_recall@100.5542
cosine_ndcg@100.4668
cosine_mrr@100.4122
cosine_map@1000.4584

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

json
  • —Dataset: json
  • —Size: 4,268 training samples
  • —Columns: <code>anchor</code> and <code>positive</code>
  • —Approximate statistics based on the first 100 samples: | | anchor | positive | |:---------|:----------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------| | type | string | string | | modality | text | text | | details | <ul><li>min: 9 tokens</li><li>mean: 17.49 tokens</li><li>max: 34 tokens</li></ul> | <ul><li>min: 21 tokens</li><li>mean: 102.99 tokens</li><li>max: 184 tokens</li></ul> |
  • —Samples: | anchor | positive | |:---------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Πόσο διαρκεί το προπτυχιακό πρόγραμμα σπουδών;</code> | <code>. Το προπτυχιακό πρόγραμμα σπουδών έχει διάρκεια δέκα διδακτικών εξαμήνων και οδηγεί στην απονομή Διπλώματος Μηχανικού, το οποίο αναγνωρίζεται ως Integrated Master με πλήρη επαγγελματικά δικαιώματα</code> | | <code>Ποιες είναι οι αλγόριθμοι τοπικής αναζήτησης Ι;</code> | <code>. Επίλυση προβλημάτων με αναζήτηση: Χώροι καταστάσεων, δέντρα αναζήτησης, μέθοδοι αναζήτησης χωρίς πληροφόρηση (depth-first, breadth-first), αναζήτηση με μερική πληροφόρηση. 3. Πληροφορημένη αναζήτηση και εξερεύνηση: Αλγόριθμοι Best First και Α*. 4. Αλγόριθμοι τοπικής αναζήτησης Ι: Hill climbing, simulated annealing. 5. Αλγόριθμοι τοπικής αναζήτησης ΙΙ: Γενετικοί αλγόριθμοι. 6</code> | | <code>Ποιες είναι οι δύο βασικές ικανότητες που σχετίζονται με την εφαρμογή στο εργαστήριο;</code> | <code>. • Η ανάπτυξη της κριτικής σκέψης, της ικανότητας λήψης αποφάσεων, της επιδίωξης της καινοτομίας, του εξωστρεφούς τρόπου σκέψης, του πνεύματος συνεργασίας και της ομαδικής προσπάθειας, και της ικανότητας προσαρμογής σε μεταβαλλόμενες συνθήκες. • Η πλήρης κατανόηση και η ικανότητα εφαρμογής του θεωρητικού υπόβαθρου στο εργαστήριο</code> |
  • —Loss: <code>MatryoshkaLoss</code> with these parameters:
json
  {
      "loss": "MultipleNegativesRankingLoss",
      "matryoshka_dims": [
          1024,
          768,
          512,
          256,
          128,
          64
      ],
      "matryoshka_weights": [
          1,
          1,
          1,
          1,
          1,
          1
      ],
      "n_dims_per_step": -1
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —per_device_train_batch_size: 32
  • —num_train_epochs: 10
  • —learning_rate: 2e-05
  • —lr_scheduler_type: cosine
  • —warmup_steps: 0.1
  • —gradient_accumulation_steps: 16
  • —bf16: True
  • —tf32: False
  • —per_device_eval_batch_size: 16
  • —load_best_model_at_end: True
  • —batch_sampler: no_duplicates
All Hyperparameters

<details><summary>Click to expand</summary>

  • —per_device_train_batch_size: 32
  • —num_train_epochs: 10
  • —max_steps: -1
  • —learning_rate: 2e-05
  • —lr_scheduler_type: cosine
  • —lr_scheduler_kwargs: None
  • —warmup_steps: 0.1
  • —optim: adamwtorchfused
  • —optim_args: None
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —optim_target_modules: None
  • —gradient_accumulation_steps: 16
  • —average_tokens_across_devices: True
  • —max_grad_norm: 1.0
  • —label_smoothing_factor: 0.0
  • —bf16: True
  • —fp16: False
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: False
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —use_liger_kernel: False
  • —liger_kernel_config: None
  • —use_cache: False
  • —neftune_noise_alpha: None
  • —torch_empty_cache_steps: None
  • —auto_find_batch_size: False
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —include_num_input_tokens_seen: no
  • —log_level: passive
  • —log_level_replica: warning
  • —disable_tqdm: False
  • —project: huggingface
  • —trackio_space_id: None
  • —trackio_bucket_id: None
  • —trackio_static_space_id: None
  • —per_device_eval_batch_size: 16
  • —prediction_loss_only: True
  • —eval_on_start: False
  • —eval_do_concat_batches: True
  • —eval_use_gather_object: False
  • —eval_accumulation_steps: None
  • —include_for_metrics: []
  • —batch_eval_metrics: False
  • —save_only_model: False
  • —save_on_each_node: False
  • —enable_jit_checkpoint: False
  • —push_to_hub: False
  • —hub_private_repo: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_always_push: False
  • —hub_revision: None
  • —load_best_model_at_end: True
  • —ignore_data_skip: False
  • —restore_callback_states_from_checkpoint: False
  • —full_determinism: False
  • —seed: 42
  • —data_seed: None
  • —use_cpu: False
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —parallelism_config: None
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —dataloader_prefetch_factor: None
  • —remove_unused_columns: True
  • —label_names: None
  • —train_sampling_strategy: random
  • —length_column_name: length
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —ddp_static_graph: None
  • —ddp_backend: None
  • —ddp_timeout: 1800
  • —fsdp: None
  • —fsdp_config: None
  • —deepspeed: None
  • —debug: []
  • —skip_memory_metrics: True
  • —do_predict: False
  • —resume_from_checkpoint: None
  • —warmup_ratio: None
  • —local_rank: -1
  • —prompts: None
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional
  • —router_mapping: {}
  • —learning_rate_mapping: {}

</details>

Training Logs

EpochStepTraining Lossdim_1024_cosine_ndcg@10dim_768_cosine_ndcg@10dim_512_cosine_ndcg@10dim_256_cosine_ndcg@10dim_128_cosine_ndcg@10dim_64_cosine_ndcg@10
1.09-0.50860.50570.49760.46400.41980.3376
1.11941011.6335------
2.018-0.50350.49780.49380.47810.45040.3969
2.2388205.7000------
3.027-0.57230.57270.55940.55030.49530.4321
3.3582303.3180------
4.036-0.60520.59610.58470.56030.51550.4487
4.4776402.3573------
5.045-0.61250.60960.59050.57520.52620.4570
5.5970501.8056------
6.054-0.61480.61380.59810.57140.53810.4558
6.7164601.6216------
7.063-0.61900.62390.60200.57890.54100.4596
7.8358701.4629------
8.072-0.62330.62920.61150.58270.54660.465
8.9552801.2774------
9.081-0.62240.62960.60310.58400.54230.4698
10.0901.35630.62570.63230.60750.58520.54400.4668
  • —The bold row denotes the saved checkpoint.

Training Time

  • —Training: 6.9 minutes

Framework Versions

  • —Python: 3.12.13
  • —Sentence Transformers: 5.6.0
  • —Transformers: 5.12.1
  • —PyTorch: 2.11.0+cu128
  • —Accelerate: 1.14.0
  • —Datasets: 4.0.0
  • —Tokenizers: 0.22.2

Citation

BibTeX

Sentence Transformers
bibtex
@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",
}
MatryoshkaLoss
bibtex
@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}
}
MultipleNegativesRankingLoss
bibtex
@misc{oord2019representationlearningcontrastivepredictive,
      title={Representation Learning with Contrastive Predictive Coding},
      author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
      year={2019},
      eprint={1807.03748},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/1807.03748},
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->