Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 17
How to use kevin-rice/embeddinggemma-ticket-similarity with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("kevin-rice/embeddinggemma-ticket-similarity")
sentences = [
"In-House Replenishment Does Not Update Quantities in Product Location History / Batches After Stock Transfer",
"Add \"Primary Location Quantity\" column in Suggestions section of In-House Replenishments UI",
"Stock and Min On Hand Column Sorting Not Working in Manage Products UI",
"Previous Surcharge and New Surcharge Displayed as Dollar Amount Instead of Percentage in Product Price History"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]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 retrieval.
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({})
)
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("kevin-rice/embeddinggemma-ticket-similarity")
# Run inference
queries = [
'Misaligned Template Section Fields and Inconsistent Invoice Layout Compared to UPS Orders',
]
documents = [
'PDF export button icon appears similar to Excel icon in Inventory Master List report',
'Inventory Master List Displays Active/Inactive Products While Manage Products Uses Different Status Visibility Logic',
'SKU Toggle Prints Commodity Code (CC) Instead of SKU in Location Labels',
]
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.3035, 0.6568, 0.2639]])
ticket-similarity-evalEmbeddingSimilarityEvaluator| Metric | Value |
|---|---|
| pearson_cosine | 0.8735 |
| spearman_cosine | 0.8192 |
sentence1, sentence2, and score| sentence1 | sentence2 | score | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| sentence1 | sentence2 | score |
|---|---|---|
View button icon under Action column is not displayed properly |
Unable to Search and Select Product in Select Product Catalog During In-House Replenishment |
1.0 |
Pick Assignment Throws Replenishment Error Even When Primary Location Has Available Stock |
Cycle Count Variance report not fetching latest cycle count data dynamically |
0.8 |
Move Items UI should auto-hide location selection when only one Primary location exists |
Primary Location not populated when product is fetched using Scan/Search Barcode in In-House Replenishment |
0.8 |
CosineSimilarityLoss with these parameters:{
"loss_fct": "torch.nn.modules.loss.MSELoss",
"cos_score_transformation": "torch.nn.modules.linear.Identity"
}
sentence1, sentence2, and score| sentence1 | sentence2 | score | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
| sentence1 | sentence2 | score |
|---|---|---|
Update Packing Slip date format to MM-DD-YYYY |
Accounting Template data is not fetching under Template column in Sales History By Item report |
0.8 |
Update Comments Section Format and Merge Herman ID / Employee ID Field |
Order With Quantity Exceeding Available Primary Stock Is Marked Delivered Instead of Back Order and Creates Negative Stock |
0.0 |
Default distribution center comment is not displayed in Comments section |
Update Packing Slip date format to MM-DD-YYYY |
0.8 |
CosineSimilarityLoss with these parameters:{
"loss_fct": "torch.nn.modules.loss.MSELoss",
"cos_score_transformation": "torch.nn.modules.linear.Identity"
}
per_device_train_batch_size: 4learning_rate: 2e-05warmup_steps: 0.1fp16: Trueper_device_eval_batch_size: 4per_device_train_batch_size: 4num_train_epochs: 3max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Truebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 4prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | ticket-similarity-eval_spearman_cosine |
|---|---|---|---|---|
| 0.0633 | 5 | 0.1581 | - | - |
| 0.1266 | 10 | 0.1581 | - | - |
| 0.1899 | 15 | 0.1117 | - | - |
| 0.2532 | 20 | 0.0869 | 0.0750 | 0.6907 |
| 0.3165 | 25 | 0.0651 | - | - |
| 0.3797 | 30 | 0.0590 | - | - |
| 0.4430 | 35 | 0.0580 | - | - |
| 0.5063 | 40 | 0.0698 | 0.1141 | 0.5602 |
| 0.5696 | 45 | 0.1079 | - | - |
| 0.6329 | 50 | 0.0932 | - | - |
| 0.6962 | 55 | 0.0762 | - | - |
| 0.7595 | 60 | 0.0938 | 0.0637 | 0.7089 |
| 0.8228 | 65 | 0.1259 | - | - |
| 0.8861 | 70 | 0.0735 | - | - |
| 0.9494 | 75 | 0.0276 | - | - |
| 1.0127 | 80 | 0.0551 | 0.0607 | 0.7692 |
| 1.0759 | 85 | 0.0788 | - | - |
| 1.1392 | 90 | 0.0807 | - | - |
| 1.2025 | 95 | 0.0334 | - | - |
| 1.2658 | 100 | 0.0508 | 0.0687 | 0.7471 |
| 1.3291 | 105 | 0.0719 | - | - |
| 1.3924 | 110 | 0.0404 | - | - |
| 1.4557 | 115 | 0.0143 | - | - |
| 1.5190 | 120 | 0.0740 | 0.0630 | 0.7372 |
| 1.5823 | 125 | 0.0410 | - | - |
| 1.6456 | 130 | 0.0483 | - | - |
| 1.7089 | 135 | 0.0629 | - | - |
| 1.7722 | 140 | 0.0513 | 0.0483 | 0.7610 |
| 1.8354 | 145 | 0.0175 | - | - |
| 1.8987 | 150 | 0.0397 | - | - |
| 1.9620 | 155 | 0.0341 | - | - |
| 2.0253 | 160 | 0.0223 | 0.0478 | 0.7755 |
| 2.0886 | 165 | 0.0167 | - | - |
| 2.1519 | 170 | 0.0230 | - | - |
| 2.2152 | 175 | 0.0600 | - | - |
| 2.2785 | 180 | 0.0357 | 0.0412 | 0.8031 |
| 2.3418 | 185 | 0.0479 | - | - |
| 2.4051 | 190 | 0.0172 | - | - |
| 2.4684 | 195 | 0.0183 | - | - |
| 2.5316 | 200 | 0.0213 | 0.0399 | 0.8162 |
| 2.5949 | 205 | 0.0115 | - | - |
| 2.6582 | 210 | 0.0305 | - | - |
| 2.7215 | 215 | 0.0101 | - | - |
| 2.7848 | 220 | 0.0189 | 0.0388 | 0.8229 |
| 2.8481 | 225 | 0.0249 | - | - |
| 2.9114 | 230 | 0.0104 | - | - |
| 2.9747 | 235 | 0.0099 | - | - |
| 3.0 | 237 | - | 0.0391 | 0.8192 |
@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",
}
Base model
google/embeddinggemma-300m