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, 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
- Languages: multilingual, ko
- License: cc-by-sa-4.0
Model Sources
Training Code: skier-song9/DL_study/codes/nlp/Finetune_Kor_STS.ipynb
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("song9/embeddinggemma-300m-KorSTS")
# Run inference
queries = [
"한 소녀가 머리를 스타일링하고 있다.",
]
sentences = [
'한 소녀가 머리를 빗고 있다.',
'한 무리의 소년들이 해변에서 축구를 하고 있다.',
'한 여자는 다른 여자의 발목을 측정한다.',
'한 남자가 키보드를 연주하고 있다.',
'한 남자가 하프를 연주하고 있다.',
]
query_embeddings = model.encode(queries)
sentences_embeddings = model.encode(sentences)
print(query_embeddings.shape, sentences_embeddings.shape)
# (1, 768) (5, 768)
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, sentences_embeddings)
print(similarities)
# tensor([[0.7389, 0.1011, 0.0921, 0.0836, 0.1487]])
Evaluation
Metrics
Semantic Similarity
- Datasets:
korsts-devandkorsts-test - Evaluated with
EmbeddingSimilarityEvaluator
| Metric | korsts-dev | korsts-test |
|---|---|---|
| pearson_cosine | 0.8305 | 0.7765 |
| spearman_cosine | 0.8285 | 0.7633 |
- There are NaN data in
korsts-test. After dropping NaN data inkorsts-test, spearman_cosine increases.Metric korsts-test (w/o NaN) pearson_cosine 0.7829 spearman_cosine 0.7689
Semantic Similarity
- Dataset:
korsts-dev - Evaluated with
EmbeddingSimilarityEvaluator
| Metric | Value |
|---|---|
| pearson_cosine | 0.7765 |
| spearman_cosine | 0.7633 |
Training Details
Training Dataset
KorSTS-train Dataset
- Size: 5,696 training samples
- Columns:
sentence1,sentence2, andlabel - Approximate statistics based on the first 1000 samples:
sentence1 sentence2 label type string string float details - min: 8 tokens
- mean: 13.14 tokens
- max: 35 tokens
- min: 8 tokens
- mean: 12.96 tokens
- max: 30 tokens
- min: 0.0
- mean: 0.45
- max: 1.0
- Samples:
sentence1 sentence2 label 비행기가 이륙하고 있다.비행기가 이륙하고 있다.1.0한 남자가 큰 플루트를 연주하고 있다.남자가 플루트를 연주하고 있다.0.76한 남자가 피자에 치즈를 뿌려놓고 있다.한 남자가 구운 피자에 치즈 조각을 뿌려놓고 있다.0.76 - Loss:
CosineSimilarityLosswith these parameters:{ "loss_fct": "torch.nn.modules.loss.MSELoss" }
Evaluation Dataset
KorSTS-dev Dataset
- Size: 1,466 evaluation samples
- Columns:
sentence1,sentence2, andlabel - Approximate statistics based on the first 1000 samples:
sentence1 sentence2 label type string string float details - min: 7 tokens
- mean: 19.41 tokens
- max: 159 tokens
- min: 2 tokens
- mean: 19.24 tokens
- max: 51 tokens
- min: 0.0
- mean: 0.42
- max: 1.0
- Samples:
sentence1 sentence2 label 안전모를 가진 한 남자가 춤을 추고 있다.안전모를 쓴 한 남자가 춤을 추고 있다.1.0어린아이가 말을 타고 있다.아이가 말을 타고 있다.0.95한 남자가 뱀에게 쥐를 먹이고 있다.남자가 뱀에게 쥐를 먹이고 있다.1.0 - Loss:
CosineSimilarityLosswith these parameters:{ "loss_fct": "torch.nn.modules.loss.MSELoss" }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: stepsgradient_accumulation_steps: 2torch_empty_cache_steps: 20learning_rate: 2e-06max_steps: 800lr_scheduler_type: cosinebf16: Truebf16_full_eval: Trueload_best_model_at_end: Truepush_to_hub: Truehub_model_id: song9/embeddinggemma-300m-KorSTShub_strategy: endauto_find_batch_size: True
All Hyperparameters
Click to expand
overwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 8per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 2eval_accumulation_steps: Nonetorch_empty_cache_steps: 20learning_rate: 2e-06weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 3max_steps: 800lr_scheduler_type: cosinelr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_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: Truefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Truefp16_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: Trueignore_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}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_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: Trueresume_from_checkpoint: Nonehub_model_id: song9/embeddinggemma-300m-KorSTShub_strategy: endhub_private_repo: Nonehub_always_push: Falsegradient_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: Truefull_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: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}
Training Logs
| Epoch | Step | Training Loss | Validation Loss | korsts-dev_spearman_cosine | korsts-test_spearman_cosine |
|---|---|---|---|---|---|
| 0.5618 | 100 | 0.0881 | 0.0300 | 0.8188 | - |
| 1.1236 | 200 | 0.0627 | 0.027 | 0.8362 | - |
| 1.6854 | 300 | 0.0382 | 0.0275 | 0.8334 | - |
| 2.2472 | 400 | 0.0277 | 0.0276 | 0.8340 | - |
| 2.8090 | 500 | 0.016 | 0.0277 | 0.8320 | - |
| 3.3708 | 600 | 0.0105 | 0.0280 | 0.8296 | - |
| 3.9326 | 700 | 0.0078 | 0.0281 | 0.8289 | - |
| 4.4944 | 800 | 0.0054 | 0.0282 | 0.8285 | - |
| -1 | -1 | - | - | 0.7633 | 0.7633 |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.11.13
- Sentence Transformers: 5.1.1
- Transformers: 4.52.4
- PyTorch: 2.6.0+cu124
- Accelerate: 1.8.1
- Datasets: 3.6.0
- Tokenizers: 0.21.2
Citation
@article{ham2020kornli,
title={KorNLI and KorSTS: New Benchmark Datasets for Korean Natural Language Understanding},
author={Ham, Jiyeon and Choe, Yo Joong and Park, Kyubyong and Choi, Ilji and Soh, Hyungjoon},
journal={arXiv preprint arXiv:2004.03289},
year={2020}
}
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",
}
- Downloads last month
- 5
Model tree for song9/embeddinggemma-300m-KorSTS
Base model
google/embeddinggemma-300mEvaluation results
- Pearson Cosine on korsts devself-reported0.830
- Spearman Cosine on korsts devself-reported0.829
- Pearson Cosine on korsts devself-reported0.777
- Spearman Cosine on korsts devself-reported0.763
- Pearson Cosine on korsts testself-reported0.777
- Spearman Cosine on korsts testself-reported0.763