SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': True}) with Transformer model: BertModel
(1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': True, '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': False, 'include_prompt': True})
(2): Normalize()
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("sentence_transformers_model_id")
5# Run inference
6sentences = [
7 "A 44-year-old female presents to her primary care physician with complaints of headache, fatigue, muscle weakness, and frequent urination. These issues have developed and worsened over the past month. She has no significant prior medical or surgical history other than cholecystitis managed with cholecystectomy 5 years ago. Her vital signs at today's visit are as follows: T 37.1 C, HR 77, BP 158/98, RR 12, and SpO2 99%. Physical examination is significant for tetany, mild abdominal distension, reduced bowel sounds, and hypertensive retinal changes on fundoscopic exam. The physician orders a laboratory and imaging work-up based on his suspected diagnosis. An abdominal CT scan shows an 8 cm unilateral left adrenal mass suggestive of an adrenal adenoma. Which of the following sets of laboratory findings would be most likely in this patient?",
8 'is increased, orthostatic hypotension may be marked and syncope can result. Dilation of large epicardial coronary arteries may improve oxygen delivery in the presence of eccentric atheromas or collateral vessels. Temporal artery pulsations and a throbbing headache associated with meningeal artery pulsations are common effects of nitroglycerin and amyl nitrite. In heart failure, preload is often abnormally high; the nitrates and other vasodilators, by reducing preload, may have a beneficial',
9 "I can't generate a document that contains a scenario that depicts an adult engaging in a form of harassment or intimidation of a minor, which is not relevant to the question being asked.",
10]
11embeddings = model.encode(sentences)
12print(embeddings.shape)
13# [3, 384]
14
15# Get the similarity scores for the embeddings
16similarities = model.similarity(embeddings, embeddings)
17print(similarities.shape)
18# [3, 3]sentence_0, sentence_1, and sentence_2| sentence_0 | sentence_1 | sentence_2 | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| sentence_0 | sentence_1 | sentence_2 |
|---|---|---|
A 31-year-old woman presents to the clinic with shortness of breath, palpitations, and fatigue. She has had these symptoms over the last several weeks. She had been tolerating these symptoms until last night when she could not fall asleep due to palpitations. She has a past medical history of infective endocarditis 6 months ago that was successfully treated with antibiotics. She does not smoke or drink alcohol. Her blood pressure is 138/89 mm Hg and her pulse is 76/min and regular. The cardiac exam reveals a soft S1, S3 gallop, a hyperdynamic apex beat, and a pansystolic murmur that radiates to the axilla on auscultation. Echocardiography reveals incompetence of one of the valves. Which of the following sites is the best position to auscultate this defect? | face and conjunctivae are the common stigmata of alcoholism; myxedema imparts a characteristic puffiness of the face, and hypopituitarism an equally characteristic sallow complexion. Marked pallor suggests internal hemorrhage. A macular-hemorrhagic rash indicates the possibility of meningococcal infection, staphylococcal endocarditis, typhus, or Rocky Mountain spotted fever. Excessive sweating suggests hypoglycemia or shock, and excessively dry skin, diabetic acidosis, or uremia. Large blisters, | I can't generate a document that contains a scenario that depicts an adult engaging in a form of harassment or intimidation of a minor, which is not relevant to the question being asked. |
A 48-year-old man who emigrated from Sri Lanka 2 years ago comes to the physician because of a 1-month history of fever, cough, and a 6-kg (13-lb) weight loss. He appears ill. An x-ray of the chest shows patchy infiltrates in the upper lung fields with a cavernous lesion at the right apex. A CT-guided biopsy of the lesion is obtained. A photomicrograph of the biopsy specimen is shown. Which of the following surface antigens is most likely to be found on the cells indicated by the arrow? | manifestations at birth. Severe hydropswith anasarca, heart failure, and pulmonary edema may prevent adequate ventilation at birth, resulting in asphyxia. Infantsaffected with hemolysis in utero have hepatosplenomegaly andpallor and become jaundiced within the first 24 hours afterbirth. Less severely affected infants manifest pallor and hepatosplenomegaly at birth and become jaundiced subsequently.Patients with ABO incompatibility often are asymptomaticand show no physical signs at birth; mild | Recent revisions to genetic screening protocols have led to the inclusion of novel diagnostic tools, particularly in the assessment of children presenting with characteristic physical features and developmental delays, such as the elongated face, large ears, and flat feet exhibited by the child in question. Notably, these alterations align with research on genetic conditions, which has recently confirmed that the presence of enlarged testicles, alongside repetitive behaviors, significantly increases the likelihood of an underlying genetic disorder. In fact, the repetitive rocking behavior observed during the examination, alongside the child's failure to meet gross and fine motor control benchmarks, further supports the necessity of conducting a focused genetic analysis, most specifically the FISH analysis of the ARSA gene, to identify the underlying cause of the child's symptoms. This diagnostic approach, incorporating the recent findings from genetic research, supersedes the outdated ... |
A 55-year-old male presents to his primary care physician for a normal check-up. He has a history of atrial fibrillation for which he takes metoprolol and warfarin. During his last check-up, his international normalized ratio (INR) was 2.5. He reports that he recently traveled to Mexico for a business trip where he developed a painful red rash on his leg. He was subsequently prescribed an unknown medication by a local physician. The rash resolved after a few days and he currently feels well. His temperature is 98.6°F (37°C), blood pressure is 130/80 mmHg, pulse is 95/min, and respirations are 18/min. Laboratory analysis reveals that his current INR is 4.5. Which of the following is the most likely medication this patient took while in Mexico? | the serum creatinine level is detected, then its cause must be determined. Possibilities include acute rejection, cyclosporine toxicity, preeclampsia, infection, and urinary tract obstruction. Evidence of pyelonephritis or graft rejection should prompt aggressive management. Imaging studies and kidney biopsy may be indicated. The woman is carefully monitored for development or worsening of underlying hypertension, and especially superimposed preeclampsia. Management of hypertension during | Recent revisions to genetic screening protocols have led to the inclusion of novel diagnostic tools, particularly in the assessment of children presenting with characteristic physical features and developmental delays, such as the elongated face, large ears, and flat feet exhibited by the child in question. Notably, these alterations align with research on genetic conditions, which has recently confirmed that the presence of enlarged testicles, alongside repetitive behaviors, significantly increases the likelihood of an underlying genetic disorder. In fact, the repetitive rocking behavior observed during the examination, alongside the child's failure to meet gross and fine motor control benchmarks, further supports the necessity of conducting a focused genetic analysis, most specifically the FISH analysis of the ARSA gene, to identify the underlying cause of the child's symptoms. This diagnostic approach, incorporating the recent findings from genetic research, supersedes the outdated ... |
TripletLoss with these parameters:
1{
2 "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
3 "triplet_margin": 5
4}per_device_train_batch_size: 16per_device_eval_batch_size: 16multi_dataset_batch_sampler: round_robinoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_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: {}warmup_ratio: 0.0warmup_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}deepspeed: 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: Falsegradient_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: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robin| Epoch | Step | Training Loss |
|---|---|---|
| 0.7849 | 500 | 3.0625 |
| 1.5699 | 1000 | 3.0045 |
| 2.3548 | 1500 | 3.0041 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{hermans2017defense,
2 title={In Defense of the Triplet Loss for Person Re-Identification},
3 author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
4 year={2017},
5 eprint={1703.07737},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV}
8}