---
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- dense
- generated_from_trainer
- dataset_size:13270
- loss:ContrastiveLoss
base_model: cambridgeltl/SapBERT-from-PubMedBERT-fulltext
widget:
- source_sentence: PGE2
sentences:
- Dinoprostone
- Cardiovascular Diseases
- Seizures
- source_sentence: heparin
sentences:
- Heart Failure
- Hyperalgesia
- Heparin
- source_sentence: bipolar mania
sentences:
- Mood Disorders
- Serotonin
- Bipolar Disorder
- source_sentence: cardiac arrhythmia
sentences:
- Acquired Immunodeficiency Syndrome
- Arrhythmias, Cardiac
- Hyperemia
- source_sentence: pulmonary hypertension
sentences:
- Hypertension, Pulmonary
- cabergoline
- Neuroleptic Malignant Syndrome
pipeline_tag: sentence-similarity
library_name: sentence-transformers
---
# SentenceTransformer based on cambridgeltl/SapBERT-from-PubMedBERT-fulltext
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [cambridgeltl/SapBERT-from-PubMedBERT-fulltext](https://huggingface.co/cambridgeltl/SapBERT-from-PubMedBERT-fulltext). It maps sentences & paragraphs to a 768-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:** [cambridgeltl/SapBERT-from-PubMedBERT-fulltext](https://huggingface.co/cambridgeltl/SapBERT-from-PubMedBERT-fulltext)
- **Maximum Sequence Length:** 512 tokens
- **Output Dimensionality:** 768 dimensions
- **Similarity Function:** Cosine Similarity
### 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({'max_seq_length': 512, 'do_lower_case': False, 'architecture': 'BertModel'})
(1): Pooling({'word_embedding_dimension': 768, '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})
)
```
## 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("Stevenf232/fine-tuned-SapBERT4")
# Run inference
sentences = [
'pulmonary hypertension',
'Hypertension, Pulmonary',
'Neuroleptic Malignant Syndrome',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[1.0000, 0.9967, 0.4133],
# [0.9967, 1.0000, 0.4165],
# [0.4133, 0.4165, 1.0000]])
```
## Training Details
### Training Dataset
#### Unnamed Dataset
* Size: 13,270 training samples
* Columns: mention, entity, and label
* Approximate statistics based on the first 1000 samples:
| | mention | entity | label |
|:--------|:---------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:-----------------------------|
| type | string | string | int |
| details |
human immunodeficiency virus | HIV Infections | 1 |
| non-Hodgkin's lymphoma | Lymphoma, Non-Hodgkin | 1 |
| renal cell carsinom | Carcinoma, Renal Cell | 1 |
* Loss: [ContrastiveLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#contrastiveloss) with these parameters:
```json
{
"distance_metric": "SiameseDistanceMetric.COSINE_DISTANCE",
"margin": 0.5,
"size_average": true
}
```
### Evaluation Dataset
#### Unnamed Dataset
* Size: 12,795 evaluation samples
* Columns: mention, entity, and label
* Approximate statistics based on the first 1000 samples:
| | mention | entity | label |
|:--------|:--------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:-----------------------------|
| type | string | string | int |
| details | Postoperative myalgia | Pain, Postoperative | 1 |
| blood loss | Postpartum Hemorrhage | 1 |
| urethane | Urethane | 1 |
* Loss: [ContrastiveLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#contrastiveloss) with these parameters:
```json
{
"distance_metric": "SiameseDistanceMetric.COSINE_DISTANCE",
"margin": 0.5,
"size_average": true
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `learning_rate`: 1e-05
- `optim`: adamw_torch
#### All Hyperparameters