---
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:132037
- loss:MultipleNegativesRankingLoss
base_model: BAAI/bge-small-en-v1.5
widget:
- source_sentence: back pain. I'm not sure what to make of it.
sentences:
- 'Observed: back pain — musculoskeletal system'
- Patient is frustrated with the medical system
- 'OPQRST — Severity: fever rated 7/10 by patient'
- source_sentence: I'm absolutely terrified. I've had eye redness for a few days and
I keep imagining the worst.
sentences:
- 'Observed: palpitations and irregular heart rate — cardiovascular — physician
confirmed: Atrial fibrillation'
- 'Patient presented: blood in urine — neurological/cognitive system'
- 'Chief complaint: patient expressed concern, reason not yet specified — calm presentation'
- source_sentence: I take a pill called clopidogrel — not sure of the dose
sentences:
- Patient is drug-free by choice — lifestyle management only
- 'Observed: fatigue and shortness of breath — haematological — physician confirmed:
Anaemia'
- 'Current medication: clopidogrel 75mg daily — antiplatelet — for post-MI'
- source_sentence: I'm on gabapentin for my neuropathic pain
sentences:
- Patient takes no regular medications
- 'Current medication: gabapentin 300mg three times daily — anticonvulsant — for
neuropathic pain'
- 'Observed: palpitations — cardiovascular system'
- source_sentence: my breathing is fast and I feel disoriented
sentences:
- Patient is anxious and hyperventilating due to health anxiety
- 'OPQRST — Onset: abdominal pain started suddenly without warning'
- 'Red flag: tachypnoea + confusion — qSOFA >= 2 — possible sepsis — IMMEDIATE ESCALATION'
pipeline_tag: sentence-similarity
library_name: sentence-transformers
metrics:
- cosine_accuracy
model-index:
- name: SentenceTransformer based on BAAI/bge-small-en-v1.5
results:
- task:
type: triplet
name: Triplet
dataset:
name: rapha val
type: rapha-val
metrics:
- type: cosine_accuracy
value: 1.0
name: Cosine Accuracy
---
# SentenceTransformer based on BAAI/bge-small-en-v1.5
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5). It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for retrieval.
## Model Details
### Model Description
- **Model Type:** Sentence Transformer
- **Base model:** [BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5)
- **Maximum Sequence Length:** 128 tokens
- **Output Dimensionality:** 384 dimensions
- **Similarity Function:** Cosine Similarity
- **Supported Modality:** Text
### Model Sources
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
- **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
### Full Model Architecture
```
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'BertModel'})
(1): Pooling({'embedding_dimension': 384, 'pooling_mode': 'cls', '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("sentence_transformers_model_id")
# Run inference
sentences = [
'my breathing is fast and I feel disoriented',
'Red flag: tachypnoea + confusion — qSOFA >= 2 — possible sepsis — IMMEDIATE ESCALATION',
'Patient is anxious and hyperventilating due to health anxiety',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.8755, 0.1384],
# [0.8755, 1.0000, 0.0772],
# [0.1384, 0.0772, 1.0000]])
```
## Evaluation
### Metrics
#### Triplet
* Dataset: `rapha-val`
* Evaluated with [TripletEvaluator](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.sentence_transformer.evaluation.TripletEvaluator)
| Metric | Value |
|:--------------------|:--------|
| **cosine_accuracy** | **1.0** |
## Training Details
### Training Dataset
#### Unnamed Dataset
* Size: 132,037 training samples
* Columns: anchor, positive, and negative
* Approximate statistics based on the first 100 samples:
| | anchor | positive | negative |
|:---------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|
| type | string | string | string |
| modality | text | text | text |
| details |
I'm trying to stay calm but I have tremors and I genuinely feel like something is very wrong. | Observed: tremors — neurological system | Patient is defensive, resistant to clinical interview |
| neck pain so bad I can't look down and light sensitivity too | Red flag: neck stiffness + photophobia + fever — possible meningitis — IMMEDIATE ESCALATION | Patient reports muscle tension in neck from bad posture |
| neck pain so bad I can't look down and light sensitivity too | Red flag: neck stiffness + photophobia + fever — possible meningitis — IMMEDIATE ESCALATION | Patient reports muscle tension in neck from bad posture |
* Loss: [MultipleNegativesRankingLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
```json
{
"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
}
```
### Evaluation Dataset
#### Unnamed Dataset
* Size: 15,000 evaluation samples
* Columns: anchor, positive, and negative
* Approximate statistics based on the first 100 samples:
| | anchor | positive | negative |
|:---------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|
| type | string | string | string |
| modality | text | text | text |
| details | I'm on prednisolone 5mg daily | Current medication: prednisolone 5mg daily — corticosteroid — for inflammatory condition | Patient is not currently prescribed anything |
| Diagnosis recorded: Community-acquired pneumonia — ICD-10 code J18.9 | Observed: cough, fever, shortness of breath — respiratory/infectious — physician confirmed: Community-acquired pneumonia | Observed: cough — upper respiratory tract infection — self-limiting, no antibiotics |
| breast lump. | Session start: patient presented with unspecified concern — Minimal communication style | Patient presented: numbness in limbs — respiratory system |
* Loss: [MultipleNegativesRankingLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
```json
{
"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
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `per_device_train_batch_size`: 256
- `learning_rate`: 2e-05
- `lr_scheduler_type`: cosine
- `warmup_steps`: 0.1
- `bf16`: True
- `per_device_eval_batch_size`: 256
- `load_best_model_at_end`: True
- `dataloader_drop_last`: True
#### All Hyperparameters