Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 15
How to use ChenyuEcho/hospital_emaillevel_LoRA_newtrainmethod with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("ChenyuEcho/hospital_emaillevel_LoRA_newtrainmethod")
sentences = [
"Which specific dates or staff users should be prioritized when auditing EHR log entries for offline or outside-hours edits to patient education notes?",
"Subject: Re: Assistance Needed: EHR Audit Logs for Patient Complaint Investigation\nDate: 2026-01-22T16:08:00\nFrom: Gabriella I. Santos\nParticipants: Angela R. Scott\n\nBody:\nHi Angela,\n\nThanks for bringing this to my attention. I'll review the patient education notes and check for any entries that may have been added offline or outside regular hours. Once I've completed the cross-reference, I'll update you promptly if I find anything relevant. Please let me know if you have specific dates or staff users you're concerned about so I can prioritize those in my review.\n\nBest,\nGabriella",
"Subject: Crash Cart Inspection Delays and Recommendations for Process Improvement\nDate: 2025-09-15T16:34:00\nFrom: Robert T. Kim\nParticipants: Catherine R. Miller\n\nBody:\nDear Catherine,\n\nI am writing to bring to your attention a concern I have observed regarding the timeliness and documentation of crash cart inspections on several inpatient floors. Recent audits show inconsistencies in weekly checks, which contradicts both JCAHO guidelines and best practices recommended in the 2022 AHA Patient Safety Update ('Crash Cart Readiness: A Quantitative Review'). As you know, inadequate crash cart maintenance can contribute to adverse patient outcomes, especially during code situations. I propose we implement electronic tracking combined with quarterly in-service training to ensure compliance and traceability. Please advise if resource allocation can be considered for this initiative, or let me know if you require further data or a formal proposal from my department.\n\nLooking forward to your insights.\n\nBest regards,\nRobert T. Kim",
"Subject: Re: Required Meeting: Performance and Policy Compliance\nDate: 2026-01-01T14:08:00\nFrom: Sarah J. Morrison\nParticipants: Patricia M. Vasquez\n\nBody:\nDear Patricia,\n\nThank you for your message. I am quite concerned and honestly confused by the allegations described. Could you please clarify which specific policy violations are being referenced? I want to state clearly that I have only discussed the Hendricks incident with patient safety personnel and the individuals you directed me to meet with. At no point have I shared confidential information outside of these channels or violated any HIPAA rules to my knowledge.\n\nIs this related to my incident report from last week? I am anxious to understand the details and context of these concerns so I can respond appropriately and ensure there is no misunderstanding. Please let me know what specific information or actions are in question.\n\nThank you for your attention to this, and I await your clarification.\n\nSincerely,\nSarah"
]
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 = [
"What is the current status of reviewing the attached document referenced by Jennifer Morrison for Margaret L. Hendricks?",
]
documents = [
'Subject: See Attached Document\nDate: 2025-11-12T10:37:00\nFrom: Jennifer Morrison\nParticipants: Margaret L. Hendricks\n\nBody:\nHello Margaret,\n\nI am reaching out to provide you with the attached file as previously referenced in our correspondence. Please take a moment to review the attached document at your earliest convenience, as it contains important information relevant to your current inquiry. If you have any questions or require clarification regarding the content, do not hesitate to reach out to me by reply email or phone. I am committed to supporting you throughout this process and ensuring you have all necessary documentation for your review.\n\nKind regards,\nJennifer Morrison',
'Subject: Confirmation of Attendance for Upcoming Meeting\nDate: 2025-12-08T12:46:00\nFrom: Barbara J. Young\nParticipants: Carol A. Campbell\n\nBody:\nHi Carol,\n\nThank you for reaching out regarding your attendance at the upcoming meeting. I can confirm that your slot is secured and you are listed on our schedule for Thursday at 10:00 AM. If you have any specific topics or materials you intend to present, please forward those to me so I can ensure the agenda accommodates your contributions. Feel free to notify me if there are any changes to your availability.\n\nRegards,\nBarbara\n\n--\nBarbara J. Young | Executive Office',
"Subject: Re: Urgent: Suction Equipment Malfunction Impacting Medication Administration\nDate: 2025-10-20T15:51:00\nFrom: Karen M. Phillips\nParticipants: Taylor A. Richardson\n\nBody:\nHi Taylor,\n\nThank you for raising this concern so promptly. I recommend we temporarily review all patient regimens in the east wing, especially those involving oral and respiratory medications, to identify any high-risk cases where delays could impact drug absorption or safety. In the interim, please ensure that nursing staff document any instances where medication administration is delayed due to equipment issues. I will coordinate with pharmacy and clinical teams to develop interim precautions and will follow up once we've completed the assessment.\n\nBest regards,\nKaren",
]
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.6719, 0.0349, -0.0535]], dtype=torch.bfloat16)
val_full_corpusInformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.8289 |
| cosine_accuracy@3 | 0.9086 |
| cosine_accuracy@5 | 0.9402 |
| cosine_accuracy@10 | 0.9718 |
| cosine_precision@1 | 0.8289 |
| cosine_precision@3 | 0.3029 |
| cosine_precision@5 | 0.188 |
| cosine_precision@10 | 0.0972 |
| cosine_recall@1 | 0.8289 |
| cosine_recall@3 | 0.9086 |
| cosine_recall@5 | 0.9402 |
| cosine_recall@10 | 0.9718 |
| cosine_ndcg@10 | 0.9003 |
| cosine_mrr@10 | 0.8774 |
| cosine_map@100 | 0.8793 |
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
Who is the selected EHR vendor for the upgrade? |
Subject: Upcoming Electronic Health Record System Upgrade: Strategic Overview & Impact |
What is the plan to develop a comprehensive documentation checklist to address anesthesia supply claim rejections caused by documentation gaps? |
Subject: Re: Claim Rejection Analysis: Supply Documentation Concern |
What decisions, owners, and timelines exist for implementing a prioritization protocol for lab draws due to limited isolation room capacity, including proposed criteria, scheduled collection intervals, and cross-functional actions with lab and nursing teams? |
Subject: Re: Isolation Room Capacity and Lab Processing Constraints |
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 | 149 | 0.8884 |
| 2.0 | 298 | 0.8970 |
| 3.0 | 447 | 0.9003 |
@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}
}