---
library_name: sentence-transformers
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:7999
- loss:MultipleNegativesRankingLoss
base_model: medicalai/ClinicalBERT
metrics:
- cosine_accuracy
widget:
- source_sentence: pt,dressing,pi,surgery,2 weeks,o,ozing,regular,dressing,weight,111.
800,height,179. 000,temperature,97. 700,pulse,88. 000,res,19. 000 bp,sy,sto,145.
000 bp,dia,sto,82. 000 spo,2,:,99,cap,blood sugar,ja,undice,ec,no past medical
history,no past medical history,no past medical history,no past medical history,no
past medical history,no past medical history,no past,no,no,no past,no,past,no,no,no,no,no,no,no,no,no,no,no,stable,stable,stable,stable,stable,stable,stable,stable,stable,stable,normal,no,surgical
history,no,surgical history,no,surgical history,no,no
sentences:
- Acne vulgaris
- Encounter for change or removal of surgical wound dressing
- Irritant contact dermatitis due to detergents
- source_sentence: 'fa,dubai,arab emirates,cardiac assessment,chest,pain,nausea,mild,dizzy,sleep,clinic,pulse,70,res,18,res,normal,sao,:,98,air
time,00 : 39 : 00,bp,140 / 100,cap,< 2 sec,temperature,36,>,3 reacts,right,>,3
reacts,total,gcs,15,car,mild'
sentences:
- Dizziness and giddiness
- Pruritus, unspecified
- Acute gastritis without bleeding
- source_sentence: low,back,pain,1,no,sp,fine,lower back,moderate,1 month,no,diseases,no,no,no,no,no,no,single,normal,no,no,no,normal,normal,normal,normal,cvs,cv,normal,abnormal,-
genito - urinary,normal,systems _ cns - cns,normal,musc,mu,normal,ps,normal,systems,endo
- end,normal,normal,haemo,haem,normal,low,back,pain,1 month
sentences:
- Headache
- Muscle spasm of back
- Other chest pain
- source_sentence: 'fa,ap,arab,mobility,knee assessment,ambula,tory,c,/,o,pain,swelling,right,cold
pack,crepebanda,v,pt,transfer,pulse,68r,16,res,normal,sao,: 100,air time,07 :
29 : 00,bp,112 / 78,cap,< 2 sec,4 reacts,right,-,>,3,reacts,gcs,15,pain,4,blood,car
accident,twisted,right ankle'
sentences:
- Unspecified injury of right ankle, initial encounter
- Other spondylosis with radiculopathy, lumbosacral region
- Right upper quadrant pain
- source_sentence: irregular,period,few months,moderate,few months ago,none,weight,90.
000,height,163. 000,temperature,98. 600,pulse,82. 000,respiration,19. 000 bp,systolic,110.
000 bp,diastolic,70. 000,sp,o,2,:,99,cap,blood sugar,ja,und,ice,ec,abd,an,l,girth,head,chest,ch
ida ch vitamin d deficiency,polycystic ovary syndrome,ch ida ch vitamin d deficiency,polycystic
ovary syndrome,ch,ida ch vitamin d deficiency,polycystic ovary syndrome,ch,ida
ch vitamin d deficiency,polycystic ovary syndrome,no,no family,no,no,nation,grade
11,grade 11,grade 11,grade 11,no,no,no,no,normal,normal,normal,normal,_ cvs,cv,normal,normal,irregular
period,cns,cn,normal,mu,normal,normal,normal,normal,normal,normal,irregular period
sentences:
- Pain in right hip
- Radial styloid tenosynovitis [de Quervain]
- Irregular menstruation, unspecified
pipeline_tag: sentence-similarity
model-index:
- name: SentenceTransformer based on medicalai/ClinicalBERT
results:
- task:
type: triplet
name: Triplet
dataset:
name: ai job validation
type: ai-job-validation
metrics:
- type: cosine_accuracy
value: 0.9429429173469543
name: Cosine Accuracy
- task:
type: triplet
name: Triplet
dataset:
name: ai job test
type: ai-job-test
metrics:
- type: cosine_accuracy
value: 0.9290709495544434
name: Cosine Accuracy
---
# SentenceTransformer based on medicalai/ClinicalBERT
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [medicalai/ClinicalBERT](https://huggingface.co/medicalai/ClinicalBERT) on the parquet 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:** [medicalai/ClinicalBERT](https://huggingface.co/medicalai/ClinicalBERT)
- **Maximum Sequence Length:** 512 tokens
- **Output Dimensionality:** 768 dimensions
- **Similarity Function:** Cosine Similarity
- **Training Dataset:**
- parquet
### 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': 512, 'do_lower_case': False}) with Transformer model: DistilBertModel
(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})
)
```
## 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("khaled-omar/distilroberta-ai-job-embeddings")
# Run inference
sentences = [
'irregular,period,few months,moderate,few months ago,none,weight,90. 000,height,163. 000,temperature,98. 600,pulse,82. 000,respiration,19. 000 bp,systolic,110. 000 bp,diastolic,70. 000,sp,o,2,:,99,cap,blood sugar,ja,und,ice,ec,abd,an,l,girth,head,chest,ch ida ch vitamin d deficiency,polycystic ovary syndrome,ch ida ch vitamin d deficiency,polycystic ovary syndrome,ch,ida ch vitamin d deficiency,polycystic ovary syndrome,ch,ida ch vitamin d deficiency,polycystic ovary syndrome,no,no family,no,no,nation,grade 11,grade 11,grade 11,grade 11,no,no,no,no,normal,normal,normal,normal,_ cvs,cv,normal,normal,irregular period,cns,cn,normal,mu,normal,normal,normal,normal,normal,normal,irregular period',
'Irregular menstruation, unspecified',
'Radial styloid tenosynovitis [de Quervain]',
]
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
#### Triplet
* Datasets: `ai-job-validation` and `ai-job-test`
* Evaluated with [TripletEvaluator
](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.TripletEvaluator)
| Metric | ai-job-validation | ai-job-test |
|:--------------------|:------------------|:------------|
| **cosine_accuracy** | **0.9429** | **0.9291** |
## Training Details
### Training Dataset
#### parquet
* Dataset: parquet
* Size: 7,999 training samples
* Columns: Entities
, PosLongDesc
, and NegLongDesc
* Approximate statistics based on the first 1000 samples:
| | Entities | PosLongDesc | NegLongDesc |
|:--------|:------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|
| type | string | string | string |
| details |
it,chiness,since 3 months,it,chiness,since,3 months,weight,90. 100,height,178. 000,temperature,98. 060,pulse,84. 000,respiration,0. 000 bp,sy,sto,122. 000 bp,dia,69. 000,sp,o,:,99,cap,blood sugar,ja,undice,ec,abd,an,rth,nonsignificant,nonsignificant,nonsignifican,t,no family,nonsignificant family,nonsignificant family,nonsignificant,no relevant family history,yes,married, smoker, carpenter,married, smoker, carpenter social,married, smoker, carpenter social history,nonsignificant,nonsignificant,nonsignificant,it,chiness,3 months,treatment
| Rash and other nonspecific skin eruption
| Acute nasopharyngitis [common cold]
|
| amc,dubai,united arab emirates,uma,pa,gut,hari,val,electrocard,gram,pt,amc,sitting,coherent,w /,can,nula,bra,chia,vital,85,18,res,normal,sao,100,air time,17,: 51 : 34,bp,120 / 81,cap,<,2,sec,temperature,> 4 reacts,>,4,reacts,total,gcs,15,pain,0,blood glucose,102,car,accident,drug overdose,intentional
| Epileptic seizures related to external causes, not intractable, without status epilepticus
| COVID-19
|
| amc gate,dubai,united arab emirates,ssi,test,airports,dubai,concourse,ent assessment,throat,transported,endorsed,pulse :,77r,14,res,normal %,sao,2 :,100,air time,05 :,26,:,00,bp,118 / 69,cap,<,2,sec,temperature,36. 7,pupil,left,>,4,reacts,right,>,4,reacts,gcs,15,pain,2,blood glucose,96,car,accident,no,throatpain
| Pain in throat
| Encounter for observation for suspected exposure to other biological agents ruled out
|
* Loss: [MultipleNegativesRankingLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
```json
{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
```
### Evaluation Dataset
#### parquet
* Dataset: parquet
* Size: 999 evaluation samples
* Columns: Entities
, PosLongDesc
, and NegLongDesc
* Approximate statistics based on the first 999 samples:
| | Entities | PosLongDesc | NegLongDesc |
|:--------|:------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|
| type | string | string | string |
| details | it,chy,redness,3 days,both,it,ching,mild,moderate,3 days,weight,50. 200,height,143. 000,temperature,98. 240,pulse,78. 000,respiration,0. 000 bp,systolic,0. 000 bp,dia,sto,lic,0. 000,sp,o,2,:,99,cap,blood sugar,ja,undice,ec,abd,no past medical history,no past medical history,unknown family medical history,negative family,chronic disease,no diabetic mellitus,no hypertention,negative family,chronic disease,no diabetic mellitus,no hypertention,no,7 years and,7 months,7 years,7 months,no,removal,int,removal,int,red,it,chy,it,chy,redness,3 days
| Acute atopic conjunctivitis, bilateral
| Deficiency of other specified B group vitamins
|
| pi,mples,pustules,plus,minus,cyst,both side,of the face,too,it,ching,skin,4,pi,notice,increase,laser removal,facial,expose,sun,pust,cyst,it,weight,52,.,800,height,159. 000,temperature,98. 100,pulse,93. 000,res,0. 000 bp,sy,sto,99. 000 bp,sto,60. 000,sp,o,98,cap,blood sugar,ja,undice,ec,no,no,ro,course,ro,not,course,no diabetic mellitus,no,les,no diabetic,mellit,us,no,les,basic,nation,nation,13,years,months,15 years,11 months,old,pu,ules,plus,cyst,side
| Local infection of the skin and subcutaneous tissue, unspecified
| Inflammatory polyarthropathy
|
| respiratory rate,sp,pain,sy,lic,bp,mm,dia,bp,mm,height,weight,00 kg,repeat,prescription
| Menopausal and female climacteric states
| COVID-19
|
* Loss: [MultipleNegativesRankingLoss
](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
```json
{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
```
### Training Hyperparameters
#### Non-Default Hyperparameters
- `eval_strategy`: steps
- `per_device_train_batch_size`: 16
- `per_device_eval_batch_size`: 16
- `learning_rate`: 2e-05
- `num_train_epochs`: 1
- `warmup_ratio`: 0.1
- `batch_sampler`: no_duplicates
#### All Hyperparameters