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
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
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-v2")
# 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:
anchorandpositive - 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:
MultipleNegativesRankingLosswith these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 16gradient_accumulation_steps: 4learning_rate: 0.0002num_train_epochs: 1fp16: True
All Hyperparameters
Click to expand
overwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 4eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 0.0002weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 1max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.0warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falsebf16: Falsefp16: Truefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters:auto_find_batch_size: Falsefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueprompts: Nonebatch_sampler: batch_samplermulti_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 |
| 0.0343 | 10 | 0.0692 |
| 0.0686 | 20 | 0.0435 |
| 0.1028 | 30 | 0.0433 |
| 0.1371 | 40 | 0.0731 |
| 0.1714 | 50 | 0.0442 |
| 0.2057 | 60 | 0.0346 |
| 0.2399 | 70 | 0.0322 |
| 0.2742 | 80 | 0.029 |
| 0.3085 | 90 | 0.0371 |
| 0.3428 | 100 | 0.0298 |
| 0.3770 | 110 | 0.056 |
| 0.4113 | 120 | 0.0378 |
| 0.4456 | 130 | 0.0493 |
| 0.4799 | 140 | 0.031 |
| 0.5141 | 150 | 0.0295 |
| 0.5484 | 160 | 0.0554 |
| 0.5827 | 170 | 0.0329 |
| 0.6170 | 180 | 0.0356 |
| 0.6512 | 190 | 0.0408 |
| 0.6855 | 200 | 0.0547 |
| 0.7198 | 210 | 0.0422 |
| 0.7541 | 220 | 0.0508 |
| 0.7883 | 230 | 0.0453 |
| 0.8226 | 240 | 0.0563 |
| 0.8569 | 250 | 0.0546 |
| 0.8912 | 260 | 0.054 |
| 0.9254 | 270 | 0.0656 |
| 0.9597 | 280 | 0.0735 |
| 0.9940 | 290 | 0.106 |
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}
}
Model tree for doanbao/bge-m3-medical-vn-lora-v2
Base model
BAAI/bge-m3