CoolFace
Modelpublic

IoannisKat1/paraphrase-multilingual-mpnet-base-v2-matryoshka1

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes86downloads
Model Card

paraphrase-multilingual-mpnet-base-v2 Matryoshka

This is a sentence-transformers model finetuned from sentence-transformers/paraphrase-multilingual-mpnet-base-v2 on the json dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.

Model Details

Model Description

  • —Model Type: Sentence Transformer
  • —Base model: sentence-transformers/paraphrase-multilingual-mpnet-base-v2 <!-- at revision 4328cf26390c98c5e3c738b4460a05b95f4911f5 -->
  • —Maximum Sequence Length: 128 tokens
  • —Output Dimensionality: 768 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': 768, 'pooling_mode': 'mean', 'include_prompt': True})
)

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/paraphrase-multilingual-mpnet-base-v2-matryoshka1")
# Run inference
queries = [
    'Ποιες είναι οι δύο τύποι τροφοδοσίας που αναφέρονται;',
]
documents = [
    '. Ελεγκτές μεταβλητών στροφών και σχεδίαση σειριακού ελεγκτή με εσωτερικό βρόχο ρεύματος: ΑΜ διπλής τροφοδοσίας, ΑΜ ή ΣΜ με διασύνδεση συνεχούς ρεύματος, Γεννήτρια ΑΜ με ηλεκτρονικά μεταβαλλόμενη αντίσταση ρότορα. Έλεγχος πραγματικής και άεργου ισχύος. Έλεγχος βήματος πτερυγίου. Περιβαλλοντικές επιπτώσεις από την εγκατάσταση αιολικών συστημάτων και λοιπών ΑΠΕ. Σύνδεση με το δίκτυο',
    '. Τα υποχρεωτικά είναι συγκεκριμένα βασικά μαθήματα της επιστήμης του Ηλεκτρολόγου Μηχανικού και Μηχανικού Υπολογιστών, τα οποία πρέπει να παρακολουθήσει και εξεταστεί επιτυχώς κάθε φοιτητής. Τα κατ’ επιλογήν υποχρεωτικά είναι μαθήματα εμβάθυνσης σε διάφορους ειδικούς τομείς',
    'Η σελίδα παρουσιάζει τους Τομείς του Τμήματος Ηλεκτρολόγων Μηχανικών και Τεχνολογίας Υπολογιστών: Τηλεπικοινωνιών και Τεχνολογίας Πληροφορίας (Τ&ΤΠ), Συστημάτων Ηλεκτρικής Ενέργειας (ΣΗΕ), Ηλεκτρονικής και Υπολογιστών (Η&Υ) και Συστήματα και Αυτόματου Ελέγχου (Σ&ΑΕ)',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 768] [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.4992, 0.0232, 0.0659]])

<!--

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": 768
  }
MetricValue
cosine_accuracy@10.4568
cosine_accuracy@30.4821
cosine_accuracy@50.5937
cosine_accuracy@100.6716
cosine_precision@10.4568
cosine_precision@30.4625
cosine_precision@50.3777
cosine_precision@100.2354
cosine_recall@10.1307
cosine_recall@30.3889
cosine_recall@50.5212
cosine_recall@100.6518
cosine_ndcg@100.5605
cosine_mrr@100.5014
cosine_map@1000.5475
Information Retrieval
json
  {
      "truncate_dim": 512
  }
MetricValue
cosine_accuracy@10.4421
cosine_accuracy@30.4589
cosine_accuracy@50.5937
cosine_accuracy@100.6568
cosine_precision@10.4421
cosine_precision@30.4435
cosine_precision@50.3676
cosine_precision@100.2305
cosine_recall@10.1272
cosine_recall@30.3742
cosine_recall@50.5116
cosine_recall@100.64
cosine_ndcg@100.5475
cosine_mrr@100.4867
cosine_map@1000.5341
Information Retrieval
json
  {
      "truncate_dim": 256
  }
MetricValue
cosine_accuracy@10.4611
cosine_accuracy@30.4779
cosine_accuracy@50.5811
cosine_accuracy@100.6463
cosine_precision@10.4611
cosine_precision@30.4625
cosine_precision@50.3735
cosine_precision@100.2272
cosine_recall@10.1325
cosine_recall@30.3911
cosine_recall@50.5165
cosine_recall@100.6323
cosine_ndcg@100.5515
cosine_mrr@100.4993
cosine_map@1000.5409
Information Retrieval
json
  {
      "truncate_dim": 128
  }
MetricValue
cosine_accuracy@10.4084
cosine_accuracy@30.4295
cosine_accuracy@50.5284
cosine_accuracy@100.6042
cosine_precision@10.4084
cosine_precision@30.4084
cosine_precision@50.3343
cosine_precision@100.2099
cosine_recall@10.1193
cosine_recall@30.3461
cosine_recall@50.4646
cosine_recall@100.5847
cosine_ndcg@100.501
cosine_mrr@100.4471
cosine_map@1000.494
Information Retrieval
json
  {
      "truncate_dim": 64
  }
MetricValue
cosine_accuracy@10.3495
cosine_accuracy@30.3663
cosine_accuracy@50.4653
cosine_accuracy@100.5326
cosine_precision@10.3495
cosine_precision@30.3495
cosine_precision@50.2888
cosine_precision@100.1855
cosine_recall@10.1025
cosine_recall@30.2977
cosine_recall@50.4021
cosine_recall@100.5165
cosine_ndcg@100.4381
cosine_mrr@100.3867
cosine_map@1000.4324

<!--

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: 97.85 tokens</li><li>max: 128 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": [
          768,
          512,
          256,
          128,
          64
      ],
      "matryoshka_weights": [
          1,
          1,
          1,
          1,
          1
      ],
      "n_dims_per_step": -1
  }

Training Hyperparameters

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

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

  • —overwrite_output_dir: False
  • —do_predict: False
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 16
  • —per_device_eval_batch_size: 8
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 8
  • —eval_accumulation_steps: None
  • —torch_empty_cache_steps: None
  • —learning_rate: 2e-05
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —max_grad_norm: 1.0
  • —num_train_epochs: 10
  • —max_steps: -1
  • —lr_scheduler_type: cosine
  • —lr_scheduler_kwargs: None
  • —warmup_ratio: 0.1
  • —warmup_steps: 0
  • —log_level: passive
  • —log_level_replica: warning
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —save_safetensors: True
  • —save_on_each_node: False
  • —save_only_model: False
  • —restore_callback_states_from_checkpoint: False
  • —no_cuda: False
  • —use_cpu: False
  • —use_mps_device: False
  • —seed: 42
  • —data_seed: None
  • —jit_mode_eval: False
  • —bf16: True
  • —fp16: False
  • —fp16_opt_level: O1
  • —half_precision_backend: auto
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: True
  • —local_rank: 0
  • —ddp_backend: None
  • —tpu_num_cores: None
  • —tpu_metrics_debug: False
  • —debug: []
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_prefetch_factor: None
  • —past_index: -1
  • —disable_tqdm: False
  • —remove_unused_columns: True
  • —label_names: None
  • —load_best_model_at_end: True
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_min_num_params: 0
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —parallelism_config: None
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamwtorchfused
  • —optim_args: None
  • —adafactor: False
  • —group_by_length: False
  • —length_column_name: length
  • —project: huggingface
  • —trackio_space_id: trackio
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —skip_memory_metrics: True
  • —use_legacy_prediction_loop: False
  • —push_to_hub: False
  • —resume_from_checkpoint: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_private_repo: None
  • —hub_always_push: False
  • —hub_revision: None
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —include_for_metrics: []
  • —eval_do_concat_batches: True
  • —fp16_backend: auto
  • —push_to_hub_model_id: None
  • —push_to_hub_organization: None
  • —mp_parameters:
  • —auto_find_batch_size: False
  • —full_determinism: False
  • —torchdynamo: None
  • —ray_scope: last
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —include_tokens_per_second: False
  • —include_num_input_tokens_seen: no
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_eval_metrics: False
  • —eval_on_start: False
  • —use_liger_kernel: False
  • —liger_kernel_config: None
  • —eval_use_gather_object: False
  • —average_tokens_across_devices: True
  • —prompts: None
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional
  • —router_mapping: {}
  • —learning_rate_mapping: {}

</details>

Training Logs

EpochStepTraining Lossdim_768_cosine_ndcg@10dim_512_cosine_ndcg@10dim_256_cosine_ndcg@10dim_128_cosine_ndcg@10dim_64_cosine_ndcg@10
0.2996105.9428-----
0.5993204.8632-----
0.8989303.3627-----
1.034-0.45170.43940.42620.37570.3146
1.1798402.5802-----
1.4794502.2302-----
1.7790602.0218-----
2.068-0.48900.48560.47250.43810.3718
2.0599701.811-----
2.3596801.1706-----
2.6592901.378-----
2.95881001.1579-----
3.0102-0.51150.50630.50790.46330.3826
3.23971100.8626-----
3.53931200.7512-----
3.83901300.7822-----
4.0136-0.53700.52520.51740.48430.4049
4.11991400.7102-----
4.41951500.6134-----
4.71911600.6054-----
5.01700.62140.53860.53450.52840.48180.4166
5.29961800.4855-----
5.59931900.5363-----
5.89892000.5715-----
6.0204-0.54190.53880.53920.48880.4263
6.17982100.4733-----
6.47942200.4234-----
6.77902300.4053-----
7.0238-0.55420.54630.54750.49470.4350
7.05992400.4324-----
7.35962500.3588-----
7.65922600.4547-----
7.95882700.389-----
8.0272-0.56770.55230.55870.50210.4377
8.23972800.3959-----
8.53932900.3051-----
8.83903000.3716-----
9.0306-0.56380.54770.55350.50090.4372
9.11993100.3123-----
9.41953200.3051-----
9.71913300.2942-----
10.03400.31270.56050.54750.55150.50100.4381
  • —The bold row denotes the saved checkpoint.

Training Time

  • —Training: 5.4 minutes

Framework Versions

  • —Python: 3.12.13
  • —Sentence Transformers: 5.6.0
  • —Transformers: 4.57.6
  • —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. -->