sentence-transformers safetensors bert sentence-similarity feature-extraction generated_from_trainer dataset_size:274230 loss:CosineSimilarityLoss arxiv:1908.10084 base_model:sentence-transformers/all-MiniLM-L6-v2 base_model:finetune:sentence-transformers/all-MiniLM-L6-v2 autotrain_compatible text-embeddings-inference endpoints_compatible region:us
---
base_model: sentence-transformers/all-MiniLM-L6-v2
library_name: sentence-transformers
pipeline_tag: sentence-similarity
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:274230
- loss:CosineSimilarityLoss
widget:
- source_sentence: "Rate PR QRS QT/QTc P QRS T \n___ 360/451 26 -46 99 \nImaging:\n\
    ."
  sentences:
  - "- Please call the heart failure clinic if you have swelling in \nyour legs, abdominal\
    \ distention, or shortness of breath at \nnight."
  - "You were found to have a serious urinary tract \ninfection (urosepsis) that will\
    \ require treatment with IV \nantibiotics."
  - "Prior to Feeding:\n-The tube should be aspirated with a 60ml syringe prior to\
    \ \nfeeding to check for residual food."
- source_sentence: "Omeprazole 40 mg PO DAILY \n5."
  sentences:
  - "Please follow up on \nthis matter with your primary care physician."
  - Please remove any remaining strips ___ days after surgery.
  - "Please continue to \ntake them as directed."
- source_sentence: 'Disp:*15 Tablet(s)* Refills:*0*

    2.'
  sentences:
  - "Your hand was found to be cold and it was difficult \nfeeling a pulse in your\
    \ right arm so a CTA was performed and \nshowed an arterial clot in your R arm,\
    \ you were seen by the \nvascular surgery team who did not recommend surgery and\
    \ you were \nstarted on anticoagulation."
  - "In the meantime, you \nshould continue with sertraline 50mg daily for depression."
  - "Please take the following as needed Bisacodyl, Senna, Docusate \nneeded for constipation\
    \ \n."
- source_sentence: "Pt given PO digoxin \nload."
  sentences:
  - "You were also \nstarted on antibiotics for possible meningitis, you will \ncomplete\
    \ a 14 day course."
  - "TAKE THESE MEDICATIONS SCHEDULED\n- LEUCOVORIN: Take 15 mg at 6AM/6PM on ___\
    \ and at 6AM ___ \n\nFOR NAUSEA, TAKE THESE MEDICATIONS:\n- ONDANSETRON 8 MG TWICE\
    \ PER DAY and stop on morning of ___."
  - "A small amount of \nfluid was drained from your abdomen."
- source_sentence: "She was fitted with a lumbar warm-n-form brace \nfor comfort."
  sentences:
  - 2) We added levetiracetam (Keppra).
  - 'Dear Ms. ___,


    It was a pleasure being part of your care at ___.'
  - "You should no longer take your coumadin medication because of \nthe risks of\
    \ bleeding, as discussed with your family and \noutpatient providers."
---

# SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2

This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2). It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

## Model Details

### Model Description
- **Model Type:** Sentence Transformer
- **Base model:** [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) <!-- at revision fa97f6e7cb1a59073dff9e6b13e2715cf7475ac9 -->
- **Maximum Sequence Length:** 256 tokens
- **Output Dimensionality:** 384 dimensions
- **Similarity Function:** Cosine Similarity
<!-- - **Training Dataset:** Unknown -->
<!-- - **Language:** Unknown -->
<!-- - **License:** Unknown -->

### Model Sources

- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)

### Full Model Architecture

```
SentenceTransformer(
  (0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 384, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, '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()
)
```

## Usage

### Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

```bash
pip install -U sentence-transformers
```

Then you can load this model and run inference.
```python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("MonirahQQ/medical_discharge_embeddings")
# Run inference
sentences = [
    'She was fitted with a lumbar warm-n-form brace \nfor comfort.',
    'You should no longer take your coumadin medication because of \nthe risks of bleeding, as discussed with your family and \noutpatient providers.',
    'Dear Ms. ___,\n\nIt was a pleasure being part of your care at ___.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
```

<!--
### Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details>
-->

<!--
### Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details>
-->

<!--
### Out-of-Scope Use

*List how the model may foreseeably be misused and address what users ought not to do with the model.*
-->

<!--
## Bias, Risks and Limitations

*What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
-->

<!--
### Recommendations

*What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
-->

## Training Details

### Training Dataset

#### Unnamed Dataset

* Size: 274,230 training samples
* Columns: <code>sentence_0</code>, <code>sentence_1</code>, and <code>label</code>
* Approximate statistics based on the first 1000 samples:
  |         | sentence_0                                                                         | sentence_1                                                                         | label                                                          |
  |:--------|:-----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------|
  | type    | string                                                                             | string                                                                             | float                                                          |
  | details | <ul><li>min: 5 tokens</li><li>mean: 26.85 tokens</li><li>max: 256 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 23.88 tokens</li><li>max: 256 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.17</li><li>max: 1.0</li></ul> |
* Samples:
  | sentence_0                                                                                                                                             | sentence_1                                                                                                                           | label            |
  |:-------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------|:-----------------|
  | <code>In ___, he was found to have metastasis in right third <br>and fifth ribs and multiple pulmonary nodules.</code>                                 | <code>Radiologic studies were <br>performed to look for spread of the cancer to your brain and <br>these tests were negative.</code> | <code>1.0</code> |
  | <code>Docusate Sodium 100 mg PO BID:PRN Constipation - First Line  <br><br>7.</code>                                                                   | <code>-You have also been given Additional Medications to control your <br>pain.</code>                                              | <code>0.0</code> |
  | <code>#) Asthma<br>- COntinued home fluticasone 50mcg spray, 2 puffs each nostril <br>QD<br>-Recommend outpatient follow-up as appropriate<br>.</code> | <code>Severe pain NOT relieved by your medication.</code>                                                                            | <code>0.0</code> |
* Loss: [<code>CosineSimilarityLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) with these parameters:
  ```json
  {
      "loss_fct": "torch.nn.modules.loss.MSELoss"
  }
  ```

### Training Hyperparameters
#### Non-Default Hyperparameters

- `per_device_train_batch_size`: 16
- `per_device_eval_batch_size`: 16
- `multi_dataset_batch_sampler`: round_robin

#### All Hyperparameters
<details><summary>Click to expand</summary>

- `overwrite_output_dir`: False
- `do_predict`: False
- `eval_strategy`: no
- `prediction_loss_only`: True
- `per_device_train_batch_size`: 16
- `per_device_eval_batch_size`: 16
- `per_gpu_train_batch_size`: None
- `per_gpu_eval_batch_size`: None
- `gradient_accumulation_steps`: 1
- `eval_accumulation_steps`: None
- `torch_empty_cache_steps`: None
- `learning_rate`: 5e-05
- `weight_decay`: 0.0
- `adam_beta1`: 0.9
- `adam_beta2`: 0.999
- `adam_epsilon`: 1e-08
- `max_grad_norm`: 1
- `num_train_epochs`: 3
- `max_steps`: -1
- `lr_scheduler_type`: linear
- `lr_scheduler_kwargs`: {}
- `warmup_ratio`: 0.0
- `warmup_steps`: 0
- `log_level`: passive
- `log_level_replica`: warning
- `log_on_each_node`: True
- `logging_nan_inf_filter`: True
- `save_safetensors`: True
- `save_on_each_node`: False
- `save_only_model`: False
- `restore_callback_states_from_checkpoint`: False
- `no_cuda`: False
- `use_cpu`: False
- `use_mps_device`: False
- `seed`: 42
- `data_seed`: None
- `jit_mode_eval`: False
- `use_ipex`: False
- `bf16`: False
- `fp16`: False
- `fp16_opt_level`: O1
- `half_precision_backend`: auto
- `bf16_full_eval`: False
- `fp16_full_eval`: False
- `tf32`: None
- `local_rank`: 0
- `ddp_backend`: None
- `tpu_num_cores`: None
- `tpu_metrics_debug`: False
- `debug`: []
- `dataloader_drop_last`: False
- `dataloader_num_workers`: 0
- `dataloader_prefetch_factor`: None
- `past_index`: -1
- `disable_tqdm`: False
- `remove_unused_columns`: True
- `label_names`: None
- `load_best_model_at_end`: False
- `ignore_data_skip`: False
- `fsdp`: []
- `fsdp_min_num_params`: 0
- `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
- `fsdp_transformer_layer_cls_to_wrap`: None
- `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
- `deepspeed`: None
- `label_smoothing_factor`: 0.0
- `optim`: adamw_torch
- `optim_args`: None
- `adafactor`: False
- `group_by_length`: False
- `length_column_name`: length
- `ddp_find_unused_parameters`: None
- `ddp_bucket_cap_mb`: None
- `ddp_broadcast_buffers`: False
- `dataloader_pin_memory`: True
- `dataloader_persistent_workers`: False
- `skip_memory_metrics`: True
- `use_legacy_prediction_loop`: False
- `push_to_hub`: False
- `resume_from_checkpoint`: None
- `hub_model_id`: None
- `hub_strategy`: every_save
- `hub_private_repo`: None
- `hub_always_push`: False
- `gradient_checkpointing`: False
- `gradient_checkpointing_kwargs`: None
- `include_inputs_for_metrics`: False
- `include_for_metrics`: []
- `eval_do_concat_batches`: True
- `fp16_backend`: auto
- `push_to_hub_model_id`: None
- `push_to_hub_organization`: None
- `mp_parameters`: 
- `auto_find_batch_size`: False
- `full_determinism`: False
- `torchdynamo`: None
- `ray_scope`: last
- `ddp_timeout`: 1800
- `torch_compile`: False
- `torch_compile_backend`: None
- `torch_compile_mode`: None
- `dispatch_batches`: None
- `split_batches`: None
- `include_tokens_per_second`: False
- `include_num_input_tokens_seen`: False
- `neftune_noise_alpha`: None
- `optim_target_modules`: None
- `batch_eval_metrics`: False
- `eval_on_start`: False
- `use_liger_kernel`: False
- `eval_use_gather_object`: False
- `average_tokens_across_devices`: False
- `prompts`: None
- `batch_sampler`: batch_sampler
- `multi_dataset_batch_sampler`: round_robin

</details>

### Training Logs
<details><summary>Click to expand</summary>

| Epoch  | Step  | Training Loss |
|:------:|:-----:|:-------------:|
| 0.0292 | 500   | 0.106         |
| 0.0583 | 1000  | 0.0991        |
| 0.0875 | 1500  | 0.097         |
| 0.1167 | 2000  | 0.0966        |
| 0.1459 | 2500  | 0.0953        |
| 0.1750 | 3000  | 0.0946        |
| 0.2042 | 3500  | 0.0936        |
| 0.2334 | 4000  | 0.0925        |
| 0.2625 | 4500  | 0.0909        |
| 0.2917 | 5000  | 0.092         |
| 0.3209 | 5500  | 0.0922        |
| 0.3501 | 6000  | 0.0897        |
| 0.3792 | 6500  | 0.0915        |
| 0.4084 | 7000  | 0.0912        |
| 0.4376 | 7500  | 0.0904        |
| 0.4667 | 8000  | 0.0908        |
| 0.4959 | 8500  | 0.0913        |
| 0.5251 | 9000  | 0.0867        |
| 0.5543 | 9500  | 0.0896        |
| 0.5834 | 10000 | 0.0885        |
| 0.6126 | 10500 | 0.0878        |
| 0.6418 | 11000 | 0.0907        |
| 0.6709 | 11500 | 0.0881        |
| 0.7001 | 12000 | 0.0877        |
| 0.7293 | 12500 | 0.0818        |
| 0.7585 | 13000 | 0.0905        |
| 0.7876 | 13500 | 0.0862        |
| 0.8168 | 14000 | 0.0889        |
| 0.8460 | 14500 | 0.0889        |
| 0.8751 | 15000 | 0.0858        |
| 0.9043 | 15500 | 0.0875        |
| 0.9335 | 16000 | 0.086         |
| 0.9627 | 16500 | 0.0863        |
| 0.9918 | 17000 | 0.0859        |
| 1.0210 | 17500 | 0.078         |
| 1.0502 | 18000 | 0.079         |
| 1.0793 | 18500 | 0.0783        |
| 1.1085 | 19000 | 0.0775        |
| 1.1377 | 19500 | 0.078         |
| 1.1669 | 20000 | 0.0791        |
| 1.1960 | 20500 | 0.0786        |
| 1.2252 | 21000 | 0.0776        |
| 1.2544 | 21500 | 0.0782        |
| 1.2835 | 22000 | 0.0766        |
| 1.3127 | 22500 | 0.0814        |
| 1.3419 | 23000 | 0.0755        |
| 1.3711 | 23500 | 0.0772        |
| 1.4002 | 24000 | 0.0798        |
| 1.4294 | 24500 | 0.0774        |
| 1.4586 | 25000 | 0.0784        |
| 1.4877 | 25500 | 0.0776        |
| 1.5169 | 26000 | 0.0764        |
| 1.5461 | 26500 | 0.0778        |
| 1.5753 | 27000 | 0.0797        |
| 1.6044 | 27500 | 0.0779        |
| 1.6336 | 28000 | 0.0762        |
| 1.6628 | 28500 | 0.0768        |
| 1.6919 | 29000 | 0.08          |
| 1.7211 | 29500 | 0.0736        |
| 1.7503 | 30000 | 0.0763        |
| 1.7795 | 30500 | 0.0757        |
| 1.8086 | 31000 | 0.0783        |
| 1.8378 | 31500 | 0.0745        |
| 1.8670 | 32000 | 0.0759        |
| 1.8961 | 32500 | 0.081         |
| 1.9253 | 33000 | 0.078         |
| 1.9545 | 33500 | 0.0755        |
| 1.9837 | 34000 | 0.0763        |
| 2.0128 | 34500 | 0.0763        |
| 2.0420 | 35000 | 0.0696        |
| 2.0712 | 35500 | 0.0703        |
| 2.1004 | 36000 | 0.071         |
| 2.1295 | 36500 | 0.0688        |
| 2.1587 | 37000 | 0.068         |
| 2.1879 | 37500 | 0.0731        |
| 2.2170 | 38000 | 0.0716        |
| 2.2462 | 38500 | 0.0729        |
| 2.2754 | 39000 | 0.0695        |
| 2.3046 | 39500 | 0.0713        |
| 2.3337 | 40000 | 0.0727        |
| 2.3629 | 40500 | 0.0682        |
| 2.3921 | 41000 | 0.0675        |
| 2.4212 | 41500 | 0.0695        |
| 2.4504 | 42000 | 0.0706        |
| 2.4796 | 42500 | 0.0718        |
| 2.5088 | 43000 | 0.0716        |
| 2.5379 | 43500 | 0.0693        |
| 2.5671 | 44000 | 0.0717        |
| 2.5963 | 44500 | 0.0683        |
| 2.6254 | 45000 | 0.0672        |
| 2.6546 | 45500 | 0.069         |
| 2.6838 | 46000 | 0.0714        |
| 2.7130 | 46500 | 0.0734        |
| 2.7421 | 47000 | 0.0681        |
| 2.7713 | 47500 | 0.07          |
| 2.8005 | 48000 | 0.0712        |
| 2.8296 | 48500 | 0.0676        |
| 2.8588 | 49000 | 0.0684        |
| 2.8880 | 49500 | 0.0724        |
| 2.9172 | 50000 | 0.0702        |
| 2.9463 | 50500 | 0.071         |
| 2.9755 | 51000 | 0.0707        |

</details>

### Framework Versions
- Python: 3.10.12
- Sentence Transformers: 3.4.1
- Transformers: 4.49.0
- PyTorch: 2.3.1+cu121
- Accelerate: 1.4.0
- Datasets: 3.3.2
- Tokenizers: 0.21.0

## Citation

### BibTeX

#### Sentence Transformers
```bibtex
@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",
}
```

<!--
## Glossary

*Clearly define terms in order to be accessible across audiences.*
-->

<!--
## Model Card Authors

*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
-->

<!--
## Model Card Contact

*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
-->