metadata
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 model finetuned from 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
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Training Dataset:
- parquet
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
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:
pip install -U sentence-transformers
Then you can load this model and run inference.
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-validationandai-job-test - Evaluated with
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, andNegLongDesc - Approximate statistics based on the first 1000 samples:
Entities PosLongDesc NegLongDesc type string string string details - min: 3 tokens
- mean: 155.39 tokens
- max: 485 tokens
- min: 4 tokens
- mean: 10.62 tokens
- max: 32 tokens
- min: 3 tokens
- mean: 10.35 tokens
- max: 31 tokens
- Samples:
Entities PosLongDesc NegLongDesc 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,treatmentRash and other nonspecific skin eruptionAcute 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,intentionalEpileptic seizures related to external causes, not intractable, without status epilepticusCOVID-19amc 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,throatpainPain in throatEncounter for observation for suspected exposure to other biological agents ruled out - Loss:
MultipleNegativesRankingLosswith these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
Evaluation Dataset
parquet
- Dataset: parquet
- Size: 999 evaluation samples
- Columns:
Entities,PosLongDesc, andNegLongDesc - Approximate statistics based on the first 999 samples:
Entities PosLongDesc NegLongDesc type string string string details - min: 4 tokens
- mean: 154.58 tokens
- max: 470 tokens
- min: 4 tokens
- mean: 10.61 tokens
- max: 31 tokens
- min: 4 tokens
- mean: 10.12 tokens
- max: 35 tokens
- Samples:
Entities PosLongDesc NegLongDesc 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 daysAcute atopic conjunctivitis, bilateralDeficiency of other specified B group vitaminspi,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,sideLocal infection of the skin and subcutaneous tissue, unspecifiedInflammatory polyarthropathyrespiratory rate,sp,pain,sy,lic,bp,mm,dia,bp,mm,height,weight,00 kg,repeat,prescriptionMenopausal and female climacteric statesCOVID-19 - Loss:
MultipleNegativesRankingLosswith these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: stepsper_device_train_batch_size: 16per_device_eval_batch_size: 16learning_rate: 2e-05num_train_epochs: 1warmup_ratio: 0.1batch_sampler: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Falsefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Falsehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseeval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportional
Training Logs
| Epoch | Step | Training Loss | Validation Loss | ai-job-validation_cosine_accuracy | ai-job-test_cosine_accuracy |
|---|---|---|---|---|---|
| -1 | -1 | - | - | 0.5495 | - |
| 0.2 | 100 | 2.8729 | 1.8172 | 0.8789 | - |
| 0.4 | 200 | 2.085 | 1.4398 | 0.9259 | - |
| 0.6 | 300 | 1.8233 | 1.3448 | 0.9339 | - |
| 0.8 | 400 | 1.6871 | 1.2579 | 0.9409 | - |
| 1.0 | 500 | 1.4881 | 1.2327 | 0.9429 | - |
| -1 | -1 | - | - | 0.9429 | 0.9291 |
Framework Versions
- Python: 3.11.4
- Sentence Transformers: 3.4.1
- Transformers: 4.41.2
- PyTorch: 2.3.1+cpu
- Accelerate: 1.3.0
- Datasets: 3.2.0
- Tokenizers: 0.19.1
Citation
BibTeX
Sentence Transformers
@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",
}
MultipleNegativesRankingLoss
@misc{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}