SentenceTransformer based on BAAI/bge-m3

This is a sentence-transformers model finetuned from BAAI/bge-m3. It maps sentences & paragraphs to a 1024-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: BAAI/bge-m3
  • Maximum Sequence Length: 8192 tokens
  • Output Dimensionality: 1024 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 8192, 'do_lower_case': False, 'architecture': 'XLMRobertaModel'})
  (1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, '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:

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("sentence_transformers_model_id")
# Run inference
sentences = [
    '{"patient":"{"age": "58.0", "age_cod": "yr", "gndr_cod": "f", "wt": "101.15", "wt_cod": "kg"}","treatment":"{"drugname": "rinvoq", "route": "oral", "dose": "frequency : daily;?"}","indi_pt":"rheumatoid arthritis"}',
    '{"pt": "pain; headache; dizziness; swelling face; therapy interrupted", "uni_code": "NA"}',
    '{"pt": "alanine aminotransferase increased; aspartate aminotransferase increased; bacteria urine identified; blood pressure increased; blood sodium decreased; blood urea increased; blood urine; cerebral ischaemia; chills; coma; haematocrit decreased; haemoglobin decreased; haemorrhage intracranial; musculoskeletal discomfort; pallor; platelet count decreased; protein urine present; pyrexia; refusal of treatment by patient; sinus pain; urinary casts; urinary sediment present; white blood cell count decreased; white blood cell count increased; white blood cells urine positive", "uni_code": "DE"}',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[ 1.0000,  0.5472, -0.0551],
#         [ 0.5472,  1.0000, -0.1079],
#         [-0.0551, -0.1079,  1.0000]])

Evaluation

Metrics

Information Retrieval

Metric Value
cosine_accuracy@1 0.0021
cosine_accuracy@3 0.0053
cosine_accuracy@5 0.008
cosine_accuracy@10 0.013
cosine_precision@1 0.0021
cosine_precision@3 0.0018
cosine_precision@5 0.0016
cosine_precision@10 0.0013
cosine_recall@1 0.0021
cosine_recall@3 0.0053
cosine_recall@5 0.008
cosine_recall@10 0.013
cosine_ndcg@10 0.0067
cosine_mrr@10 0.0048
cosine_map@100 0.0063

Training Details

Training Dataset

Unnamed Dataset

  • Size: 400,000 training samples
  • Columns: sentence_0 and sentence_1
  • Approximate statistics based on the first 1000 samples:
    sentence_0 sentence_1
    type string string
    details
    • min: 105 tokens
    • mean: 299.0 tokens
    • max: 2505 tokens
    • min: 20 tokens
    • mean: 40.49 tokens
    • max: 282 tokens
  • Samples:
    sentence_0 sentence_1
    {"patient":"{"age": "15.0", "age_cod": "yr", "gndr_cod": "f", "wt": "60.0", "wt_cod": "kg"}","treatment":"{"drugname": "rizatriptan.", "route": "oral", "dose": "qd, tablet"}; {"drugname": "amitriptyline", "route": "oral", "dose": "qd, tablet"}; {"drugname": "mirtazapine.", "route": "oral", "dose": "qd, tablet"}; {"drugname": "sumatriptan.", "route": "oral", "dose": "qd, tablet"}","indi_pt":"suicidal ideation; suicidal ideation; suicidal ideation"} {"pt": "acute respiratory failure; intentional overdose; somnolence; sopor; toxicity to various agents", "uni_code": "HO"}
    {"patient":"{"age": "38.0", "age_cod": "yr", "gndr_cod": "m", "wt": "86.17", "wt_cod": "kg"}","treatment":"{"drugname": "albuterol sulfate.", "route": "respiratory (inhalation)", "dose": "180 mcg, prn"}; {"drugname": "albuterol sulfate.", "route": "respiratory (inhalation)", "dose": "180 mcg, prn"}","indi_pt":"asthma"} {"pt": "chest discomfort; device delivery system issue", "uni_code": "NA"}
    {"patient":"{"age": "62.0", "age_cod": "yr", "gndr_cod": "f", "wt": "90.7", "wt_cod": "kg"}","treatment":"{"drugname": "effexor xr", "route": "nan", "dose": "nan"}; {"drugname": "effexor xr", "route": "nan", "dose": "nan"}; {"drugname": "effexor xr", "route": "nan", "dose": "nan"}; {"drugname": "venlafaxine hcl", "route": "nan", "dose": "nan"}; {"drugname": "venlafaxine hcl", "route": "nan", "dose": "nan"}; {"drugname": "venlafaxine hcl", "route": "nan", "dose": "nan"}; {"drugname": "venlafaxine hydrochloride", "route": "nan", "dose": "nan"}; {"drugname": "venlafaxine hydrochloride", "route": "nan", "dose": "nan"}; {"drugname": "venlafaxine hydrochloride", "route": "nan", "dose": "nan"}; {"drugname": "venlafaxine hydrochloride", "route": "nan", "dose": "nan"}; {"drugname": "venlafaxine hydrochloride", "route": "nan", "dose": "nan"}; {"drugname": "venlafaxine hydrochloride", "route": "nan", "dose": "nan"}; {"drugname": "wellbutrin", "route": "nan", "dose": "100 mg, daily"}","indi_pt":"m... {"pt": "arthropathy; drug ineffective", "uni_code": "NA"}
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • multi_dataset_batch_sampler: round_robin

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 8
  • per_device_eval_batch_size: 8
  • 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: {'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: None
  • hub_always_push: False
  • hub_revision: None
  • 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
  • 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
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: round_robin
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Click to expand
Epoch Step Training Loss cosine_ndcg@10
0.01 500 2.064 -
0.02 1000 1.9201 -
0.03 1500 1.8076 -
0.04 2000 1.7084 -
0.05 2500 1.6477 -
0.06 3000 1.5749 -
0.07 3500 1.5356 -
0.08 4000 1.4819 -
0.09 4500 1.422 -
0.1 5000 1.3966 -
0.11 5500 1.3675 -
0.12 6000 1.3818 -
0.13 6500 1.3584 -
0.14 7000 1.3121 -
0.15 7500 1.312 -
0.16 8000 1.2551 -
0.17 8500 1.2927 -
0.18 9000 1.2369 -
0.19 9500 1.252 -
0.2 10000 1.2314 -
0.21 10500 1.2033 -
0.22 11000 1.2347 -
0.23 11500 1.1843 -
0.24 12000 1.1809 -
0.25 12500 1.1919 -
0.26 13000 1.1592 -
0.27 13500 1.1628 -
0.28 14000 1.1466 -
0.29 14500 1.1374 -
0.3 15000 1.1423 -
0.31 15500 1.1371 -
0.32 16000 1.1454 -
0.33 16500 1.1266 -
0.34 17000 1.1363 -
0.35 17500 1.162 -
0.36 18000 1.125 -
0.37 18500 1.0757 -
0.38 19000 1.0912 -
0.39 19500 1.0784 -
0.4 20000 1.0761 -
0.41 20500 1.1171 -
0.42 21000 1.0636 -
0.43 21500 1.0759 -
0.44 22000 1.0536 -
0.45 22500 1.0589 -
0.46 23000 1.0116 -
0.47 23500 1.0576 -
0.48 24000 1.0583 -
0.49 24500 1.0401 -
0.5 25000 1.0324 -
0.51 25500 1.0211 -
0.52 26000 1.0055 -
0.53 26500 1.0083 -
0.54 27000 1.0241 -
0.55 27500 1.0217 -
0.56 28000 1.0202 -
0.57 28500 0.9915 -
0.58 29000 0.9601 -
0.59 29500 1.0089 -
0.6 30000 0.9765 -
0.61 30500 0.9635 -
0.62 31000 0.9602 -
0.63 31500 0.9607 -
0.64 32000 0.9732 -
0.65 32500 0.9554 -
0.66 33000 0.9314 -
0.67 33500 0.9533 -
0.68 34000 0.9554 -
0.69 34500 0.9422 -
0.7 35000 0.9356 -
0.71 35500 0.9478 -
0.72 36000 0.9426 -
0.73 36500 0.9425 -
0.74 37000 0.9447 -
0.75 37500 0.9251 -
0.76 38000 0.88 -
0.77 38500 0.9306 -
0.78 39000 0.9269 -
0.79 39500 0.8957 -
0.8 40000 0.9576 -
0.81 40500 0.921 -
0.82 41000 0.9027 -
0.83 41500 0.8977 -
0.84 42000 0.9079 -
0.85 42500 0.911 -
0.86 43000 0.9039 -
0.87 43500 0.9062 -
0.88 44000 0.9055 -
0.89 44500 0.8933 -
0.9 45000 0.8942 -
0.91 45500 0.9035 -
0.92 46000 0.8864 -
0.93 46500 0.8937 -
0.94 47000 0.8727 -
0.95 47500 0.8645 -
0.96 48000 0.8426 -
0.97 48500 0.8701 -
0.98 49000 0.8517 -
0.99 49500 0.8635 -
1.0 50000 0.8637 0.0043
1.01 50500 0.7842 -
1.02 51000 0.8217 -
1.03 51500 0.8421 -
1.04 52000 0.7827 -
1.05 52500 0.8445 -
1.06 53000 0.8121 -
1.07 53500 0.8057 -
1.08 54000 0.8027 -
1.09 54500 0.7986 -
1.1 55000 0.8065 -
1.11 55500 0.8096 -
1.12 56000 0.8062 -
1.13 56500 0.7977 -
1.1400 57000 0.7805 -
1.15 57500 0.7898 -
1.16 58000 0.8121 -
1.17 58500 0.777 -
1.18 59000 0.7883 -
1.19 59500 0.7868 -
1.2 60000 0.7805 -
1.21 60500 0.8078 -
1.22 61000 0.7893 -
1.23 61500 0.8214 -
1.24 62000 0.7962 -
1.25 62500 0.7769 -
1.26 63000 0.7775 -
1.27 63500 0.7735 -
1.28 64000 0.8054 -
1.29 64500 0.7613 -
1.3 65000 0.7894 -
1.31 65500 0.7791 -
1.32 66000 0.7628 -
1.33 66500 0.7737 -
1.34 67000 0.7474 -
1.35 67500 0.7773 -
1.3600 68000 0.7615 -
1.37 68500 0.7731 -
1.38 69000 0.7501 -
1.3900 69500 0.7538 -
1.4 70000 0.7782 -
1.41 70500 0.7416 -
1.42 71000 0.7777 -
1.43 71500 0.7485 -
1.44 72000 0.7726 -
1.45 72500 0.7316 -
1.46 73000 0.7297 -
1.47 73500 0.7597 -
1.48 74000 0.7556 -
1.49 74500 0.7501 -
1.5 75000 0.7687 -
1.51 75500 0.7382 -
1.52 76000 0.7349 -
1.53 76500 0.7469 -
1.54 77000 0.7523 -
1.55 77500 0.7543 -
1.56 78000 0.7593 -
1.5700 78500 0.7208 -
1.58 79000 0.7623 -
1.5900 79500 0.7429 -
1.6 80000 0.7274 -
1.6100 80500 0.766 -
1.62 81000 0.7573 -
1.63 81500 0.7422 -
1.6400 82000 0.7288 -
1.65 82500 0.7088 -
1.6600 83000 0.7682 -
1.67 83500 0.7426 -
1.6800 84000 0.7325 -
1.69 84500 0.7128 -
1.7 85000 0.7092 -
1.71 85500 0.7194 -
1.72 86000 0.735 -
1.73 86500 0.7461 -
1.74 87000 0.7232 -
1.75 87500 0.7491 -
1.76 88000 0.7272 -
1.77 88500 0.7214 -
1.78 89000 0.7082 -
1.79 89500 0.692 -
1.8 90000 0.7201 -
1.81 90500 0.6991 -
1.8200 91000 0.7233 -
1.83 91500 0.7144 -
1.8400 92000 0.7128 -
1.85 92500 0.6971 -
1.8600 93000 0.7096 -
1.87 93500 0.7091 -
1.88 94000 0.7256 -
1.8900 94500 0.7154 -
1.9 95000 0.7237 -
1.9100 95500 0.725 -
1.92 96000 0.6913 -
1.9300 96500 0.6932 -
1.94 97000 0.7294 -
1.95 97500 0.7016 -
1.96 98000 0.7033 -
1.97 98500 0.7057 -
1.98 99000 0.7374 -
1.99 99500 0.7036 -
2.0 100000 0.7072 0.0057
2.01 100500 0.6372 -
2.02 101000 0.6088 -
2.03 101500 0.5999 -
2.04 102000 0.6285 -
2.05 102500 0.6135 -
2.06 103000 0.6229 -
2.07 103500 0.6098 -
2.08 104000 0.6228 -
2.09 104500 0.6536 -
2.1 105000 0.6269 -
2.11 105500 0.6015 -
2.12 106000 0.6176 -
2.13 106500 0.6207 -
2.14 107000 0.6466 -
2.15 107500 0.5975 -
2.16 108000 0.5948 -
2.17 108500 0.6076 -
2.18 109000 0.6264 -
2.19 109500 0.6043 -
2.2 110000 0.6118 -
2.21 110500 0.6211 -
2.22 111000 0.5927 -
2.23 111500 0.6021 -
2.24 112000 0.6353 -
2.25 112500 0.6215 -
2.26 113000 0.6167 -
2.27 113500 0.6013 -
2.2800 114000 0.6208 -
2.29 114500 0.6026 -
2.3 115000 0.5851 -
2.31 115500 0.6124 -
2.32 116000 0.6307 -
2.33 116500 0.6032 -
2.34 117000 0.598 -
2.35 117500 0.6496 -
2.36 118000 0.6151 -
2.37 118500 0.5772 -
2.38 119000 0.5902 -
2.39 119500 0.5716 -
2.4 120000 0.6081 -
2.41 120500 0.566 -
2.42 121000 0.5792 -
2.43 121500 0.6168 -
2.44 122000 0.5764 -
2.45 122500 0.6209 -
2.46 123000 0.605 -
2.4700 123500 0.6045 -
2.48 124000 0.5886 -
2.49 124500 0.6054 -
2.5 125000 0.5711 -
2.51 125500 0.589 -
2.52 126000 0.5732 -
2.5300 126500 0.6116 -
2.54 127000 0.5793 -
2.55 127500 0.5502 -
2.56 128000 0.5678 -
2.57 128500 0.5892 -
2.58 129000 0.58 -
2.59 129500 0.5951 -
2.6 130000 0.5732 -
2.61 130500 0.5799 -
2.62 131000 0.5987 -
2.63 131500 0.5716 -
2.64 132000 0.5691 -
2.65 132500 0.5789 -
2.66 133000 0.6035 -
2.67 133500 0.5751 -
2.68 134000 0.5772 -
2.69 134500 0.575 -
2.7 135000 0.6058 -
2.71 135500 0.5622 -
2.7200 136000 0.5709 -
2.73 136500 0.5533 -
2.74 137000 0.5791 -
2.75 137500 0.5647 -
2.76 138000 0.5541 -
2.77 138500 0.5763 -
2.7800 139000 0.5614 -
2.79 139500 0.5589 -
2.8 140000 0.589 -
2.81 140500 0.5852 -
2.82 141000 0.5819 -
2.83 141500 0.5351 -
2.84 142000 0.5831 -
2.85 142500 0.5697 -
2.86 143000 0.564 -
2.87 143500 0.572 -
2.88 144000 0.5882 -
2.89 144500 0.5732 -
2.9 145000 0.5597 -
2.91 145500 0.5541 -
2.92 146000 0.5771 -
2.93 146500 0.5561 -
2.94 147000 0.5855 -
2.95 147500 0.5779 -
2.96 148000 0.5432 -
2.9700 148500 0.5533 -
2.98 149000 0.5591 -
2.99 149500 0.5605 -
3.0 150000 0.5704 0.0067

Framework Versions

  • Python: 3.11.5
  • Sentence Transformers: 5.0.0
  • Transformers: 4.54.0
  • PyTorch: 2.7.1+cu126
  • Accelerate: 1.9.0
  • Datasets: 4.0.0
  • Tokenizers: 0.21.2

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}
}
Downloads last month
12
Safetensors
Model size
0.6B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for nexusmed-ai/adr_bge_m3_embedding

Base model

BAAI/bge-m3
Finetuned
(544)
this model

Papers for nexusmed-ai/adr_bge_m3_embedding

Evaluation results