bge-m3 Matryoshka

This is a sentence-transformers model finetuned from BAAI/bge-m3 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: BAAI/bge-m3
  • Maximum Sequence Length: 8192 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': 'cls', 'include_prompt': True})
  (2): Normalize({})
)

Usage

Direct Usage (Sentence Transformers)

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("IoannisKat1/bge-m3-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.3623, 0.0569, 0.0797]])

Evaluation

Metrics

Information Retrieval

Metric Value
cosine_accuracy@1 0.5579
cosine_accuracy@3 0.5726
cosine_accuracy@5 0.6695
cosine_accuracy@10 0.7368
cosine_precision@1 0.5579
cosine_precision@3 0.5516
cosine_precision@5 0.4434
cosine_precision@10 0.2592
cosine_recall@1 0.1609
cosine_recall@3 0.463
cosine_recall@5 0.6114
cosine_recall@10 0.716
cosine_ndcg@10 0.6405
cosine_mrr@10 0.5933
cosine_map@100 0.6327

Information Retrieval

Metric Value
cosine_accuracy@1 0.5642
cosine_accuracy@3 0.5832
cosine_accuracy@5 0.6653
cosine_accuracy@10 0.7284
cosine_precision@1 0.5642
cosine_precision@3 0.5579
cosine_precision@5 0.4429
cosine_precision@10 0.2571
cosine_recall@1 0.1639
cosine_recall@3 0.4725
cosine_recall@5 0.6116
cosine_recall@10 0.71
cosine_ndcg@10 0.6409
cosine_mrr@10 0.5971
cosine_map@100 0.6358

Information Retrieval

Metric Value
cosine_accuracy@1 0.5411
cosine_accuracy@3 0.5537
cosine_accuracy@5 0.6463
cosine_accuracy@10 0.7221
cosine_precision@1 0.5411
cosine_precision@3 0.5319
cosine_precision@5 0.4253
cosine_precision@10 0.2543
cosine_recall@1 0.1574
cosine_recall@3 0.4504
cosine_recall@5 0.5882
cosine_recall@10 0.7026
cosine_ndcg@10 0.6245
cosine_mrr@10 0.5753
cosine_map@100 0.6167

Information Retrieval

Metric Value
cosine_accuracy@1 0.5053
cosine_accuracy@3 0.52
cosine_accuracy@5 0.6232
cosine_accuracy@10 0.6989
cosine_precision@1 0.5053
cosine_precision@3 0.4975
cosine_precision@5 0.4063
cosine_precision@10 0.2474
cosine_recall@1 0.1481
cosine_recall@3 0.4196
cosine_recall@5 0.5591
cosine_recall@10 0.6823
cosine_ndcg@10 0.5984
cosine_mrr@10 0.5436
cosine_map@100 0.5891

Information Retrieval

Metric Value
cosine_accuracy@1 0.4547
cosine_accuracy@3 0.4674
cosine_accuracy@5 0.5832
cosine_accuracy@10 0.6505
cosine_precision@1 0.4547
cosine_precision@3 0.4484
cosine_precision@5 0.3693
cosine_precision@10 0.2295
cosine_recall@1 0.1318
cosine_recall@3 0.3775
cosine_recall@5 0.5096
cosine_recall@10 0.6321
cosine_ndcg@10 0.5481
cosine_mrr@10 0.4932
cosine_map@100 0.5415

Information Retrieval

Metric Value
cosine_accuracy@1 0.4042
cosine_accuracy@3 0.4147
cosine_accuracy@5 0.5032
cosine_accuracy@10 0.5832
cosine_precision@1 0.4042
cosine_precision@3 0.3993
cosine_precision@5 0.3208
cosine_precision@10 0.2013
cosine_recall@1 0.1195
cosine_recall@3 0.3416
cosine_recall@5 0.4479
cosine_recall@10 0.5579
cosine_ndcg@10 0.4848
cosine_mrr@10 0.4383
cosine_map@100 0.4849

Training Details

Training Dataset

json

  • Dataset: json
  • Size: 4,268 training samples
  • Columns: anchor and positive
  • Approximate statistics based on the first 100 samples:
    anchor positive
    type string string
    modality text text
    details
    • min: 9 tokens
    • mean: 17.49 tokens
    • max: 34 tokens
    • min: 21 tokens
    • mean: 102.99 tokens
    • max: 184 tokens
  • Samples:
    anchor positive
    Πόσο διαρκεί το προπτυχιακό πρόγραμμα σπουδών; . Το προπτυχιακό πρόγραμμα σπουδών έχει διάρκεια δέκα διδακτικών εξαμήνων και οδηγεί στην απονομή Διπλώματος Μηχανικού, το οποίο αναγνωρίζεται ως Integrated Master με πλήρη επαγγελματικά δικαιώματα
    Ποιες είναι οι αλγόριθμοι τοπικής αναζήτησης Ι; . Επίλυση προβλημάτων με αναζήτηση: Χώροι καταστάσεων, δέντρα αναζήτησης, μέθοδοι αναζήτησης χωρίς πληροφόρηση (depth-first, breadth-first), αναζήτηση με μερική πληροφόρηση. 3. Πληροφορημένη αναζήτηση και εξερεύνηση: Αλγόριθμοι Best First και Α*. 4. Αλγόριθμοι τοπικής αναζήτησης Ι: Hill climbing, simulated annealing. 5. Αλγόριθμοι τοπικής αναζήτησης ΙΙ: Γενετικοί αλγόριθμοι. 6
    Ποιες είναι οι δύο βασικές ικανότητες που σχετίζονται με την εφαρμογή στο εργαστήριο; . • Η ανάπτυξη της κριτικής σκέψης, της ικανότητας λήψης αποφάσεων, της επιδίωξης της καινοτομίας, του εξωστρεφούς τρόπου σκέψης, του πνεύματος συνεργασίας και της ομαδικής προσπάθειας, και της ικανότητας προσαρμογής σε μεταβαλλόμενες συνθήκες. • Η πλήρης κατανόηση και η ικανότητα εφαρμογής του θεωρητικού υπόβαθρου στο εργαστήριο
  • Loss: 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
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 16
  • num_train_epochs: 10
  • learning_rate: 2e-05
  • lr_scheduler_type: cosine
  • warmup_steps: 0.1
  • gradient_accumulation_steps: 8
  • bf16: True
  • tf32: True
  • load_best_model_at_end: True
  • batch_sampler: no_duplicates

All Hyperparameters

Click to expand
  • per_device_train_batch_size: 16
  • num_train_epochs: 10
  • max_steps: -1
  • learning_rate: 2e-05
  • lr_scheduler_type: cosine
  • lr_scheduler_kwargs: None
  • warmup_steps: 0.1
  • optim: adamw_torch_fused
  • 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: 8
  • 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: True
  • 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: 8
  • 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: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': 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: {}

Training Logs

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.2996 10 4.6184 - - - - - -
0.5993 20 3.8331 - - - - - -
0.8989 30 2.5099 - - - - - -
1.0 34 - 0.6199 0.6101 0.5977 0.5768 0.5202 0.3959
1.1798 40 2.0127 - - - - - -
1.4794 50 1.6530 - - - - - -
1.7790 60 1.6534 - - - - - -
2.0 68 - 0.6550 0.6484 0.6309 0.5980 0.5532 0.4497
2.0599 70 1.4525 - - - - - -
2.3596 80 0.8705 - - - - - -
2.6592 90 0.9917 - - - - - -
2.9588 100 0.9173 - - - - - -
3.0 102 - 0.6527 0.6528 0.6374 0.6068 0.5663 0.4678
3.2397 110 0.6969 - - - - - -
3.5393 120 0.6619 - - - - - -
3.8390 130 0.6238 - - - - - -
4.0 136 - 0.6446 0.6380 0.6246 0.5929 0.5616 0.4807
4.1199 140 0.5692 - - - - - -
4.4195 150 0.4249 - - - - - -
4.7191 160 0.4387 - - - - - -
5.0 170 0.4721 0.6293 0.6368 0.6257 0.5993 0.5619 0.4741
5.2996 180 0.3860 - - - - - -
5.5993 190 0.3624 - - - - - -
5.8989 200 0.3685 - - - - - -
6.0 204 - 0.6360 0.6357 0.6294 0.6083 0.5514 0.4851
6.1798 210 0.3870 - - - - - -
6.4794 220 0.3785 - - - - - -
6.7790 230 0.2833 - - - - - -
7.0 238 - 0.6344 0.6352 0.6194 0.5950 0.5475 0.4845
7.0599 240 0.3495 - - - - - -
7.3596 250 0.3182 - - - - - -
7.6592 260 0.3248 - - - - - -
7.9588 270 0.2856 - - - - - -
8.0 272 - 0.6425 0.6395 0.6259 0.6014 0.5521 0.4857
8.2397 280 0.2580 - - - - - -
8.5393 290 0.2360 - - - - - -
8.8390 300 0.2161 - - - - - -
9.0 306 - 0.6390 0.6398 0.6259 0.5983 0.5459 0.4841
9.1199 310 0.2612 - - - - - -
9.4195 320 0.2935 - - - - - -
9.7191 330 0.2273 - - - - - -
10.0 340 0.2497 0.6405 0.6409 0.6245 0.5984 0.5481 0.4848
  • The bold row denotes the saved checkpoint.

Training Time

  • Training: 7.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

@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

@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

@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},
}
Downloads last month
18
Safetensors
Model size
0.6B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for IoannisKat1/bge-m3-matryoshka

Base model

BAAI/bge-m3
Finetuned
(510)
this model

Papers for IoannisKat1/bge-m3-matryoshka

Evaluation results