embeddinggemma-300m fine-tuned on German Search Categories
This is a sentence-transformers model finetuned from google/embeddinggemma-300m on the search-categories-german-triplets dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text 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
- Training Dataset:
- Language: de
- License: apache-2.0
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 2048, 'do_lower_case': False, 'architecture': 'Gemma3TextModel'})
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
(2): Dense({'in_features': 768, 'out_features': 3072, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
(3): Dense({'in_features': 3072, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
(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("ktcapraz/embeddinggemma-300m-german-search-categories")
# Run inference
queries = [
"Wann endet die Verhandlungsfrist f\u00fcr Spielerlisten 2024?",
]
documents = [
'A broad, general question, related to a specific time.',
'A specific question about a person or entity, with no time constraint.',
'A keyword-based search for a broad topic, with no time constraint.',
]
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.7721, 0.3525, 0.1172]])
Evaluation
Metrics
Information Retrieval
- Datasets:
german-search-cats-eval
andgerman-search-cats-test
- Evaluated with
InformationRetrievalEvaluator
Metric | german-search-cats-eval | german-search-cats-test |
---|---|---|
cosine_accuracy@1 | 0.1989 | 0.7507 |
cosine_accuracy@3 | 0.5265 | 0.9884 |
cosine_accuracy@5 | 0.7575 | 0.9996 |
cosine_accuracy@10 | 1.0 | 1.0 |
cosine_precision@1 | 0.1989 | 0.7507 |
cosine_precision@3 | 0.1755 | 0.3295 |
cosine_precision@5 | 0.1515 | 0.1999 |
cosine_precision@10 | 0.1 | 0.1 |
cosine_recall@1 | 0.1989 | 0.7507 |
cosine_recall@3 | 0.5265 | 0.9884 |
cosine_recall@5 | 0.7575 | 0.9996 |
cosine_recall@10 | 1.0 | 1.0 |
cosine_ndcg@10 | 0.5624 | 0.9023 |
cosine_mrr@10 | 0.4255 | 0.8681 |
cosine_map@100 | 0.4255 | 0.8681 |
Information Retrieval
- Dataset:
german-search-cats-eval
- Evaluated with
InformationRetrievalEvaluator
Metric | Value |
---|---|
cosine_accuracy@1 | 0.7544 |
cosine_accuracy@3 | 0.988 |
cosine_accuracy@5 | 0.9997 |
cosine_accuracy@10 | 1.0 |
cosine_precision@1 | 0.7544 |
cosine_precision@3 | 0.3293 |
cosine_precision@5 | 0.1999 |
cosine_precision@10 | 0.1 |
cosine_recall@1 | 0.7544 |
cosine_recall@3 | 0.988 |
cosine_recall@5 | 0.9997 |
cosine_recall@10 | 1.0 |
cosine_ndcg@10 | 0.9035 |
cosine_mrr@10 | 0.8698 |
cosine_map@100 | 0.8698 |
Training Details
Training Dataset
search-categories-german-triplets
- Dataset: search-categories-german-triplets at bbf15f6
- Size: 73,141 training samples
- Columns:
anchor
,positive
, andnegatives
- Approximate statistics based on the first 1000 samples:
anchor positive negatives type string string list details - min: 4 tokens
- mean: 12.97 tokens
- max: 25 tokens
- min: 13 tokens
- mean: 16.08 tokens
- max: 18 tokens
- size: 3 elements
- Samples:
anchor positive negatives Fleischerzeugung Umweltkosten Deutschland
A keyword-based search for a broad topic, with no time constraint.
['A keyword-based search for a broad topic, related to a specific time.', 'A broad, general question, with no time constraint.', 'A specific keyword search for a person or entity, with no time constraint.']
Schule Rösrath Mpox Schließung
A specific keyword search for a person or entity, with no time constraint.
['A specific keyword search for a person or entity, related to a specific time.', 'A specific question about a person or entity, with no time constraint.', 'A keyword-based search for a broad topic, with no time constraint.']
Was ändert sich bei der Passbeantragung ab Mai 2024?
A broad, general question, related to a specific time.
['A keyword-based search for a broad topic, related to a specific time.', 'A broad, general question, with no time constraint.', 'A specific question about a person or entity, related to a specific time.']
- Loss:
CachedMultipleNegativesRankingLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim", "mini_batch_size": 8, "gather_across_devices": false }
Evaluation Dataset
search-categories-german-triplets
- Dataset: search-categories-german-triplets at bbf15f6
- Size: 15,674 evaluation samples
- Columns:
anchor
,positive
, andnegatives
- Approximate statistics based on the first 1000 samples:
anchor positive negatives type string string list details - min: 4 tokens
- mean: 12.59 tokens
- max: 26 tokens
- min: 13 tokens
- mean: 16.21 tokens
- max: 18 tokens
- size: 3 elements
- Samples:
anchor positive negatives Weihnachtsgeschäft Einzelhandel November Dezember 2024
A specific keyword search for a person or entity, related to a specific time.
['A keyword-based search for a broad topic, related to a specific time.', 'A specific keyword search for a person or entity, with no time constraint.', 'A specific question about a person or entity, related to a specific time.']
Wie reagiert die Union auf Mützenichs Vorstoß?
A specific question about a person or entity, with no time constraint.
['A specific keyword search for a person or entity, with no time constraint.', 'A specific question about a person or entity, related to a specific time.', 'A broad, general question, with no time constraint.']
Al-Manar TV Sperrverfügung Telekom
A specific keyword search for a person or entity, with no time constraint.
['A specific keyword search for a person or entity, related to a specific time.', 'A specific question about a person or entity, with no time constraint.', 'A keyword-based search for a broad topic, with no time constraint.']
- Loss:
CachedMultipleNegativesRankingLoss
with these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim", "mini_batch_size": 8, "gather_across_devices": false }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy
: stepsper_device_train_batch_size
: 128per_device_eval_batch_size
: 128learning_rate
: 1e-05num_train_epochs
: 1warmup_ratio
: 0.1fp16
: Trueprompts
: {'anchor': 'task: search result | query: ', 'positive': 'task: classification | query: '}batch_sampler
: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: stepsprediction_loss_only
: Trueper_device_train_batch_size
: 128per_device_eval_batch_size
: 128per_gpu_train_batch_size
: Noneper_gpu_eval_batch_size
: Nonegradient_accumulation_steps
: 1eval_accumulation_steps
: Nonetorch_empty_cache_steps
: Nonelearning_rate
: 1e-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
: Truefp16_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
: {'anchor': 'task: search result | query: ', 'positive': 'task: classification | query: '}batch_sampler
: no_duplicatesmulti_dataset_batch_sampler
: proportionalrouter_mapping
: {}learning_rate_mapping
: {}
Training Logs
Epoch | Step | Training Loss | Validation Loss | german-search-cats-eval_cosine_ndcg@10 | german-search-cats-test_cosine_ndcg@10 |
---|---|---|---|---|---|
-1 | -1 | - | - | 0.5624 | - |
0.0350 | 20 | 1.8489 | - | - | - |
0.0699 | 40 | 0.9438 | - | - | - |
-1 | -1 | - | - | 0.8633 | - |
0.0350 | 20 | 0.6601 | - | - | - |
0.0699 | 40 | 0.4921 | - | - | - |
0.1049 | 60 | 0.6323 | - | - | - |
0.1399 | 80 | 0.8749 | - | - | - |
0.1748 | 100 | 0.755 | 0.6962 | 0.8705 | - |
0.2098 | 120 | 0.6572 | - | - | - |
0.2448 | 140 | 0.7488 | - | - | - |
0.2797 | 160 | 0.7288 | - | - | - |
0.3147 | 180 | 0.9539 | - | - | - |
0.3497 | 200 | 0.7782 | 0.6118 | 0.8888 | - |
0.3846 | 220 | 0.5965 | - | - | - |
0.4196 | 240 | 0.6789 | - | - | - |
0.4545 | 260 | 0.6537 | - | - | - |
0.4895 | 280 | 0.6572 | - | - | - |
0.5245 | 300 | 0.6221 | 0.5587 | 0.8966 | - |
0.5594 | 320 | 0.5079 | - | - | - |
0.5944 | 340 | 0.5949 | - | - | - |
0.6294 | 360 | 0.6828 | - | - | - |
0.6643 | 380 | 0.6628 | - | - | - |
0.6993 | 400 | 0.6654 | 0.5398 | 0.8986 | - |
0.7343 | 420 | 0.5939 | - | - | - |
0.7692 | 440 | 0.6976 | - | - | - |
0.8042 | 460 | 0.6453 | - | - | - |
0.8392 | 480 | 0.5204 | - | - | - |
0.8741 | 500 | 0.5709 | 0.5383 | 0.9035 | - |
0.9091 | 520 | 0.5452 | - | - | - |
0.9441 | 540 | 0.635 | - | - | - |
0.9790 | 560 | 0.8884 | - | - | - |
-1 | -1 | - | - | - | 0.9023 |
Framework Versions
- Python: 3.10.18
- Sentence Transformers: 5.1.0
- Transformers: 4.56.1
- PyTorch: 2.8.0+cu128
- Accelerate: 1.10.1
- Datasets: 4.1.0
- Tokenizers: 0.22.0
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}
}
- Downloads last month
- 34
Model tree for ktcapraz/embeddinggemma-300m-german-search-categories
Base model
google/embeddinggemma-300mEvaluation results
- Cosine Accuracy@1 on german search cats evalself-reported0.199
- Cosine Accuracy@3 on german search cats evalself-reported0.527
- Cosine Accuracy@5 on german search cats evalself-reported0.757
- Cosine Accuracy@10 on german search cats evalself-reported1.000
- Cosine Precision@1 on german search cats evalself-reported0.199
- Cosine Precision@3 on german search cats evalself-reported0.176
- Cosine Precision@5 on german search cats evalself-reported0.151
- Cosine Precision@10 on german search cats evalself-reported0.100
- Cosine Recall@1 on german search cats evalself-reported0.199
- Cosine Recall@3 on german search cats evalself-reported0.527