embeddinggemma-300m Matryoshka

This is a sentence-transformers model finetuned from google/embeddinggemma-300m 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: google/embeddinggemma-300m
  • Maximum Sequence Length: 2048 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': 'Gemma3TextModel'})
  (1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
  (2): Dense({'in_features': 768, 'out_features': 3072, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity', 'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'})
  (3): Dense({'in_features': 3072, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity', 'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'})
  (4): 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/embeddinggemma-300m-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.4588,  0.0118, -0.0126]])

Evaluation

Metrics

Information Retrieval

Metric Value
cosine_accuracy@1 0.5116
cosine_accuracy@3 0.5389
cosine_accuracy@5 0.6547
cosine_accuracy@10 0.7032
cosine_precision@1 0.5116
cosine_precision@3 0.5137
cosine_precision@5 0.4173
cosine_precision@10 0.2501
cosine_recall@1 0.1481
cosine_recall@3 0.4379
cosine_recall@5 0.5805
cosine_recall@10 0.6914
cosine_ndcg@10 0.6097
cosine_mrr@10 0.5545
cosine_map@100 0.601

Information Retrieval

Metric Value
cosine_accuracy@1 0.5179
cosine_accuracy@3 0.5326
cosine_accuracy@5 0.6421
cosine_accuracy@10 0.6884
cosine_precision@1 0.5179
cosine_precision@3 0.5144
cosine_precision@5 0.4147
cosine_precision@10 0.2448
cosine_recall@1 0.1493
cosine_recall@3 0.4347
cosine_recall@5 0.5742
cosine_recall@10 0.674
cosine_ndcg@10 0.6016
cosine_mrr@10 0.5536
cosine_map@100 0.5962

Information Retrieval

Metric Value
cosine_accuracy@1 0.4779
cosine_accuracy@3 0.4947
cosine_accuracy@5 0.6021
cosine_accuracy@10 0.6653
cosine_precision@1 0.4779
cosine_precision@3 0.4772
cosine_precision@5 0.3874
cosine_precision@10 0.2354
cosine_recall@1 0.1381
cosine_recall@3 0.4023
cosine_recall@5 0.5367
cosine_recall@10 0.6509
cosine_ndcg@10 0.5696
cosine_mrr@10 0.5166
cosine_map@100 0.5613

Information Retrieval

Metric Value
cosine_accuracy@1 0.4379
cosine_accuracy@3 0.4547
cosine_accuracy@5 0.5642
cosine_accuracy@10 0.6337
cosine_precision@1 0.4379
cosine_precision@3 0.4372
cosine_precision@5 0.3558
cosine_precision@10 0.2234
cosine_recall@1 0.1272
cosine_recall@3 0.3716
cosine_recall@5 0.4939
cosine_recall@10 0.6161
cosine_ndcg@10 0.5331
cosine_mrr@10 0.4776
cosine_map@100 0.5237

Information Retrieval

Metric Value
cosine_accuracy@1 0.3937
cosine_accuracy@3 0.4021
cosine_accuracy@5 0.4905
cosine_accuracy@10 0.5663
cosine_precision@1 0.3937
cosine_precision@3 0.3902
cosine_precision@5 0.3158
cosine_precision@10 0.1994
cosine_recall@1 0.1135
cosine_recall@3 0.3289
cosine_recall@5 0.4346
cosine_recall@10 0.5481
cosine_ndcg@10 0.474
cosine_mrr@10 0.4258
cosine_map@100 0.4706

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: 11 tokens
    • mean: 23.37 tokens
    • max: 44 tokens
    • min: 25 tokens
    • mean: 131.82 tokens
    • max: 256 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": [
            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

Click to expand
  • 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: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • 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
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch_fused
  • 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: {}

Training Logs

Epoch Step Training Loss 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 3.7351 - - - - -
0.5993 20 2.1273 - - - - -
0.8989 30 1.4916 - - - - -
1.0 34 - 0.6181 0.5990 0.5565 0.5182 0.4301
1.1798 40 1.0246 - - - - -
1.4794 50 0.7911 - - - - -
1.7790 60 0.9107 - - - - -
2.0 68 - 0.6021 0.5913 0.5547 0.5058 0.4100
2.0599 70 0.8617 - - - - -
2.3596 80 0.4465 - - - - -
2.6592 90 0.5044 - - - - -
2.9588 100 0.515 - - - - -
3.0 102 - 0.6124 0.5980 0.5573 0.5133 0.4171
3.2397 110 0.3633 - - - - -
3.5393 120 0.299 - - - - -
3.8390 130 0.3074 - - - - -
4.0 136 - 0.6081 0.6034 0.5579 0.5088 0.4299
4.1199 140 0.2911 - - - - -
4.4195 150 0.2401 - - - - -
4.7191 160 0.2208 - - - - -
5.0 170 0.2465 0.6136 0.5987 0.5642 0.5223 0.4608
5.2996 180 0.1568 - - - - -
5.5993 190 0.1549 - - - - -
5.8989 200 0.1841 - - - - -
6.0 204 - 0.6012 0.5772 0.5470 0.5107 0.4416
6.1798 210 0.2326 - - - - -
6.4794 220 0.1171 - - - - -
6.7790 230 0.1091 - - - - -
7.0 238 - 0.5972 0.5958 0.5543 0.5240 0.4542
7.0599 240 0.1428 - - - - -
7.3596 250 0.1052 - - - - -
7.6592 260 0.1138 - - - - -
7.9588 270 0.0927 - - - - -
8.0 272 - 0.6163 0.5997 0.5642 0.5212 0.4634
8.2397 280 0.087 - - - - -
8.5393 290 0.0679 - - - - -
8.8390 300 0.0503 - - - - -
9.0 306 - 0.6091 0.6024 0.5684 0.5325 0.4680
9.1199 310 0.0451 - - - - -
9.4195 320 0.0532 - - - - -
9.7191 330 0.0412 - - - - -
10.0 340 0.055 0.6097 0.6016 0.5696 0.5331 0.474
  • The bold row denotes the saved checkpoint.

Training Time

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

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

Model tree for IoannisKat1/embeddinggemma-300m-matryoshka1

Finetuned
(270)
this model

Papers for IoannisKat1/embeddinggemma-300m-matryoshka1

Evaluation results