CoolFace
Modelpublic

ktcapraz/embeddinggemma-300m-german-search-categories

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes68downloads
Model Card

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 <!-- at revision c5cfa06e5e282a820e85d57f7fb053207494f41d -->
  • —Maximum Sequence Length: 2048 tokens
  • —Output Dimensionality: 768 dimensions
  • —Similarity Function: Cosine Similarity
  • —Training Dataset:
  • —search-categories-german-triplets
  • —Language: de
  • —License: apache-2.0

Model Sources

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:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
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]])

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Information Retrieval
Metricgerman-search-cats-evalgerman-search-cats-test
cosine_accuracy@10.19890.7507
cosine_accuracy@30.52650.9884
cosine_accuracy@50.75750.9996
cosine_accuracy@101.01.0
cosine_precision@10.19890.7507
cosine_precision@30.17550.3295
cosine_precision@50.15150.1999
cosine_precision@100.10.1
cosine_recall@10.19890.7507
cosine_recall@30.52650.9884
cosine_recall@50.75750.9996
cosine_recall@101.01.0
cosine_ndcg@100.56240.9023
cosine_mrr@100.42550.8681
cosine_map@1000.42550.8681
Information Retrieval
MetricValue
cosine_accuracy@10.7544
cosine_accuracy@30.988
cosine_accuracy@50.9997
cosine_accuracy@101.0
cosine_precision@10.7544
cosine_precision@30.3293
cosine_precision@50.1999
cosine_precision@100.1
cosine_recall@10.7544
cosine_recall@30.988
cosine_recall@50.9997
cosine_recall@101.0
cosine_ndcg@100.9035
cosine_mrr@100.8698
cosine_map@1000.8698

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

search-categories-german-triplets
  • —Dataset: search-categories-german-triplets at bbf15f6
  • —Size: 73,141 training samples
  • —Columns: <code>anchor</code>, <code>positive</code>, and <code>negatives</code>
  • —Approximate statistics based on the first 1000 samples: | | anchor | positive | negatives | |:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:-----------------------------------| | type | string | string | list | | details | <ul><li>min: 4 tokens</li><li>mean: 12.97 tokens</li><li>max: 25 tokens</li></ul> | <ul><li>min: 13 tokens</li><li>mean: 16.08 tokens</li><li>max: 18 tokens</li></ul> | <ul><li>size: 3 elements</li></ul> |
  • —Samples: | anchor | positive | negatives | |:------------------------------------------------------------------|:----------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Fleischerzeugung Umweltkosten Deutschland</code> | <code>A keyword-based search for a broad topic, with no time constraint.</code> | <code>['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.']</code> | | <code>Schule Rösrath Mpox Schließung</code> | <code>A specific keyword search for a person or entity, with no time constraint.</code> | <code>['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.']</code> | | <code>Was ändert sich bei der Passbeantragung ab Mai 2024?</code> | <code>A broad, general question, related to a specific time.</code> | <code>['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.']</code> |
  • —Loss: <code>CachedMultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "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: <code>anchor</code>, <code>positive</code>, and <code>negatives</code>
  • —Approximate statistics based on the first 1000 samples: | | anchor | positive | negatives | |:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:-----------------------------------| | type | string | string | list | | details | <ul><li>min: 4 tokens</li><li>mean: 12.59 tokens</li><li>max: 26 tokens</li></ul> | <ul><li>min: 13 tokens</li><li>mean: 16.21 tokens</li><li>max: 18 tokens</li></ul> | <ul><li>size: 3 elements</li></ul> |
  • —Samples: | anchor | positive | negatives | |:--------------------------------------------------------------------|:-------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Weihnachtsgeschäft Einzelhandel November Dezember 2024</code> | <code>A specific keyword search for a person or entity, related to a specific time.</code> | <code>['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.']</code> | | <code>Wie reagiert die Union auf Mützenichs Vorstoß?</code> | <code>A specific question about a person or entity, with no time constraint.</code> | <code>['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.']</code> | | <code>Al-Manar TV Sperrverfügung Telekom</code> | <code>A specific keyword search for a person or entity, with no time constraint.</code> | <code>['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.']</code> |
  • —Loss: <code>CachedMultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim",
      "mini_batch_size": 8,
      "gather_across_devices": false
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —eval_strategy: steps
  • —per_device_train_batch_size: 128
  • —per_device_eval_batch_size: 128
  • —learning_rate: 1e-05
  • —num_train_epochs: 1
  • —warmup_ratio: 0.1
  • —fp16: True
  • —prompts: {'anchor': 'task: search result | query: ', 'positive': 'task: classification | query: '}
  • —batch_sampler: no_duplicates
All Hyperparameters

<details><summary>Click to expand</summary>

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: steps
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 128
  • —per_device_eval_batch_size: 128
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 1
  • —eval_accumulation_steps: None
  • —torch_empty_cache_steps: None
  • —learning_rate: 1e-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: 1
  • —max_steps: -1
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: {}
  • —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
  • —use_ipex: False
  • —bf16: False
  • —fp16: True
  • —fp16_opt_level: O1
  • —half_precision_backend: auto
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —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: False
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_min_num_params: 0
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —parallelism_config: None
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamwtorchfused
  • —optim_args: None
  • —adafactor: False
  • —group_by_length: False
  • —length_column_name: length
  • —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: False
  • —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: False
  • —prompts: {'anchor': 'task: search result | query: ', 'positive': 'task: classification | query: '}
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional
  • —router_mapping: {}
  • —learning_rate_mapping: {}

</details>

Training Logs

EpochStepTraining LossValidation Lossgerman-search-cats-eval_cosine_ndcg@10german-search-cats-test_cosine_ndcg@10
-1-1--0.5624-
0.0350201.8489---
0.0699400.9438---
-1-1--0.8633-
0.0350200.6601---
0.0699400.4921---
0.1049600.6323---
0.1399800.8749---
0.17481000.7550.69620.8705-
0.20981200.6572---
0.24481400.7488---
0.27971600.7288---
0.31471800.9539---
0.34972000.77820.61180.8888-
0.38462200.5965---
0.41962400.6789---
0.45452600.6537---
0.48952800.6572---
0.52453000.62210.55870.8966-
0.55943200.5079---
0.59443400.5949---
0.62943600.6828---
0.66433800.6628---
0.69934000.66540.53980.8986-
0.73434200.5939---
0.76924400.6976---
0.80424600.6453---
0.83924800.5204---
0.87415000.57090.53830.9035-
0.90915200.5452---
0.94415400.635---
0.97905600.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
bibtex
@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
bibtex
@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}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->