Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 12
This is a sentence-transformers model finetuned from google/embeddinggemma-300m on the json 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.
SentenceTransformer(
(0): Transformer({'max_seq_length': 2048, 'do_lower_case': False}) with Transformer model: 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()
)
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("congvm/embeddinggemma-300M-triplet-vn-10000-20250924")
# Run inference
sentences = [
'task: sentence similarity | query: Đất tiềm năng sinh lời cao trong khu tam giác vàng Củ Chi',
'task: sentence similarity | query: Tiêu đề: cần tiền kinh doanh ra gấp đất bình mỹ gardern\n\n\nMô tả: - diện tích 80m2 (5mx16m), mặt đường nhựa 7,5m.\n- cách võ văn bích 200m, vành đai 3 chỉ 1,5km.\n- khu tam giác vàng của củ chi.\n- tiềm năng sinh lời cao.\n- hình chân thực, chính chủ.',
'task: sentence similarity | query: Tiêu đề: chùa hà - lô góc - mặt ngõ kinh doanh - ô tô đỗ cửa - 17 tỷ\n\n\nMô tả: chùa hà - lô góc - mặt ngõ kinh doanh - ô tô đỗ cửa - 17 tỷ\n\n* diện tích 38m2 - mặt tiền 4.6m\n\n* vị trí: trung tâm quận cầu giấy, ngõ thông ô tô vào nhà. mặt ngõ kinh doanh sầm uất.\n\n* thiết kế 5 tầng chắc chắn, lô góc thoáng sáng:\n- t1: khách, bếp, wc\n- t2,3,4: mỗi tầng 2 phòng ngủ, wc\n- t5: phòng thờ, sân phơi\n\n* sổ đỏ vuông a4\nliên hệ duy:',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
query, answer, and negative| query | answer | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| query | answer | negative |
|---|---|---|
task: sentence similarity |
query: Cho thuê nhà trọ trệt gác trần gần trường học Tân Hưng Q7 giá 4.5 triệu | task: sentence similarity |
task: sentence similarity |
query: Cho thuê nhà trọ trệt gác trần gần trường học Tân Hưng Q7 giá 4.5 triệu | task: sentence similarity |
task: sentence similarity |
query: Cho thuê nhà trọ trệt gác trần gần trường học Tân Hưng Q7 giá 4.5 triệu | task: sentence similarity |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
query, answer, and negative| query | answer | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| query | answer | negative |
|---|---|---|
task: sentence similarity |
query: Căn hộ gần Big C và trường học Quận 2 | task: sentence similarity |
task: sentence similarity |
query: Căn hộ gần Big C và trường học Quận 2 | task: sentence similarity |
task: sentence similarity |
query: Căn hộ gần Big C và trường học Quận 2 | task: sentence similarity |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
eval_strategy: stepslearning_rate: 2e-05num_train_epochs: 5warmup_ratio: 0.1fp16: Truedataloader_num_workers: 8prompts: task: sentence similarity | query: batch_sampler: no_duplicatesoverwrite_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: 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: 5max_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: Truedataloader_num_workers: 8dataloader_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_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: 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: Trueprompts: task: sentence similarity | query: batch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | Validation Loss |
|---|---|---|---|
| 0.0093 | 100 | 0.9919 | - |
| 0.0185 | 200 | 0.2415 | - |
| 0.0278 | 300 | 0.1604 | - |
| 0.0371 | 400 | 0.1351 | - |
| 0.0464 | 500 | 0.1141 | - |
| 0.0556 | 600 | 0.0998 | - |
| 0.0649 | 700 | 0.0962 | - |
| 0.0742 | 800 | 0.0865 | - |
| 0.0835 | 900 | 0.0871 | - |
| 0.0927 | 1000 | 0.0798 | - |
| 0.1020 | 1100 | 0.0764 | - |
| 0.1113 | 1200 | 0.0754 | - |
| 0.1205 | 1300 | 0.08 | - |
| 0.1298 | 1400 | 0.0767 | - |
| 0.1391 | 1500 | 0.0685 | - |
| 0.1484 | 1600 | 0.0761 | - |
| 0.1576 | 1700 | 0.0727 | - |
| 0.1669 | 1800 | 0.0742 | - |
| 0.1762 | 1900 | 0.0666 | - |
| 0.1855 | 2000 | 0.0725 | - |
| 0.1947 | 2100 | 0.0703 | - |
| 0.2040 | 2200 | 0.0728 | - |
| 0.2133 | 2300 | 0.0693 | - |
| 0.2226 | 2400 | 0.0669 | - |
| 0.2318 | 2500 | 0.0707 | - |
| 0.2411 | 2600 | 0.0657 | - |
| 0.2504 | 2700 | 0.068 | - |
| 0.2596 | 2800 | 0.0681 | - |
| 0.2689 | 2900 | 0.0717 | - |
| 0.2782 | 3000 | 0.0671 | - |
| 0.2875 | 3100 | 0.0652 | - |
| 0.2967 | 3200 | 0.0664 | - |
| 0.3060 | 3300 | 0.0671 | - |
| 0.3153 | 3400 | 0.0675 | - |
| 0.3246 | 3500 | 0.0688 | - |
| 0.3338 | 3600 | 0.0718 | - |
| 0.3431 | 3700 | 0.0689 | - |
| 0.3524 | 3800 | 0.0672 | - |
| 0.3616 | 3900 | 0.0663 | - |
| 0.3709 | 4000 | 0.0744 | - |
| 0.3802 | 4100 | 0.0662 | - |
| 0.3895 | 4200 | 0.0703 | - |
| 0.3987 | 4300 | 0.0709 | - |
| 0.4080 | 4400 | 0.0733 | - |
| 0.4173 | 4500 | 0.067 | - |
| 0.4266 | 4600 | 0.071 | - |
| 0.4358 | 4700 | 0.0715 | - |
| 0.4451 | 4800 | 0.0813 | - |
| 0.4544 | 4900 | 0.0712 | - |
| 0.4636 | 5000 | 0.0685 | 0.0865 |
| 0.4729 | 5100 | 0.0619 | - |
| 0.4822 | 5200 | 0.0693 | - |
| 0.4915 | 5300 | 0.0667 | - |
| 0.5007 | 5400 | 0.0719 | - |
| 0.5100 | 5500 | 0.0683 | - |
| 0.5193 | 5600 | 0.0712 | - |
| 0.5286 | 5700 | 0.0615 | - |
| 0.5378 | 5800 | 0.0732 | - |
| 0.5471 | 5900 | 0.0666 | - |
| 0.5564 | 6000 | 0.0657 | - |
| 0.5657 | 6100 | 0.0686 | - |
| 0.5749 | 6200 | 0.0633 | - |
| 0.5842 | 6300 | 0.0716 | - |
| 0.5935 | 6400 | 0.0626 | - |
| 0.6027 | 6500 | 0.0653 | - |
| 0.6120 | 6600 | 0.0595 | - |
| 0.6213 | 6700 | 0.0682 | - |
| 0.6306 | 6800 | 0.0588 | - |
| 0.6398 | 6900 | 0.0603 | - |
| 0.6491 | 7000 | 0.0582 | - |
| 0.6584 | 7100 | 0.0574 | - |
| 0.6677 | 7200 | 0.0578 | - |
| 0.6769 | 7300 | 0.0593 | - |
| 0.6862 | 7400 | 0.0611 | - |
| 0.6955 | 7500 | 0.0577 | - |
| 0.7047 | 7600 | 0.058 | - |
| 0.7140 | 7700 | 0.0531 | - |
| 0.7233 | 7800 | 0.0556 | - |
| 0.7326 | 7900 | 0.0559 | - |
| 0.7418 | 8000 | 0.0481 | - |
| 0.7511 | 8100 | 0.0572 | - |
| 0.7604 | 8200 | 0.0553 | - |
| 0.7697 | 8300 | 0.0535 | - |
| 0.7789 | 8400 | 0.0534 | - |
| 0.7882 | 8500 | 0.0541 | - |
| 0.7975 | 8600 | 0.0504 | - |
| 0.8068 | 8700 | 0.0538 | - |
| 0.8160 | 8800 | 0.0485 | - |
| 0.8253 | 8900 | 0.0465 | - |
| 0.8346 | 9000 | 0.0527 | - |
| 0.8438 | 9100 | 0.045 | - |
| 0.8531 | 9200 | 0.047 | - |
| 0.8624 | 9300 | 0.0486 | - |
| 0.8717 | 9400 | 0.0463 | - |
| 0.8809 | 9500 | 0.0458 | - |
| 0.8902 | 9600 | 0.0471 | - |
| 0.8995 | 9700 | 0.0392 | - |
| 0.9088 | 9800 | 0.0411 | - |
| 0.9180 | 9900 | 0.0441 | - |
| 0.9273 | 10000 | 0.0479 | 0.0785 |
@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",
}
@misc{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
Base model
google/embeddinggemma-300m