Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 18
How to use Akshayram1/embeddinggemma-300m with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Akshayram1/embeddinggemma-300m")
sentences = [
"what is still blocking dead letter replay tooling",
"Dead Letter Queue replay tooling\n\nOperators need a safe way to replay events out of the Dead Letter Queue after a fix ships. Add atlasctl dlq replay backed by api/pipelines.py with filters on pipeline, failure class and time window, a dry-run mode that prints counts only, and a rate limit so replay never starves live traffic. Acceptance criteria: replayed events keep their original event_id so downstream deduplication still holds, every replay writes an audit record, and the runbook contains a worked example from the 2026-08-26 regression. Status history: todo 2026-08-25, in_progress 2026-09-02, in_review 2026-09-09 with two open review comments from Vikram Joshi about rate limiting. Depends on ATLAS-107, ATLAS-108 and ATLAS-116. Reporter Vikram Joshi, assignee Neha Kapoor.",
"INC-002 Staging Ingestion Outage from SSL Verification Failure\n\nDocument kind: incident. Author: Vikram Joshi. Reviewers: Rohan Mehta, Maya Rao, Akshay Sharma. Status: active, written 2026-08-19, reviewed at the postmortem on 2026-08-21. Impact: all staging CDC ingestion down for 4 hours 11 minutes, 2026-08-19T06:12Z to 10:23Z. No customer data was affected; the pilot demo scheduled for that afternoon was postponed. Timeline: 06:12Z connector pods begin crash-looping with certificate verify failed; 06:40Z Vikram Joshi opens ATLAS-110 and states on the bridge that the staging PostgreSQL server certificate has expired; 07:20Z a certificate renewal request is filed with the platform team, which is the wrong remediation; 09:05Z Rohan Mehta checks openssl output and finds the server certificate valid until 2027-01-14; 09:30Z he execs into a pod and finds /etc/ssl/certs/aster-internal-ca.pem absent; 09:40Z ATLAS-111 is opened, tracing the loss to the slim base image adopted on 2026-08-14; 10:23Z a rebuilt image restores ingestion. CONTRADICTION RESOLVED: the expired-server-certificate claim recorded in the first version of ATLAS-110 is incorrect and superseded by ATLAS-111. Corrective actions: CA bundle baked in with a build-time fingerprint assertion and a start-up self-check, per the SSL hardening decision, shipped in PR-004 with commit e42a7f0c3b91; the SSL certificate runbook now mandates checking the client side before the server. 90 minutes of the outage are directly attributable to diagnosing in the wrong order.",
"ADR-004 Retry Budget and Backoff Policy\n\nDocument kind: decision. Author: Vikram Joshi. Approvers: Neha Kapoor, Rohan Mehta, Maya Rao. Status: approved 2026-08-26, implemented 2026-09-01 under ATLAS-108. Context: the first draft of the DLQ replay runbook stated a retry budget of five attempts with a 30 second ceiling. During the retry and DLQ design review Vikram Joshi pointed out that Aster Labs broker maintenance routinely takes eight to twelve minutes, so a 30 second ceiling would exhaust every retry and dump an entire maintenance window into the Dead Letter Queue, turning a self-healing event into a manual replay of tens of thousands of records. Neha Kapoor countered that a long ceiling delays the visibility of genuinely broken pipelines. Decision: eight attempts with exponential backoff and full jitter, base 2 seconds, ceiling 15 minutes, giving roughly 45 minutes of tolerance; and, to answer the visibility concern, a pipeline with any event past attempt four for more than five minutes raises a warning on the Observability Dashboard under ATLAS-119. The earlier five-attempt, 30-second text in the runbook is superseded and the runbook was corrected on 2026-08-27. Implemented in workers/retry_worker.py through PR-005 and commit b8740e2fd1a3, with ceilings configurable in deploy/helm/atlas/values.yaml."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This model was finetuned with Unsloth.
based on unsloth/embeddinggemma-300m
This is a sentence-transformers model finetuned from unsloth/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, classification, clustering, and more.
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'max_seq_length': 512, 'do_lower_case': False, 'architecture': 'PeftModelForFeatureExtraction'})
(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("sentence_transformers_model_id")
# Run inference
queries = [
'what retry policy replaced five attempts at 30 seconds',
]
documents = [
'Retry Worker with jittered exponential backoff\n\nBuild workers/retry_worker.py to consume atlas.retry.v1, re-attempt delivery with exponential backoff and full jitter, and hand exhausted events to the Dead Letter Queue. Acceptance criteria: transient Kafka or sink failures recover without operator action, retry attempts are labelled by failure class in monitoring/metrics.py, and the backoff ceiling is configurable through deploy/helm/atlas/values.yaml. Status history: todo 2026-08-17, in_progress 2026-08-25, in_review 2026-08-28, done 2026-09-01. The first runbook draft documented five attempts capped at 30 seconds; the retry policy decision of 2026-08-26 replaced that with eight attempts and a 15 minute ceiling, and the runbook was updated. Depends on ATLAS-107. Reporter Vikram Joshi, assignee Neha Kapoor. Evidence: PR-005 and commit b8740e2fd1a3.',
'Alert on replication slot growth before disk pressure\n\nA stalled Atlas consumer holds the PostgreSQL replication slot open and retained WAL grows until the primary runs out of disk. Add a slot_retained_bytes gauge to monitoring/metrics.py and page SRE at 20 GB retained or 30 minutes of no slot advance, whichever comes first. Acceptance criteria: the alert fired correctly during the 2026-08-19 SSL outage rehearsal, the on-call runbook documents the drain procedure, and the gauge is visible on the Observability Dashboard. Status history: todo 2026-08-17, in_progress 2026-08-20, done 2026-08-24. Depends on ATLAS-101; feeds ATLAS-109. Reporter Vikram Joshi, assignee Vikram Joshi. Evidence: PR-007 panels and the dashboard on-call runbook.',
'Runbook: Dead Letter Queue Triage and Replay\n\nDocument kind: runbook. Owner: Neha Kapoor. Contributors: Vikram Joshi, Rohan Mehta. Status: active, first draft 2026-08-25, corrected 2026-08-27, updated 2026-09-10. Scope: what to do when Dead Letter Queue depth alerts on the Observability Dashboard under ATLAS-119. Step 1, classify: group atlas.dlq.v1 records by failure class. Decode failures usually mean a schema change, so read the schema migration runbook next. Sink failures usually mean a downstream outage and often clear themselves through the Retry Worker. Step 2, fix forward, never replay into a broken pipeline. Step 3, replay with atlasctl dlq replay, filtered by pipeline and time window, always with --dry-run first. Replayed events keep their original event_id, so downstream deduplication still holds, which is the property established by the checkpoint decision and ATLAS-103. Correction 2026-08-27: the first draft of this runbook stated a retry budget of five attempts capped at 30 seconds. That is superseded by the retry policy decision of eight attempts with a 15 minute ceiling under ATLAS-108. Update 2026-09-10: the replay CLI in ATLAS-118 is still in review with open rate-limiting comments, so for Atlas 1.0 replay is performed manually using the worked example from the 2026-08-26 regression, where 312 malformed envelopes were replayed in three batches of 104.',
]
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.2781, 0.1833, 0.2271]])
atlasInformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.31 |
| cosine_accuracy@3 | 0.55 |
| cosine_accuracy@5 | 0.65 |
| cosine_accuracy@10 | 0.78 |
| cosine_precision@1 | 0.31 |
| cosine_precision@3 | 0.1833 |
| cosine_precision@5 | 0.13 |
| cosine_precision@10 | 0.078 |
| cosine_recall@1 | 0.31 |
| cosine_recall@3 | 0.55 |
| cosine_recall@5 | 0.65 |
| cosine_recall@10 | 0.78 |
| cosine_ndcg@10 | 0.5338 |
| cosine_mrr@10 | 0.4561 |
| cosine_map@100 | 0.4681 |
question, passage_text, and negative| question | passage_text | negative | |
|---|---|---|---|
| type | string | string | string |
| modality | text | text | text |
| details |
|
|
|
| question | passage_text | negative |
|---|---|---|
why does atlas use pgoutput instead of wal2json |
Atlas PostgreSQL CDC Reader Design |
Map envelope fields by name across schema generations |
what replication slot name does each pipeline get |
Atlas PostgreSQL CDC Reader Design |
Atlas Sprint 1 demo |
what fields are in the atlas event envelope |
Atlas Event Envelope and Schema Registry Design |
Map envelope fields by name across schema generations |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
per_device_train_batch_size: 16learning_rate: 2e-05num_train_epochs: 1lr_scheduler_type: constant_with_warmupwarmup_ratio: 0.05prompts: {'question': '', 'passage_text': '', 'negative': ''}batch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseprediction_loss_only: Trueper_device_train_batch_size: 16per_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: 1max_steps: -1lr_scheduler_type: constant_with_warmuplr_scheduler_kwargs: {}warmup_ratio: 0.05warmup_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: Falsefp16_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: {'question': '', 'passage_text': '', 'negative': ''}batch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | atlas_cosine_ndcg@10 |
|---|---|---|---|
| -1 | -1 | - | 0.1975 |
| 0.3846 | 5 | 2.9373 | - |
| 0.7692 | 10 | 2.561 | - |
| -1 | -1 | - | 0.5338 |
@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{oord2019representationlearningcontrastivepredictive,
title={Representation Learning with Contrastive Predictive Coding},
author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
year={2019},
eprint={1807.03748},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1807.03748},
}