SentenceTransformer based on google/embeddinggemma-2

This is a sentence-transformers model finetuned from google/embeddinggemma-2 on the sentence-transformers/all-nli dataset. It maps inputs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: google/embeddinggemma-2
  • Maximum Sequence Length: 1000000000000000019884624838656 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity
  • Supported Modalities: Text, Image, Audio, Video, Message
  • Training Dataset:
    • sentence-transformers/all-nli
  • 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'}, 'image': {'method': 'forward', 'method_output_name': 'last_hidden_state'}, 'audio': {'method': 'forward', 'method_output_name': 'last_hidden_state'}, 'video': {'method': 'forward', 'method_output_name': 'last_hidden_state'}, 'message': {'method': 'forward', 'method_output_name': 'last_hidden_state', 'format': 'structured'}}, 'module_output_name': 'token_embeddings', 'architecture': 'EmbeddingGemma2Model'})
  (1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
  (2): Normalize({'module_input_name': 'sentence_embedding', 'module_output_name': 'sentence_embedding'})
)

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("ML-Intern-lab/embeddinggemma-2-allnli-triplet")
# Run inference
queries = [
    'Two women are embracing while holding to go packages.',
]
documents = [
    'Two woman are holding packages.',
    'Two kids in numbered jerseys wash their hands.',
    'A man selling donuts to a customer.',
]
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.8584, 0.3772, 0.3133]])

Evaluation

Metrics

Triplet

Metric Value
cosine_accuracy 0.9459

Training Details

Training Dataset

sentence-transformers/all-nli

  • Dataset: sentence-transformers/all-nli
  • Size: 557,850 training samples
  • Columns: anchor, positive, and negative
  • Approximate statistics based on the first 100 samples:
    anchor positive negative
    type string string string
    modality text text text
    details
    • min: 8 tokens
    • mean: 14.08 tokens
    • max: 28 tokens
    • min: 6 tokens
    • mean: 13.85 tokens
    • max: 28 tokens
    • min: 5 tokens
    • mean: 14.85 tokens
    • max: 28 tokens
  • Samples:
    anchor positive negative
    A person on a horse jumps over a broken down airplane. A person is outdoors, on a horse. A person is at a diner, ordering an omelette.
    Children smiling and waving at camera There are children present The kids are frowning
    A boy is jumping on skateboard in the middle of a red bridge. The boy does a skateboarding trick. The boy skates down the sidewalk.
  • Loss: CachedMultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "mini_batch_size": 16,
        "mini_batch_num_tokens": null,
        "gather_across_devices": false,
        "directions": [
            "query_to_doc"
        ],
        "partition_mode": "joint",
        "hardness_mode": null,
        "hardness_strength": 0.0
    }
    

Evaluation Dataset

sentence-transformers/all-nli

  • Dataset: sentence-transformers/all-nli
  • Size: 6,584 evaluation samples
  • Columns: anchor, positive, and negative
  • Approximate statistics based on the first 100 samples:
    anchor positive negative
    type string string string
    modality text text text
    details
    • min: 7 tokens
    • mean: 17.35 tokens
    • max: 38 tokens
    • min: 5 tokens
    • mean: 9.86 tokens
    • max: 28 tokens
    • min: 5 tokens
    • mean: 10.28 tokens
    • max: 18 tokens
  • Samples:
    anchor positive negative
    Two women are embracing while holding to go packages. Two woman are holding packages. The men are fighting outside a deli.
    Two young children in blue jerseys, one with the number 9 and one with the number 2 are standing on wooden steps in a bathroom and washing their hands in a sink. Two kids in numbered jerseys wash their hands. Two kids in jackets walk to school.
    A man selling donuts to a customer during a world exhibition event held in the city of Angeles A man selling donuts to a customer. A woman drinks her coffee in a small cafe.
  • Loss: CachedMultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "mini_batch_size": 16,
        "mini_batch_num_tokens": null,
        "gather_across_devices": false,
        "directions": [
            "query_to_doc"
        ],
        "partition_mode": "joint",
        "hardness_mode": null,
        "hardness_strength": 0.0
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 128
  • num_train_epochs: 1
  • max_steps: 1500
  • learning_rate: 2e-05
  • warmup_steps: 0.1
  • bf16: True
  • per_device_eval_batch_size: 128
  • batch_sampler: no_duplicates

All Hyperparameters

Click to expand
  • per_device_train_batch_size: 128
  • num_train_epochs: 1
  • max_steps: 1500
  • learning_rate: 2e-05
  • lr_scheduler_type: linear
  • 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: 1
  • 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: None
  • 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: 128
  • 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: False
  • 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
  • dataloader_multiprocessing_context: None
  • dataloader_in_order: True
  • 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
  • local_rank: -1
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}
  • warmup_ratio: None

Training Logs

Epoch Step Training Loss Validation Loss all-nli-dev_cosine_accuracy
-1 -1 - - 0.9036
0.0046 20 1.6320 - -
0.0092 40 1.5520 - -
0.0138 60 1.4255 - -
0.0184 80 1.2147 - -
0.0229 100 1.0517 - -
0.0275 120 0.8570 - -
0.0321 140 0.8000 - -
0.0367 160 0.7947 - -
0.0413 180 0.7525 - -
0.0459 200 0.6815 - -
0.0505 220 0.6914 - -
0.0551 240 0.6813 - -
0.0574 250 - 0.3524 0.9406
0.0596 260 0.6740 - -
0.0642 280 0.6508 - -
0.0688 300 0.6537 - -
0.0734 320 0.6400 - -
0.0780 340 0.6726 - -
0.0826 360 0.6459 - -
0.0872 380 0.6518 - -
0.0918 400 0.6561 - -
0.0964 420 0.6366 - -
0.1009 440 0.6344 - -
0.1055 460 0.6060 - -
0.1101 480 0.6290 - -
0.1147 500 0.7045 0.3279 0.9443
0.1193 520 0.6654 - -
0.1239 540 0.6329 - -
0.1285 560 0.6248 - -
0.1331 580 0.6289 - -
0.1376 600 0.6293 - -
0.1422 620 0.6200 - -
0.1468 640 0.6097 - -
0.1514 660 0.6558 - -
0.1560 680 0.6488 - -
0.1606 700 0.6108 - -
0.1652 720 0.6311 - -
0.1698 740 0.6408 - -
0.1721 750 - 0.3174 0.9449
0.1744 760 0.6349 - -
0.1789 780 0.6083 - -
0.1835 800 0.6153 - -
0.1881 820 0.6040 - -
0.1927 840 0.6180 - -
0.1973 860 0.5697 - -
0.2019 880 0.6652 - -
0.2065 900 0.6085 - -
0.2111 920 0.6082 - -
0.2156 940 0.6263 - -
0.2202 960 0.5992 - -
0.2248 980 0.5950 - -
0.2294 1000 0.5778 0.3149 0.9453
0.2340 1020 0.5890 - -
0.2386 1040 0.6056 - -
0.2432 1060 0.6154 - -
0.2478 1080 0.6102 - -
0.2524 1100 0.5502 - -
0.2569 1120 0.6006 - -
0.2615 1140 0.6149 - -
0.2661 1160 0.5941 - -
0.2707 1180 0.6153 - -
0.2753 1200 0.5927 - -
0.2799 1220 0.5759 - -
0.2845 1240 0.5894 - -
0.2868 1250 - 0.3132 0.9456
0.2891 1260 0.5852 - -
0.2936 1280 0.5578 - -
0.2982 1300 0.5786 - -
0.3028 1320 0.5501 - -
0.3074 1340 0.6244 - -
0.3120 1360 0.6009 - -
0.3166 1380 0.5955 - -
0.3212 1400 0.5901 - -
0.3258 1420 0.6017 - -
0.3304 1440 0.6022 - -
0.3349 1460 0.5904 - -
0.3395 1480 0.6046 - -
0.3441 1500 0.5862 0.3131 0.9459

Training Time

  • Training: 2.1 hours
  • Evaluation: 12.4 minutes
  • Total: 2.3 hours

Framework Versions

  • Python: 3.12.12
  • Sentence Transformers: 6.1.0
  • Transformers: 5.19.0
  • PyTorch: 2.14.1+cu130
  • Accelerate: 1.15.0
  • Datasets: 5.1.0
  • Tokenizers: 0.23.3

Additional Resources

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",
}

CachedMultipleNegativesRankingLoss

@misc{gao2021scaling,
    title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup},
    author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan},
    year={2021},
    eprint={2101.06983},
    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
26
Safetensors
Model size
0.3B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for ML-Intern-lab/embeddinggemma-2-allnli-triplet

Finetuned
(123)
this model

Papers for ML-Intern-lab/embeddinggemma-2-allnli-triplet

Evaluation results