SentenceTransformer based on google/embeddinggemma-300m
This is a sentence-transformers model finetuned from google/embeddinggemma-300m. It maps sentences & paragraphs 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-300m
- Maximum Sequence Length: 2048 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Supported Modality: Text
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
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("dinushiTJ/nz-research-commons-embedding-gemma-v2")
# Run inference
queries = [
'maori_origin',
]
documents = [
'title: Understanding cultural relationships: Whānau, whanaungatanga and Māori student attainment of university entrance in a mainstream secondary school in Aotearoa, New Zealand\n\nauthors: McGill, Kristin\n\nsubjects: Cultural relationships\n\nabstract: This study seeks to understand the importance of cultural relationships in supporting Māori student achievement of University Entrance. This research is based on the stories of five female ākonga Māori, all of whom completed five years of secondary education, and their whānau. It looks deeply into their relational experiences of whanaungatanga and whānautanga with their school, and the impact this had on their academic achievement of NCEA Level 3 and University Entrance. \r\n\r\nThe results highlight the importance of culturally grounded transformative praxis and the risk of attempting to incorporate culturally located principles such as whānau and whanaungatanga into a schooling context, while still operating within historical hegemonic frameworks.\n\ntext: Understanding cultural relationships: Whānau, whanaungatanga and Māori student attainment of university entrance in a mainstream secondary school in Aotearoa, New Zealand This study seeks to understand the importance of cultural relationships in supporting Māori student achievement of University Entrance. This research is based on the stories of five female ākonga Māori, all of whom completed five years of secondary education, and their whānau. It looks deeply into their relational experiences of whanaungatanga and whānautanga with their school, and the impact this had on their academic achievement of NCEA Level 3 and University Entrance. \r\n\r\nThe results highlight the importance of culturally grounded transformative praxis and the risk of attempting to incorporate culturally located principles such as whānau and whanaungatanga into a schooling context, while still operating within historical hegemonic frameworks.\n\nyear: 2023',
'title: Editorial: Pacific education: research and practice.\n\nauthors: Strachan, Jane\n\nsubjects: educational anthropology\n\nabstract: The article discusses various reports published within the issue including one by Tanya Wendt Samu on the call for teachers to be responsive to the diversities between group of learners as well as within groups of learners and another by Fran Cahill on the discussion of the difficulties that Samoan adolescents have in living within the traditional Samoan culture of home.\n\ntext: Editorial: Pacific education: research and practice. The article discusses various reports published within the issue including one by Tanya Wendt Samu on the call for teachers to be responsive to the diversities between group of learners as well as within groups of learners and another by Fran Cahill on the discussion of the difficulties that Samoan adolescents have in living within the traditional Samoan culture of home.\n\nyear: 2006',
'title: An evaluation of Te Rau Puawai workforce 100: Perspectives of Te Rau Puawai bursars\n\nauthors: Nikora, Linda Waimarie\n\nsubjects: Maori students\n\nabstract: The Te Rau Puawai programme is an attempt to change the nature of the Maori\r\nmental health workforce. To do this, Maori with aspirations to work, or to continue to\r\nwork in the mental health workforce, are supported, financially and academically, to\r\ncomplete a tertiary qualification relevant to the field.\r\nTo evaluate the Te Rau Puawai programme, the Ministry of Health commissioned the\r\nMaori and Psychology Research Unit of the University of Waikato in July 2001. The\r\noverall aim of the evaluation was to provide the Ministry with a clearer understanding\r\nof the programme including: the perceived critical success factors, the barriers if any\r\nregarding Te Rau Puawai, the impact of the programme, the extent to which the\r\nprogramme may be transferable, gaps in the programme, and suggested\r\nimprovements.\r\nThe evaluation team set out to gather the experiences and perspectives of recipients of\r\nTe Rau Puawai services by asking all bursars to complete a questionnaire and\r\nvolunteer for follow up interviews or focus groups. Sixty two bursars responded to\r\nour questionnaire, and we complete focus group or individual follow up interviews\r\nwith 19 bursars.\n\ntext: An evaluation of Te Rau Puawai workforce 100: Perspectives of Te Rau Puawai bursars The Te Rau Puawai programme is an attempt to change the nature of the Maori\r\nmental health workforce. To do this, Maori with aspirations to work, or to continue to\r\nwork in the mental health workforce, are supported, financially and academically, to\r\ncomplete a tertiary qualification relevant to the field.\r\nTo evaluate the Te Rau Puawai programme, the Ministry of Health commissioned the\r\nMaori and Psychology Research Unit of the University of Waikato in July 2001. The\r\noverall aim of the evaluation was to provide the Ministry with a clearer understanding\r\nof the programme including: the perceived critical success factors, the barriers if any\r\nregarding Te Rau Puawai, the impact of the programme, the extent to which the\r\nprogramme may be transferable, gaps in the programme, and suggested\r\nimprovements.\r\nThe evaluation team set out to gather the experiences and perspectives of recipients of\r\nTe Rau Puawai services by asking all bursars to complete a questionnaire and\r\nvolunteer for follow up interviews or focus groups. Sixty two bursars responded to\r\nour questionnaire, and we complete focus group or individual follow up interviews\r\nwith 19 bursars.\n\nyear: 2002-05-01',
]
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.9017, -0.1908, 0.8361]])
Training Details
Training Dataset
Unnamed Dataset
- Size: 5,000 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: 6 tokensmean: 6.75 tokensmax: 8 tokens min: 55 tokensmean: 702.62 tokensmax: 1882 tokens min: 93 tokensmean: 651.33 tokensmax: 2048 tokens - Samples:
anchor positive negative maori_origin title: Biteauthors: Mitchell, Torisubjects: poetryabstract: Bite is a collection of blunt confessional poetry draped in honesty, identity, and 21st century feminism, examined through lived experience with eating disorders, sexuality, trauma, disconnect from family and culture, love and loss, and what it means to be a girl growing up. The collection explores these raw concepts with vulnerability, through the eyes of ‘wolf girl’, in hopes that talking loudly about these topics will force the public to challenge the silence and stigma around them. - Loss: TripletLoss with these parameters:
{ "distance_metric": "TripletDistanceMetric.COSINE", "triplet_margin": 0.3 }
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 1learning_rate: 2e-05num_train_epochs: 1warmup_ratio: 0.1prompts: task: classification | query:
All Hyperparameters
overwrite_output_dir: Falsedo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 1per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Falsefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: task: classification | query:batch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}
Training Logs
| Epoch | Step | Training Loss |
|---|---|---|
| 0.01 | 50 | 0.1511 |
| 0.02 | 100 | 0.0427 |
| 0.03 | 150 | 0.0149 |
| 0.04 | 200 | 0.0092 |
| 0.05 | 250 | 0.0502 |
| 0.06 | 300 | 0.013 |
| 0.07 | 350 | 0.0497 |
| 0.08 | 400 | 0.053 |
| 0.09 | 450 | 0.0499 |
| 0.1 | 500 | 0.016 |
| 0.11 | 550 | 0.0442 |
| 0.12 | 600 | 0.0422 |
| 0.13 | 650 | 0.0533 |
| 0.14 | 700 | 0.014 |
| 0.15 | 750 | 0.0075 |
| 0.16 | 800 | 0.0304 |
| 0.17 | 850 | 0.078 |
| 0.18 | 900 | 0.0116 |
| 0.19 | 950 | 0.0474 |
| 0.2 | 1000 | 0.0095 |
| 0.21 | 1050 | 0.0254 |
| 0.22 | 1100 | 0.0049 |
| 0.23 | 1150 | 0.0332 |
| 0.24 | 1200 | 0.024 |
| 0.25 | 1250 | 0.0124 |
| 0.26 | 1300 | 0.0275 |
| 0.27 | 1350 | 0.0517 |
| 0.28 | 1400 | 0.0344 |
| 0.29 | 1450 | 0.0162 |
| 0.3 | 1500 | 0.0269 |
| 0.31 | 1550 | 0.0234 |
| 0.32 | 1600 | 0.0124 |
| 0.33 | 1650 | 0.033 |
| 0.34 | 1700 | 0.007 |
| 0.35 | 1750 | 0.001 |
| 0.36 | 1800 | 0.0161 |
| 0.37 | 1850 | 0.027 |
| 0.38 | 1900 | 0.0057 |
| 0.39 | 1950 | 0.0097 |
| 0.4 | 2000 | 0.0087 |
| 0.41 | 2050 | 0.012 |
| 0.42 | 2100 | 0.0028 |
| 0.43 | 2150 | 0.0196 |
| 0.44 | 2200 | 0.0116 |
| 0.45 | 2250 | 0.0415 |
| 0.46 | 2300 | 0.0288 |
| 0.47 | 2350 | 0.0022 |
| 0.48 | 2400 | 0.0032 |
| 0.49 | 2450 | 0.0532 |
| 0.5 | 2500 | 0.0108 |
| 0.51 | 2550 | 0.0152 |
| 0.52 | 2600 | 0.0089 |
| 0.53 | 2650 | 0.0158 |
| 0.54 | 2700 | 0.0018 |
| 0.55 | 2750 | 0.006 |
| 0.56 | 2800 | 0.0021 |
| 0.57 | 2850 | 0.0098 |
| 0.58 | 2900 | 0.0038 |
| 0.59 | 2950 | 0.0104 |
| 0.6 | 3000 | 0.0181 |
| 0.61 | 3050 | 0.0114 |
| 0.62 | 3100 | 0.0049 |
| 0.63 | 3150 | 0.0074 |
| 0.64 | 3200 | 0.0122 |
| 0.65 | 3250 | 0.0094 |
| 0.66 | 3300 | 0.0153 |
| 0.67 | 3350 | 0.0212 |
| 0.68 | 3400 | 0.0 |
| 0.69 | 3450 | 0.0025 |
| 0.7 | 3500 | 0.0128 |
| 0.71 | 3550 | 0.0301 |
| 0.72 | 3600 | 0.018 |
| 0.73 | 3650 | 0.0339 |
| 0.74 | 3700 | 0.0059 |
| 0.75 | 3750 | 0.0018 |
| 0.76 | 3800 | 0.032 |
| 0.77 | 3850 | 0.0076 |
| 0.78 | 3900 | 0.0204 |
| 0.79 | 3950 | 0.0046 |
| 0.8 | 4000 | 0.0 |
| 0.81 | 4050 | 0.0295 |
| 0.82 | 4100 | 0.0042 |
| 0.83 | 4150 | 0.0168 |
| 0.84 | 4200 | 0.0232 |
| 0.85 | 4250 | 0.0002 |
| 0.86 | 4300 | 0.0 |
| 0.87 | 4350 | 0.0039 |
| 0.88 | 4400 | 0.0 |
| 0.89 | 4450 | 0.0079 |
| 0.9 | 4500 | 0.0177 |
| 0.91 | 4550 | 0.0301 |
| 0.92 | 4600 | 0.0246 |
| 0.93 | 4650 | 0.0029 |
| 0.94 | 4700 | 0.0273 |
| 0.95 | 4750 | 0.0 |
| 0.96 | 4800 | 0.0025 |
| 0.97 | 4850 | 0.0 |
| 0.98 | 4900 | 0.0018 |
| 0.99 | 4950 | 0.0324 |
| 1.0 | 5000 | 0.0105 |
Training Time
- Training: 1.1 hours
Framework Versions
- Python: 3.12.13
- Sentence Transformers: 5.7.0
- Transformers: 4.57.0.dev0
- PyTorch: 2.10.0+cu128
- Accelerate: 1.13.0
- Datasets: 5.0.1
- Tokenizers: 0.22.2
Additional Resources
- Training and Finetuning Embedding Models with Sentence Transformers: the end-to-end guide for training or finetuning Sentence Transformer models.
- Introduction to Matryoshka Embedding Models: variable-size embeddings that can be truncated with minimal quality loss.
- Binary and Scalar Embedding Quantization for Significantly Faster & Cheaper Retrieval: post-training compression of embedding vectors.
- Multimodal Embedding & Reranker Models with Sentence Transformers: use text, image, audio, and video models through the same API.
- Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers: train multimodal embedding models, with a Visual Document Retrieval walkthrough.
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",
}
TripletLoss
@misc{hermans2017defense,
title={In Defense of the Triplet Loss for Person Re-Identification},
author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
year={2017},
eprint={1703.07737},
archivePrefix={arXiv},
primaryClass={cs.CV}
}