---
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:360886
- loss:CoSENTLoss
base_model: sentence-transformers/all-mpnet-base-v2
widget:
- source_sentence: '|Immunosuppressant drug therapy (procedure)| : { |Method (attribute)|
= |Administration - action (qualifier value)|, |Direct substance (attribute)|
= |Auranofin (substance)| }, { |Has intent (attribute)| = |Therapeutic intent
(qualifier value)| }'
sentences:
- Tofacitinib therapy (procedure)
- Mural thrombus of right ventricle following acute myocardial infarction (disorder)
- Neonatal botulism (disorder)
- source_sentence: '|Injury of finger of left hand (disorder)| + |Traumatic blister
of index finger (disorder)| + |Traumatic blister of left hand (disorder)| : {
|Finding site (attribute)| = |Skin structure of left index finger (body structure)|,
|Associated morphology (attribute)| = |Blister (morphologic abnormality)| }, {
|Due to (attribute)| = |Traumatic event (event)| }'
sentences:
- Cardiovascular system closure (procedure)
- Entire skin of lower eyelid and periocular area (body structure)
- Avulsion of nail unit of left little finger (disorder)
- source_sentence: '|Evaluation finding (finding)| : { |Interprets (attribute)| =
|Interferon gamma assay (procedure)|, |Has interpretation (attribute)| = |Positive
(qualifier value)| }'
sentences:
- Gleason pattern (observable entity)
- Interferon gamma assay positive (finding)
- Intentional melphalan overdose (disorder)
- source_sentence: '|Finding of specific antibody level (finding)| : { |Interprets
(attribute)| = |Measurement of viral antibody (procedure)| }'
sentences:
- Lyme detected by immunoblot (finding)
- Primary malignant neoplasm of accessory sinus (disorder)
- Perfusion of lymphatics with hyperthermia (procedure)
- source_sentence: '|Neoplasm of anterior wall of nasopharynx (disorder)| + |Neoplasm
of uncertain behavior of nasopharynx (disorder)| : { |Finding site (attribute)|
= |Structure of anterior wall of nasopharynx (body structure)|, |Associated morphology
(attribute)| = |Neoplasm of uncertain behavior (morphologic abnormality)| }'
sentences:
- Secondary angle-closure glaucoma - synechial (disorder)
- Neoplasm of uncertain behavior of lateral wall of nasopharynx (disorder)
- Product containing precisely cefamandole (as cefamandole nafate) 1 gram/1 vial
powder for conventional release solution for injection (clinical drug)
pipeline_tag: sentence-similarity
library_name: sentence-transformers
metrics:
- pearson_cosine
- spearman_cosine
model-index:
- name: SentenceTransformer based on sentence-transformers/all-mpnet-base-v2
results:
- task:
type: semantic-similarity
name: Semantic Similarity
dataset:
name: sts dev
type: sts-dev
metrics:
- type: pearson_cosine
value: 0.9048593944190657
name: Pearson Cosine
- type: spearman_cosine
value: 0.8556279874385214
name: Spearman Cosine
---
# SentenceTransformer based on sentence-transformers/all-mpnet-base-v2
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2) on the csv dataset. 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:** [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2)
- **Maximum Sequence Length:** 384 tokens
- **Output Dimensionality:** 768 dimensions
- **Similarity Function:** Cosine Similarity
- **Training Dataset:**
- csv
### 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': 384, 'do_lower_case': False}) with Transformer model: MPNetModel
(1): Pooling({'word_embedding_dimension': 768, '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("yyzheng00/all-mpnet-base-v2_snomed_expression")
# Run inference
sentences = [
'|Neoplasm of anterior wall of nasopharynx (disorder)| + |Neoplasm of uncertain behavior of nasopharynx (disorder)| : { |Finding site (attribute)| = |Structure of anterior wall of nasopharynx (body structure)|, |Associated morphology (attribute)| = |Neoplasm of uncertain behavior (morphologic abnormality)| }',
'Neoplasm of uncertain behavior of lateral wall of nasopharynx (disorder)',
'Secondary angle-closure glaucoma - synechial (disorder)',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
```
## Evaluation
### Metrics
#### Semantic Similarity
* Dataset: `sts-dev`
* Evaluated with [EmbeddingSimilarityEvaluator](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
| Metric | Value |
|:--------------------|:-----------|
| pearson_cosine | 0.9049 |
| **spearman_cosine** | **0.8556** |
## Training Details
### Training Dataset
#### csv
* Dataset: csv
* Size: 360,886 training samples
* Columns: text_a, text_b, and label
* Approximate statistics based on the first 1000 samples:
| | text_a | text_b | label |
|:--------|:-------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:------------------------------------------------|
| type | string | string | int |
| details |
|Risk assessment (procedure)| : { |Method (attribute)| = |Evaluation - action (qualifier value)| }, { |Has focus (attribute)| = |At increased risk of ineffective tissue perfusion (finding)| } | Assessment of risk of ineffective tissue perfusion (procedure) | 1 |
| |Chronic inflammatory disorder (disorder)| + |Chronic nervous system disorder (disorder)| + |Meningitis (disorder)| : { |Finding site (attribute)| = |Meninges structure (body structure)|, |Associated morphology (attribute)| = |Chronic inflammatory morphology (morphologic abnormality)| }, { |Clinical course (attribute)| = |Chronic (qualifier value)| } | Chronic meningitis (disorder) | 1 |
| |Imaging of head (procedure)| + |Ultrasound procedure on topographic region (procedure)| : { |Method (attribute)| = |Ultrasound imaging - action (qualifier value)|, |Procedure site - Direct (attribute)| = |Head structure (body structure)| } | Imaging of brain (procedure) | 0 |
* Loss: [CoSENTLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
```json
{
"scale": 20.0,
"similarity_fct": "pairwise_cos_sim"
}
```
### Evaluation Dataset
#### csv
* Dataset: csv
* Size: 360,886 evaluation samples
* Columns: text_a, text_b, and label
* Approximate statistics based on the first 1000 samples:
| | text_a | text_b | label |
|:--------|:-------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:------------------------------------------------|
| type | string | string | int |
| details | |Disorder of fetal abdominal region (disorder)| + |Fetal genitourinary abnormality (disorder)| + |Kidney disease (disorder)| : { |Occurrence (attribute)| = |Fetal period (qualifier value)|, |Finding site (attribute)| = |Kidney structure (body structure)|, |Associated morphology (attribute)| = |Morphologically abnormal structure (morphologic abnormality)|, |Pathological process (attribute)| = |Pathological developmental process (qualifier value)| } | Early urethral obstruction sequence (disorder) | 0 |
| |Computed tomography of pelvis for brachytherapy planning (procedure)| + |Computed tomography of prostate for radiotherapy planning (procedure)| : { |Has focus (attribute)| = |Treatment planning for brachytherapy (procedure)| }, { |Method (attribute)| = |Computed tomography imaging - action (qualifier value)|, |Procedure site - Direct (attribute)| = |Prostatic structure (body structure)| } | Computed tomography of prostate with contrast for radiotherapy planning (procedure) | 0 |
| |Product containing only hydroxyzine in oral dose form (medicinal product form)| : |Has manufactured dose form (attribute)| = |Conventional release oral capsule (dose form)|, |Has unit of presentation (attribute)| = |Capsule (unit of presentation)|, |Count of base of active ingredient (attribute)| = #1, { |Has precise active ingredient (attribute)| = |Hydroxyzine pamoate (substance)|, |Has basis of strength substance (attribute)| = |Hydroxyzine pamoate (substance)|, |Has presentation strength numerator value (attribute)| = #100, |Has presentation strength numerator unit (attribute)| = |milligram (qualifier value)|, |Has presentation strength denominator value (attribute)| = #1, |Has presentation strength denominator unit (attribute)| = |Capsule (unit of presentation)| } | Hydroxyzine pamoate 100mg capsule (product) | 1 |
* Loss: [CoSENTLoss](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosentloss) with these parameters:
```json
{
"scale": 20.0,
"similarity_fct": "pairwise_cos_sim"
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `per_device_train_batch_size`: 16
- `per_device_eval_batch_size`: 16
- `num_train_epochs`: 1
- `warmup_ratio`: 0.1
- `fp16`: True
- `batch_sampler`: no_duplicates
#### All Hyperparameters