CoolFace
Modelpublic

lsy9874205/heal-protocol-embeddings

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

SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2

This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2. It maps sentences & paragraphs to a 384-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-MiniLM-L6-v2 <!-- at revision fa97f6e7cb1a59073dff9e6b13e2715cf7475ac9 -->
  • Maximum Sequence Length: 256 tokens
  • Output Dimensionality: 384 dimensions
  • Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: BertModel 
  (1): Pooling({'word_embedding_dimension': 384, '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("sentence_transformers_model_id")
# Run inference
sentences = [
    'To evaluate the cost-effectiveness of ED-initiated buprenorphine with peer navigator support compared to enhanced referral to treatment.',
    'Concerns about withdrawal precipitation',
    '11.1.2 Steering Committee\n\nComposition:\n- Executive Committee members\n- Site investigators\n- Patient/community representatives\n- Key co-investigators\n\nResponsibilities:\n- Protocol revisions\n- Implementation monitoring\n- Recruitment oversight\n- Review of study progress\n- Addressing operational challenges',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]

# 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. -->

<!--

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

Unnamed Dataset
  • Size: 247,936 training samples
  • Columns: <code>sentence0</code>, <code>sentence1</code>, and <code>label</code>
  • Approximate statistics based on the first 1000 samples: | | sentence0 | sentence1 | label | |:--------|:-----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:--------------------------------------------------------------| | type | string | string | float | | details | <ul><li>min: 3 tokens</li><li>mean: 48.16 tokens</li><li>max: 256 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 44.76 tokens</li><li>max: 256 tokens</li></ul> | <ul><li>min: 0.5</li><li>mean: 0.5</li><li>max: 1.0</li></ul> |
  • Samples: | sentence0 | sentence1 | label | |:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------| | <code>10.4 Participant Confidentiality</code> | <code>9.1.1 Data and Safety Monitoring Board (DSMB)<br><br>An independent DSMB will be established, consisting of experts in emergency medicine, addiction medicine, biostatistics, and ethics. The DSMB will:<br>- Review and approve the monitoring plan<br>- Meet at least annually to review study progress and safety<br>- Review any serious adverse events<br>- Make recommendations regarding study continuation or modification</code> | <code>0.5</code> | | <code>7.1 Randomization<br><br>Participants will be randomly assigned in a 1:1 ratio to receive either BUP-NX or XR-NTX using a computer-generated randomization sequence with permuted blocks of varying sizes. Randomization will be stratified by site and by opioid type (short-acting prescription opioids, heroin, or fentanyl as primary opioid of use).</code> | <code>10.3 Risk Mitigation</code> | <code>0.5</code> | | <code>11.1 Study Leadership and Governance</code> | <code>To examine patient perspectives on intervention acceptability and barriers/facilitators to engagement through qualitative interviews with a subset of participants.</code> | <code>0.5</code> |
  • Loss: <code>CosineSimilarityLoss</code> with these parameters:
json
  {
      "loss_fct": "torch.nn.modules.loss.MSELoss"
  }

Training Hyperparameters

Non-Default Hyperparameters
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • multi_dataset_batch_sampler: round_robin
All Hyperparameters

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

  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: no
  • 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
  • torch_empty_cache_steps: None
  • learning_rate: 5e-05
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1
  • num_train_epochs: 3
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • 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: {'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: 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: 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: batch_sampler
  • multi_dataset_batch_sampler: round_robin

</details>

Training Logs

EpochStepTraining Loss
0.03235000.0107
0.064510000.0025
0.096815000.0023
0.129120000.0023
0.161325000.0021
0.193630000.002
0.225935000.0018
0.258140000.0018
0.290445000.0017
0.322750000.0017
0.354955000.0017
0.387260000.0016
0.419565000.0015
0.451770000.0016
0.484075000.0016
0.516380000.0015
0.548585000.0015
0.580890000.0014
0.613195000.0015
0.6453100000.0015
0.6776105000.0014
0.7099110000.0015
0.7421115000.0013
0.7744120000.0013
0.8067125000.0013
0.8389130000.0013
0.8712135000.0013
0.9035140000.0013
0.9357145000.0013
0.9680150000.0012
1.0003155000.0012
1.0325160000.0011
1.0648165000.0011
1.0971170000.0011
1.1293175000.0011
1.1616180000.0011
1.1939185000.001
1.2261190000.001
1.2584195000.0011
1.2907200000.001
1.3229205000.0011
1.3552210000.001
1.3875215000.001
1.4197220000.001
1.4520225000.001
1.4843230000.001
1.5165235000.0009
1.5488240000.001
1.5811245000.001
1.6133250000.0009
1.6456255000.001
1.6779260000.001
1.7101265000.001
1.7424270000.001
1.7747275000.001
1.8069280000.001
1.8392285000.001
1.8715290000.001
1.9037295000.0009
1.9360300000.0009
1.9682305000.0009
2.0005310000.0009
2.0328315000.0008
2.0650320000.0008
2.0973325000.0007
2.1296330000.0008
2.1618335000.0008
2.1941340000.0008
2.2264345000.0008
2.2586350000.0008
2.2909355000.0008
2.3232360000.0008
2.3554365000.0008
2.3877370000.0008
2.4200375000.0008
2.4522380000.0008
2.4845385000.0008
2.5168390000.0008
2.5490395000.0008
2.5813400000.0007
2.6136405000.0008
2.6458410000.0008
2.6781415000.0007
2.7104420000.0007
2.7426425000.0007
2.7749430000.0008
2.8072435000.0008
2.8394440000.0007
2.8717445000.0008
2.9040450000.0008
2.9362455000.0007
2.9685460000.0007

Framework Versions

  • Python: 3.13.2
  • Sentence Transformers: 3.4.1
  • Transformers: 4.49.0
  • PyTorch: 2.6.0
  • Accelerate: 1.4.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",
}

HEAL Protocol Embeddings

This model is fine-tuned from all-MiniLM-L6-v2 on HEAL Initiative clinical protocols.

Performance Evaluation

Comparison with OpenAI embeddings:

MetricOpenAIFine-tunedChange
Faithfulness0.6670.833⬆️ +0.166
Answer Relevancy0.9860.986=
Context Precision1.0001.000=
Context Recall1.0000.000⬇️ -1.000

Key Findings

  • Improved faithfulness to source material
  • Maintained high answer relevancy
  • Trade-off in context recall

Future Improvements

  1. 1.Retrieval Strategy
  2. 2.Implement hybrid search combining semantic and keyword matching
  3. 3.Add re-ranking for better result ordering
  1. 1.Model Architecture
  2. 2.Experiment with larger base models
  3. 3.Fine-tune with domain-specific loss functions
  1. 1.Data Processing
  2. 2.Optimize chunking strategy
  3. 3.Increase training data diversity <!--

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. -->