SentenceTransformer based on BAAI/bge-m3

This is a sentence-transformers model finetuned from BAAI/bge-m3 on the vietnamese-medical-qa dataset. 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
  • Training Dataset:
  • Language: vi

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: PeftModelForFeatureExtraction 
  (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("doanbao/bge-m3-medical-vn-lora")
# Run inference
sentences = [
    'Chào bác sĩ,\nEm bị viêm tai thanh dịch. Vậy bác sĩ cho em hỏi viêm tai thanh dịch có thể điều trị được không? Bệnh này có tự hết không hay bắt buộc phải uống thuốc mỗi lần bị viêm? Em cảm ơn bác sĩ.',
    'Chào bạn,\nĐể trả lời câu hỏi trên, bác sĩ xin giải đáp như sau:\nViêm tai thanh dịch là bệnh lý liên quan đến chức năng thông thoáng của vòi tai (là ống nối thông từ mũi tới tai). Đây là bệnh lý lành tính tuy nhiên việc điều trị cần phải theo dõi sát trong thời gian 1 - 3 tháng vì dịch ở trong tai tiêu chậm, đặc biệt ở người hút thuốc lá hoặc có tiền sử bệnh mũi.\nVì vậy, bạn nên đến thăm khám để nhân được kế hoạch điều trị và theo dõi cho dứt điểm tình trạng ứ dịch trong tai.\nTrân trọng!',
    'Chào bạn,\nĐể trả lời câu hỏi trên, bác sĩ xin giải đáp như sau:\nKhó thở không phải là bệnh mà nó là triệu chứng bệnh phổ biến liên quan đến vấn đề sức khỏe nghiêm trọng. Biểu hiện này tồn tại dưới dạng cấp tính hoặc mãn tính. Khó thở có thể là triệu chứng của nhiều bệnh lý hô hấp, tim mạch hoặc ở 1 số cơ quan khác và cũng không loại trừ nguyên nhân rối loạn lo âu tổng quát.\nBạn cần đi khám bác sĩ để được tầm soát những nguyên nhân bệnh gây nên tình trạng khó thở để được điều trị hiệu quả.\nTrân trọng!',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]

Training Details

Training Dataset

vietnamese-medical-qa

  • Dataset: vietnamese-medical-qa at 6201315
  • Size: 18,670 training samples
  • Columns: anchor and positive
  • Approximate statistics based on the first 1000 samples:
    anchor positive
    type string string
    details
    • min: 6 tokens
    • mean: 73.18 tokens
    • max: 230 tokens
    • min: 24 tokens
    • mean: 197.0 tokens
    • max: 2051 tokens
  • Samples:
    anchor positive
    Chào bác sĩ,
    Răng cháu hiện tại có mủ ở dưới lợi nhưng khi đau cháu sẽ không ngủ được (quá đau). Tuy nhiên chỉ vài ngày là hết mà thỉnh thoảng nó lại bị đau. Chị cháu bảo là trước chị cháu cũng bị như vậy chỉ là đau răng tuổi dậy thì thôi. Bác sĩ cho cháu hỏi đau răng kèm có mủ dưới lợi là bệnh gì? Cháu có cần đi chữa trị không? Cháu cảm ơn.
    Chào bạn,
    Để trả lời câu hỏi trên, bác sĩ xin giải đáp như sau:
    Răng bạn hiện tại có mủ dưới lợi gây đau nhức nhiều. Bạn có thể đến phòng khám răng hàm mặt bệnh viện để được thăm khám, chụp phim và tư vấn cho bạn được chính xác
    Trân trọng!
    Chào bác sĩ,
    Em thấy mặt dưới, phía cuống lưỡi của mình có 2 nốt mụn nhỏ, đỏ xung quanh, ở giữa có nhân trắng, đau nhẹ khi dùng đầu lưỡi chạm vào. Đồng thời, phía cuống lưỡi mặt trên cũng có các nốt lớn nổi lên, không gây đau. Bác sĩ cho em hỏi cuống lưỡi nổi mụn nhỏ là dấu hiệu bệnh gì? Có phải em đang mắc bệnh gì không hay chỉ bị nhiệt miệng bình thường? Em cảm ơn bác sĩ.
    Chào bạn,
    Để trả lời câu hỏi trên, bác sĩ xin giải đáp như sau:
    Triệu chứng nốt mụn đỏ vùng dưới lưỡi, đau khi chạm vào gợi ý tình trạng mụn viêm vùng lưỡi, nếu nốt mụn không to thêm và tự hết trong 7-10 ngày thì bạn không cần quá lo lắng.
    Trong trường hợp nốt mụn to dần hoặc nốt mụn tồn tại trên 02 tuần không hết thì bạn cần đến bác sĩ để khám kiểm tra. Đối với các nốt lớn mặt trên lưỡi thì bạn có thể đến phòng khám Tai mũi họng để bác sĩ khám kiểm tra và tư vấn cụ thể hơn.
    Trân trọng!
    Chào bác sĩ,
    Từ tháng 4/2020, em mới xuất hiện lần đầu triệu chứng viêm amidan có mủ và sốt. Tuy nhiên, kể từ thời gian đó trở đi, bệnh tái phát nhiều lần (khoảng 1,2 tháng bị 01 lần), nhất là sau khi bị cảm tình trạng viêm nặng hơn lúc bình thường (sốt và có mủ, không tự khỏi được). Tình trạng trên ảnh hưởng rất nhiều đến sức khỏe và sinh hoạt của bản thân. Bác sĩ cho em hỏi viêm amidan có mủ kèm sốt tái phát nhiều lần phải làm sao? Em có nguy cơ bị ung thư vòm họng không? Em cảm ơn.
    Chào bạn,
    Để trả lời câu hỏi trên, bác sĩ xin giải đáp như sau:
    Các triệu chứng sốt, đau họng, amidan có mủ tái đi tái lại nhiều lần gợi ý tình trạng viêm amidan mạn. Tình trạng viêm amidan của chị tái đi tái lại thường xuyên, ảnh hưởng nhiều đến sức khỏe và sinh hoạt bản thân do đó có chỉ định cắt amidan để điều trị hiệu quả tình trạng trên.
    Viêm amidan mạn không phải là nguy cơ ung thư vòm họng, tuy vậy bạn nên đến phòng khám Tai mũi họng để khám, nội soi kiểm tra nhằm xác định có đúng là chị đang có tình trạng viêm amidan mạn hay không, đồng thời tầm soát thêm một số nguyên nhân gây sốt, đau họng khác.
    Trân trọng!
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 16
  • learning_rate: 0.0002
  • num_train_epochs: 1
  • fp16: True

All Hyperparameters

Click to expand
  • 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: 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: 0.0002
  • 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.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
  • 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: 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}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • 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: no
  • 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: True
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional

Training Logs

Click to expand
Epoch Step Training Loss
0.0086 10 0.4403
0.0171 20 0.2183
0.0257 30 0.1949
0.0343 40 0.2547
0.0428 50 0.1662
0.0514 60 0.1458
0.0600 70 0.2065
0.0686 80 0.0917
0.0771 90 0.1387
0.0857 100 0.1519
0.0943 110 0.1133
0.1028 120 0.2258
0.1114 130 0.2272
0.1200 140 0.2088
0.1285 150 0.1589
0.1371 160 0.2538
0.1457 170 0.1861
0.1542 180 0.1988
0.1628 190 0.1534
0.1714 200 0.1331
0.1799 210 0.1462
0.1885 220 0.0925
0.1971 230 0.1696
0.2057 240 0.1396
0.2142 250 0.1326
0.2228 260 0.1317
0.2314 270 0.1152
0.2399 280 0.1514
0.2485 290 0.0906
0.2571 300 0.1191
0.2656 310 0.0698
0.2742 320 0.2159
0.2828 330 0.1619
0.2913 340 0.0991
0.2999 350 0.2041
0.3085 360 0.1579
0.3171 370 0.1065
0.3256 380 0.0851
0.3342 390 0.1704
0.3428 400 0.1371
0.3513 410 0.1414
0.3599 420 0.1365
0.3685 430 0.2702
0.3770 440 0.0965
0.3856 450 0.0991
0.3942 460 0.1276
0.4027 470 0.1285
0.4113 480 0.1738
0.4199 490 0.0737
0.4284 500 0.0931
0.4370 510 0.1889
0.4456 520 0.1346
0.4542 530 0.1301
0.4627 540 0.0781
0.4713 550 0.1173
0.4799 560 0.1187
0.4884 570 0.1328
0.4970 580 0.1245
0.5056 590 0.0779
0.5141 600 0.1138
0.5227 610 0.1731
0.5313 620 0.1222
0.5398 630 0.0772
0.5484 640 0.1536
0.5570 650 0.1665
0.5656 660 0.0668
0.5741 670 0.0981
0.5827 680 0.0799
0.5913 690 0.1256
0.5998 700 0.0771
0.6084 710 0.0892
0.6170 720 0.1019
0.6255 730 0.1224
0.6341 740 0.1439
0.6427 750 0.0582
0.6512 760 0.0793
0.6598 770 0.0797
0.6684 780 0.1365
0.6769 790 0.1033
0.6855 800 0.1702
0.6941 810 0.1174
0.7027 820 0.0848
0.7112 830 0.0893
0.7198 840 0.0614
0.7284 850 0.119
0.7369 860 0.134
0.7455 870 0.0723
0.7541 880 0.0867
0.7626 890 0.108
0.7712 900 0.0721
0.7798 910 0.0645
0.7883 920 0.0846
0.7969 930 0.082
0.8055 940 0.1308
0.8141 950 0.069
0.8226 960 0.1099
0.8312 970 0.0963
0.8398 980 0.0582
0.8483 990 0.1116
0.8569 1000 0.0772
0.8655 1010 0.1055
0.8740 1020 0.1024
0.8826 1030 0.0702
0.8912 1040 0.0566
0.8997 1050 0.1006
0.9083 1060 0.1019
0.9169 1070 0.0843
0.9254 1080 0.0689
0.9340 1090 0.1176
0.9426 1100 0.1219
0.9512 1110 0.0773
0.9597 1120 0.1095
0.9683 1130 0.1082
0.9769 1140 0.0953
0.9854 1150 0.1239
0.9940 1160 0.1302

Framework Versions

  • Python: 3.11.13
  • Sentence Transformers: 4.1.0
  • Transformers: 4.57.3
  • PyTorch: 2.6.0+cu124
  • Accelerate: 1.9.0
  • Datasets: 4.4.1
  • Tokenizers: 0.22.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}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for doanbao/bge-m3-medical-vn-lora

Base model

BAAI/bge-m3
Finetuned
(350)
this model

Dataset used to train doanbao/bge-m3-medical-vn-lora