--- 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 | | | | * 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,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 | | | | * 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 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
Click to expand - `overwrite_output_dir`: False - `do_predict`: False - `eval_strategy`: steps - `prediction_loss_only`: True - `per_device_train_batch_size`: 16 - `per_device_eval_batch_size`: 16 - `per_gpu_train_batch_size`: None - `per_gpu_eval_batch_size`: None - `gradient_accumulation_steps`: 1 - `eval_accumulation_steps`: None - `learning_rate`: 2e-05 - `weight_decay`: 0.0 - `adam_beta1`: 0.9 - `adam_beta2`: 0.999 - `adam_epsilon`: 1e-08 - `max_grad_norm`: 1.0 - `num_train_epochs`: 1 - `max_steps`: -1 - `lr_scheduler_type`: linear - `lr_scheduler_kwargs`: {} - `warmup_ratio`: 0.1 - `warmup_steps`: 0 - `log_level`: passive - `log_level_replica`: warning - `log_on_each_node`: True - `logging_nan_inf_filter`: True - `save_safetensors`: True - `save_on_each_node`: False - `save_only_model`: False - `restore_callback_states_from_checkpoint`: False - `no_cuda`: False - `use_cpu`: False - `use_mps_device`: False - `seed`: 42 - `data_seed`: None - `jit_mode_eval`: False - `use_ipex`: False - `bf16`: False - `fp16`: False - `fp16_opt_level`: O1 - `half_precision_backend`: auto - `bf16_full_eval`: False - `fp16_full_eval`: False - `tf32`: None - `local_rank`: 0 - `ddp_backend`: None - `tpu_num_cores`: None - `tpu_metrics_debug`: False - `debug`: [] - `dataloader_drop_last`: False - `dataloader_num_workers`: 0 - `dataloader_prefetch_factor`: None - `past_index`: -1 - `disable_tqdm`: False - `remove_unused_columns`: True - `label_names`: None - `load_best_model_at_end`: False - `ignore_data_skip`: False - `fsdp`: [] - `fsdp_min_num_params`: 0 - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False} - `fsdp_transformer_layer_cls_to_wrap`: None - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None} - `deepspeed`: None - `label_smoothing_factor`: 0.0 - `optim`: adamw_torch - `optim_args`: None - `adafactor`: False - `group_by_length`: False - `length_column_name`: length - `ddp_find_unused_parameters`: None - `ddp_bucket_cap_mb`: None - `ddp_broadcast_buffers`: False - `dataloader_pin_memory`: True - `dataloader_persistent_workers`: False - `skip_memory_metrics`: True - `use_legacy_prediction_loop`: False - `push_to_hub`: False - `resume_from_checkpoint`: None - `hub_model_id`: None - `hub_strategy`: every_save - `hub_private_repo`: False - `hub_always_push`: False - `gradient_checkpointing`: False - `gradient_checkpointing_kwargs`: None - `include_inputs_for_metrics`: False - `eval_do_concat_batches`: True - `fp16_backend`: auto - `push_to_hub_model_id`: None - `push_to_hub_organization`: None - `mp_parameters`: - `auto_find_batch_size`: False - `full_determinism`: False - `torchdynamo`: None - `ray_scope`: last - `ddp_timeout`: 1800 - `torch_compile`: False - `torch_compile_backend`: None - `torch_compile_mode`: None - `dispatch_batches`: None - `split_batches`: None - `include_tokens_per_second`: False - `include_num_input_tokens_seen`: False - `neftune_noise_alpha`: None - `optim_target_modules`: None - `batch_eval_metrics`: False - `prompts`: None - `batch_sampler`: no_duplicates - `multi_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 ```bibtex @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 ```bibtex @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} } ```