CoolFace
Modelpublic

surajvbangera/mediclaim_embedding

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes401downloads
Model Card

SentenceTransformer based on sentence-transformers/multi-qa-mpnet-base-cos-v1

This is a sentence-transformers model finetuned from sentence-transformers/multi-qa-mpnet-base-cos-v1 on the mediclaim 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/multi-qa-mpnet-base-cos-v1 <!-- at revision 822dbc9732879fe45b5d79fdb372f2ccec4c76b5 -->
  • —Maximum Sequence Length: 512 tokens
  • —Output Dimensionality: 768 dimensions
  • —Similarity Function: Cosine Similarity
  • —Training Dataset:
  • —mediclaim <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, '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("surajvbangera/mediclaim_embedding")
# Run inference
sentences = [
    'what kind of coverage is provided by insurance for medical expenses that go beyond the normal amount?',
    'health insurance cover and provides wider health protection for you and your family. In case of higher expenses \ndue to illness or accidents, Extra Care Plus policy takes care of the additional expenses. It is important to consider',
    'Age/\ndeduc-\ntible\n200000 200000 300000 200000 300000 500000 300000 500000 300000 500000 1000000 300000 500000 1000000 300000 500000 1000000\n21-25 6,544 7,011 4,345 10,389 7,490 5,127 9,839 7,283 11,767 9,087 6,289 13,419 10,054 7,343 19,518 16,543 13,717',
]
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]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Information Retrieval
Metricdim_768dim_512dim_256dim_128dim_64
cosine_accuracy@10.30210.28120.30210.27080.25
cosine_accuracy@30.80210.78120.79170.78120.7292
cosine_accuracy@50.8750.8750.88540.84380.8333
cosine_accuracy@100.95830.94790.93750.94790.9167
cosine_precision@10.30210.28120.30210.27080.25
cosine_precision@30.26740.26040.26390.26040.2431
cosine_precision@50.1750.1750.17710.16870.1667
cosine_precision@100.09580.09480.09380.09480.0917
cosine_recall@10.30210.28120.30210.27080.25
cosine_recall@30.80210.78120.79170.78120.7292
cosine_recall@50.8750.8750.88540.84380.8333
cosine_recall@100.95830.94790.93750.94790.9167
cosine_ndcg@100.64980.62940.63970.62290.5922
cosine_mrr@100.54840.52510.5410.51670.4863
cosine_map@1000.55130.52870.54460.51870.4908

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

mediclaim
  • —Dataset: mediclaim at 943cab1
  • —Size: 956 training samples
  • —Columns: <code>anchor</code> and <code>positive</code>
  • —Approximate statistics based on the first 956 samples: | | anchor | positive | |:--------|:-----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 10 tokens</li><li>mean: 23.14 tokens</li><li>max: 85 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 57.2 tokens</li><li>max: 135 tokens</li></ul> |
  • —Samples: | anchor | positive | |:---------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Can I get a preventive health check-up covered under my insurance, and if yes, is there a limit to it?</code> | <code>by the Medical Practitioner.<br> vii. The Deductible shall not be applicable on this bene�t.<br> Stay Fit Health Check Up<br> The Insured may avail a health check-up, only for Preventive <br>Test, up to a limit speci�ed in the Policy Schedule, provided</code> | | <code>Which claims are excluded if they don't follow the Transplantation of Human Organs Amendment Bill 2011?</code> | <code>4 CIN: U66010PN2000PLC015329, UIN: BAJHLIP23069V032223<br> Specific exclusions:<br> 1. Claims which have NOT been admitted under Medical expenses section<br> 2. Claims not in compliance with THE TRANSPLANTATION OF HUMAN ORGANS (AMENDMENT) BILL, 2011</code> | | <code>Will the insurance pay for lawful abortion and related hospital stays?</code> | <code>ii. We will also cover expenses towards lawful medical termination of pregnancy during the Policy period.<br> iii. In patient Hospitalization Expenses of pre-natal and post-natal hospitalization</code> |
  • —Loss: <code>MatryoshkaLoss</code> with these parameters:
json
  {
      "loss": "MultipleNegativesRankingLoss",
      "matryoshka_dims": [
          768,
          512,
          256,
          128,
          64
      ],
      "matryoshka_weights": [
          1,
          1,
          1,
          1,
          1
      ],
      "n_dims_per_step": -1
  }

Evaluation Dataset

mediclaim
  • —Dataset: mediclaim at 943cab1
  • —Size: 956 evaluation samples
  • —Columns: <code>anchor</code> and <code>positive</code>
  • —Approximate statistics based on the first 956 samples: | | anchor | positive | |:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 10 tokens</li><li>mean: 22.4 tokens</li><li>max: 62 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 56.76 tokens</li><li>max: 133 tokens</li></ul> |
  • —Samples: | anchor | positive | |:---------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Is there any refund for medical exams if I get a policy and it's accepted?</code> | <code>• If pre-policy checkup is conducted, 50% of the medical tests charges would be reimbursed, subject to acceptance <br>of proposal and policy issuance.<br>Age of the person <br>to be insured<br>Sum Insured Medical Examination</code> | | <code>Are there any exclusions for coverage of substance abuse treatment or its consequences?</code> | <code>are payable but not the complete claim. <br>12. T reatment for Alcoholism, drug or substance abuse or any addictive condition and consequences thereof. <br>(Excl12)</code> | | <code>Can you tell me about the medical bills I might have within 90 days after being discharged?</code> | <code>CIN: U66010PN2000PLC015329, UIN:BAJHLIP23069V032223 3<br> c. Post-hospitalisation expenses<br> The medical expenses incurred in the 90 days immediately after you were discharged, provided that:</code> |
  • —Loss: <code>MatryoshkaLoss</code> with these parameters:
json
  {
      "loss": "MultipleNegativesRankingLoss",
      "matryoshka_dims": [
          768,
          512,
          256,
          128,
          64
      ],
      "matryoshka_weights": [
          1,
          1,
          1,
          1,
          1
      ],
      "n_dims_per_step": -1
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —eval_strategy: epoch
  • —per_device_train_batch_size: 32
  • —per_device_eval_batch_size: 16
  • —gradient_accumulation_steps: 16
  • —learning_rate: 2e-05
  • —num_train_epochs: 40
  • —lr_scheduler_type: cosine
  • —warmup_ratio: 0.1
  • —fp16: True
  • —load_best_model_at_end: True
  • —optim: adamwtorchfused
  • —batch_sampler: no_duplicates
All Hyperparameters

<details><summary>Click to expand</summary>

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: epoch
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 32
  • —per_device_eval_batch_size: 16
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 16
  • —eval_accumulation_steps: None
  • —torch_empty_cache_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: 40
  • —max_steps: -1
  • —lr_scheduler_type: cosine
  • —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: True
  • —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: True
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_min_num_params: 0
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamwtorchfused
  • —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: None
  • —hub_always_push: False
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —include_for_metrics: []
  • —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
  • —eval_on_start: False
  • —use_liger_kernel: False
  • —eval_use_gather_object: False
  • —average_tokens_across_devices: False
  • —prompts: None
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional

</details>

Training Logs

EpochStepTraining LossValidation Lossdim_768_cosine_ndcg@10dim_512_cosine_ndcg@10dim_256_cosine_ndcg@10dim_128_cosine_ndcg@10dim_64_cosine_ndcg@10
-1-1--0.47230.47480.50150.45890.3867
1.02-1.59250.48210.48460.51220.46040.3971
2.04-1.59250.48210.48460.51220.46040.3971
3.06-1.04020.54310.54680.55300.50090.4435
4.08-0.79000.58760.59260.60750.54840.4726
5.01033.06460.60770.58900.60390.62700.57790.5072
6.012-0.52130.63570.63790.65220.59660.5417
7.014-0.47350.64250.63950.62860.59950.5795
8.016-0.44160.62530.63870.62270.59030.5738
9.018-0.42360.63030.64890.63870.61790.5670
10.0208.84560.41150.64650.65190.63690.61120.572
11.022-0.40590.64470.62700.63180.61690.5950
12.024-0.40360.63820.63180.63460.60630.6026
13.026-0.40220.64850.64100.64410.61630.5900
14.028-0.40220.65200.64260.65970.62250.6001
15.0304.46020.40330.65070.63630.65760.62170.6134
16.032-0.40470.65300.63890.66090.63500.6068
17.034-0.40580.65010.63440.65010.62810.5997
18.036-0.40670.65090.63330.65530.63600.6050
19.038-0.40700.65610.63310.66020.63970.6051
20.0403.96050.40710.64980.62940.63970.62290.5922
  • —The bold row denotes the saved checkpoint.

Framework Versions

  • —Python: 3.11.11
  • —Sentence Transformers: 3.4.1
  • —Transformers: 4.48.3
  • —PyTorch: 2.5.1+cu124
  • —Accelerate: 1.3.0
  • —Datasets: 3.3.2
  • —Tokenizers: 0.21.0

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",
}
MatryoshkaLoss
bibtex
@misc{kusupati2024matryoshka,
    title={Matryoshka Representation Learning},
    author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
    year={2024},
    eprint={2205.13147},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}
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}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->