Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 15
How to use ChenyuEcho/ai-test with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("ChenyuEcho/ai-test")
sentences = [
"Internal communications tracking permit application delays or production impact",
"Subject: Re: Coordination for Upcoming Auditor Visit to Tequila Facility\nDate: 2026-01-07T13:35:00\nFrom: Roberto Garza\nParticipants: Elena Fuentes\n\nBody:\nHi Elena,\n\nThanks for reaching out regarding the auditor visit. Can you share whether any of the visitors have dietary restrictions or accessibility needs we should consider for the site tour and lunch? Also, will translation services or special PPE be required for any attendees? Please confirm if there are specific topics or production areas they want to prioritize during the tour, so we can prepare accordingly.\n\nLooking forward to your response.\n\nBest regards,\nRoberto",
"Subject: Production Team Shift Schedules and Holiday Coverage\nDate: 2025-08-11T10:08:00\nFrom: Sofia Hernandez\nParticipants: Agave Spirits International Production Team\n\nBody:\nHi team,\n\nI wanted to follow up regarding our upcoming shift schedules and to ensure we have the necessary coverage for the next few weeks. As you know, we need the permit to maintain production levels, so it's important that we avoid any staffing gaps—especially with the team working overtime this week. Please review your assigned shifts on the attached schedule. If you need to request time off or swap a shift, let me know by Wednesday so we can coordinate approvals and avoid disruptions. For those available to cover during the holiday period, please confirm your availability as soon as possible. Your flexibility and commitment are highly appreciated as we work to keep production targets on track.\n\nThank you,\nSofia Hernandez\nProduction Supervisor",
"Subject: Re: Tequila Production Yield Calculations and Permit Status Concerns\nDate: 2025-10-24T07:21:00\nFrom: Sofia Hernandez\nParticipants: Roberto Garza\n\nBody:\nHi Roberto,\n\nThank you for sending over the yield data and highlighting the decrease due to fiber content. I'll review the numbers more closely before our Thursday meeting and will propose any adjustments to the shift schedule if necessary. Regarding the permit, I agree it’s critical—I'll check in with Rick this afternoon for a status update and notify you immediately if your involvement is needed or if there are any bottlenecks we need to address. Your proactive approach is appreciated.\n\nLet’s align on next steps Thursday.\n\nBest,\nSofia"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from Qwen/Qwen3-Embedding-0.6B. It maps sentences & paragraphs to a 1024-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': 32768, 'do_lower_case': False, 'architecture': 'Qwen3Model'})
(1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': True, 'include_prompt': True})
(2): 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 = [
"How were high-value business expenses reviewed for required manager approvals?",
]
documents = [
'Subject: Reminder: Year-End Expense Submission Deadline and T&E Policy Requirements\nDate: 2025-08-25T16:44:00\nFrom: Maria Santos\nParticipants: Carlos Delgado; Ricardo Rick Mendez; Ana Lucia Vega; Miguel Torres; Carmen Ortiz\n\nBody:\nDear Team,\n\nAs we approach year-end, I want to remind everyone that all 2024 business expense reports must be submitted in Concur by December 18th. Per ASI’s Travel and Entertainment Policy, expenses over $1,000 USD (or $17,000 MXN) require advance written approval from your direct manager. Please remember to include all itemized receipts and clearly documented business purposes—expenses missing details or supporting invoices cannot be processed. Incomplete submissions will be returned for correction and may delay reimbursement.\n\nIf you have any questions or need clarification, please review the T&E Policy on the intranet or contact me directly. Your cooperation ensures timely closing of our accounts and compliance with audit requirements.\n\nThank you for your attention to these details.\n\nRegards,\nMaria Santos\nFinance Director - Mexico\n\n--\nMaria Santos\nFinance Director, Mexico Operations\nAgave Spirits International',
"Subject: Request for Volume Discount to Support Q4 Targets\nDate: 2026-01-14T09:41:00\nFrom: Kevin O'Brien\nParticipants: Carlos Delgado\n\nBody:\nHi Carlos,\n\nI wanted to reach out regarding our ongoing discussions with Distribuidora Romero. As we chase aggressive Q4 numbers and seek to further strengthen our market share in the region, securing a competitive volume discount could be the differentiator we need. Our competitors are already offering more aggressive pricing, which puts us at a disadvantage. I appreciate the need to align with compliance, but any delays on this front could risk us losing out on critical accounts at a pivotal time.\n\nLet’s connect soon to map out the path forward and ensure we’re positioned as the preferred partner.\n\nBest,\nKevin",
'Subject: Completed Due Diligence Package: Impresiones Jalisco – Request for Compliance Approval\nDate: 2025-12-30T17:15:00\nFrom: Miguel Torres\nParticipants: Jennifer Walsh\n\nBody:\nHi Jennifer,\n\nI’m pleased to submit the complete third-party due diligence package for Impresiones Jalisco, our proposed supplier for label printing services. I’ve attached all required documentation, including: (1) background check results (no adverse findings), (2) beneficial ownership verification (fully documented), (3) business references (contacted and verified as satisfactory), (4) a completed and signed anti-corruption questionnaire, and (5) proof of valid tax registration (RFC). Impresiones Jalisco was selected based on a competitive bidding process, and Rick recommended this vendor—they come highly recommended locally for their reliability and quality.\n\nPlease review the attached package and let me know if you need any further information. Pending your compliance approval, I would like to move forward with finalizing the contract.\n\nThanks for your attention to this. I look forward to your feedback so we can proceed.\n\nBest regards,\nMiguel\n\n--\nMiguel Torres\nProcurement Manager\nASI Mexico',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 1024] [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[ 0.4629, -0.0649, 0.0549]], dtype=torch.bfloat16)
val_full_corpusInformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.3977 |
| cosine_accuracy@3 | 0.6165 |
| cosine_accuracy@5 | 0.7102 |
| cosine_accuracy@10 | 0.8352 |
| cosine_precision@1 | 0.3977 |
| cosine_precision@3 | 0.2055 |
| cosine_precision@5 | 0.142 |
| cosine_precision@10 | 0.0835 |
| cosine_recall@1 | 0.3977 |
| cosine_recall@3 | 0.6165 |
| cosine_recall@5 | 0.7102 |
| cosine_recall@10 | 0.8352 |
| cosine_ndcg@10 | 0.599 |
| cosine_mrr@10 | 0.5251 |
| cosine_map@100 | 0.5334 |
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
How did compliance procedures impact market research and account strategy discussions? |
Subject: Re: Q4 Market Research Results: Strong Positioning & Opportunities |
Communications referencing urgency or market competition potentially impacting procedural compliance |
Subject: Request for Special Pricing Exception – Key Account, Q4 Impact |
Who approved wire transfers above threshold without complete documentation or authorization forms? |
Subject: Clarification Needed: Travel Expense Reimbursements and Payment Procedures |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false
}
per_device_train_batch_size: 16per_device_eval_batch_size: 16multi_dataset_batch_sampler: round_robindo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16gradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 5e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1num_train_epochs: 3max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_ratio: Nonewarmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Trueenable_jit_checkpoint: Falsesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseuse_cpu: Falseseed: 42data_seed: Nonebf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: -1ddp_backend: Nonedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonedisable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}accelerator_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: Nonegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Truepush_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_for_metrics: []eval_do_concat_batches: Trueauto_find_batch_size: Falsefull_determinism: Falseddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_num_input_tokens_seen: noneftune_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: Trueuse_cache: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | val_full_corpus_cosine_ndcg@10 |
|---|---|---|
| 1.0 | 95 | 0.5955 |
| 2.0 | 190 | 0.5966 |
| 3.0 | 285 | 0.5990 |
@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}
}