SentenceTransformer based on hiieu/halong_embedding

This is a sentence-transformers model finetuned from hiieu/halong_embedding. 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: hiieu/halong_embedding
  • Maximum Sequence Length: 512 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: XLMRobertaModel 
  (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:

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("TuanNM171284/TuanNM171284-HaLong-embedding-medical")
# Run inference
sentences = [
    'Làm sao để chăm sóc bệnh nhân mắc hẹp bao quy đầu?',
    'Chăm sóc bao gồm vệ sinh sạch sẽ bao quy đầu hàng ngày bằng nước sạch và xà phòng nhẹ, tuột bao quy đầu nhẹ nhàng để rửa. Sau phẫu thuật, cần theo dõi các dấu hiệu sưng đỏ, chảy máu và vệ sinh mỗi ngày để tránh nhiễm trùng và mất cảm giác.',
    'Bệnh gan nhiễm mỡ không do rượu có đặc điểm là sự hiện diện của rất nhiều mỡ tích tụ trong gan. Sau đó có thể diễn tiến nặng dần lên thành viêm gan nhiễm mỡ không do rượu (NASH). Tình trạng này có thể gây tổn thương tế bào gan nghiêm trọng và dẫn đến xơ gan, suy chức năng gan. Xơ gan có thể dẫn tới: Báng bụng, Dãn tĩnh mạch thực quản, có thể gây vỡ làm nôn ra máu, Bệnh não gan: Các biểu hiện như lú lẫn, ngủ gà hay rối loạn chức năng thần kinh cao cấp, Ung thư gan, Suy gan giai đoạn cuối.',
]
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]

Evaluation

Metrics

Information Retrieval

Metric dim_768 dim_512 dim_256 dim_128 dim_64
cosine_accuracy@1 0.6334 0.6328 0.6374 0.6313 0.6044
cosine_accuracy@3 0.7862 0.7837 0.7923 0.79 0.7661
cosine_accuracy@5 0.8418 0.8395 0.8416 0.8405 0.8238
cosine_accuracy@10 0.8974 0.8993 0.9028 0.9057 0.8901
cosine_precision@1 0.6334 0.6328 0.6374 0.6313 0.6044
cosine_precision@3 0.2621 0.2612 0.2641 0.2633 0.2554
cosine_precision@5 0.1684 0.1679 0.1683 0.1681 0.1648
cosine_precision@10 0.0897 0.0899 0.0903 0.0906 0.089
cosine_recall@1 0.6334 0.6328 0.6374 0.6313 0.6044
cosine_recall@3 0.7862 0.7837 0.7923 0.79 0.7661
cosine_recall@5 0.8418 0.8395 0.8416 0.8405 0.8238
cosine_recall@10 0.8974 0.8993 0.9028 0.9057 0.8901
cosine_ndcg@10 0.764 0.7642 0.769 0.7662 0.7455
cosine_mrr@10 0.7215 0.7212 0.7263 0.7218 0.6995
cosine_map@100 0.7262 0.7259 0.7311 0.7263 0.7044

Training Details

Training Dataset

Unnamed Dataset

  • Size: 5,215 training samples
  • Columns: anchor and positive
  • Approximate statistics based on the first 1000 samples:
    anchor positive
    type string string
    details
    • min: 7 tokens
    • mean: 13.86 tokens
    • max: 29 tokens
    • min: 16 tokens
    • mean: 79.69 tokens
    • max: 356 tokens
  • Samples:
    anchor positive
    Bệnh Addison là gì? Bệnh Addison là một bệnh hiếm gặp, xảy ra khi tuyến thượng thận không sản xuất đủ các hormone cortisol và aldosterone. Bệnh còn được gọi là suy thượng thận nguyên phát.
    Triệu chứng của bệnh Addison là gì? Các triệu chứng của bệnh Addison bao gồm mệt mỏi mãn tính, yếu cơ, mất cảm giác ngon miệng, giảm cân, huyết áp thấp, da sẫm màu, bất thường lượng đường trong máu, buồn nôn, nôn, tiêu chảy, không có khả năng đối phó với căng thẳng, tâm trạng buồn bực, khó chịu, trầm cảm, không thích nghi được với cảm giác nóng hoặc lạnh, và thèm đồ ăn mặn.
    Cách điều trị bệnh Addison ra sao? Bệnh Addison được điều trị bằng cách thay thế các hormone bị thiếu. Cortisol có thể được thay thế bằng viên hydrocortisone, aldosterone có thể được thay thế bằng fludrocortisone acetate. Liều lượng cần được điều chỉnh trong thời gian căng thẳng, nhiễm trùng, phẫu thuật hoặc chấn thương và phải tuân thủ liều nghiêm ngặt dưới sự chỉ định và giám sát của bác sĩ.
  • Loss: MatryoshkaLoss with these parameters:
    {
        "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: steps
  • per_device_eval_batch_size: 4
  • gradient_accumulation_steps: 4
  • learning_rate: 2e-05
  • lr_scheduler_type: cosine
  • warmup_ratio: 0.1
  • bf16: True
  • load_best_model_at_end: True
  • optim: adamw_torch_fused
  • batch_sampler: no_duplicates

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: 4
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 4
  • 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: 3
  • 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: True
  • 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: True
  • 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}
  • tp_size: 0
  • 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_fused
  • 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
  • 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

Training Logs

Epoch Step Training Loss dim_768_cosine_ndcg@10 dim_512_cosine_ndcg@10 dim_256_cosine_ndcg@10 dim_128_cosine_ndcg@10 dim_64_cosine_ndcg@10
0.1227 10 2.7834 0.6736 0.6704 0.6625 0.6478 0.6050
0.2454 20 4.2471 0.6918 0.6880 0.6818 0.6709 0.6358
0.3681 30 3.2069 0.7016 0.6997 0.7012 0.6935 0.6665
0.4908 40 2.9097 0.7177 0.7163 0.7169 0.7086 0.6783
0.6135 50 3.0704 0.7268 0.7263 0.7272 0.7178 0.6901
0.7362 60 2.5582 0.7231 0.7248 0.7274 0.7219 0.7001
0.8589 70 2.074 0.7214 0.7217 0.7277 0.7259 0.7072
0.9816 80 2.8852 0.7359 0.7362 0.7390 0.7351 0.7132
1.0982 90 1.3827 0.7458 0.7448 0.7464 0.7423 0.7175
1.2209 100 1.5382 0.7472 0.7474 0.7484 0.7410 0.7145
1.3436 110 1.6667 0.7433 0.7437 0.7455 0.7423 0.7174
1.4663 120 1.6423 0.7497 0.7502 0.7530 0.7495 0.7250
1.5890 130 1.2332 0.7539 0.7543 0.7582 0.7552 0.7296
1.7117 140 1.4156 0.7573 0.7583 0.7619 0.7588 0.7352
1.8344 150 1.2422 0.7592 0.7591 0.7634 0.7599 0.7371
1.9571 160 0.917 0.7579 0.7585 0.7643 0.7610 0.7392
2.0736 170 1.3069 0.7605 0.7610 0.7665 0.7644 0.7430
2.1963 180 0.949 0.7599 0.7612 0.7662 0.7639 0.7433
2.3190 190 0.9943 0.7609 0.7620 0.7662 0.7643 0.7430
2.4417 200 1.1196 0.7623 0.7629 0.7672 0.7652 0.7439
2.5644 210 0.8954 0.7637 0.7634 0.7687 0.7663 0.7447
2.6871 220 0.8713 0.7640 0.7636 0.7689 0.7659 0.7451
2.8098 230 1.1643 0.7639 0.7640 0.7690 0.7661 0.7453
2.9325 240 1.0182 0.7640 0.7642 0.7690 0.7662 0.7455

Framework Versions

  • Python: 3.11.11
  • Sentence Transformers: 3.4.1
  • Transformers: 4.51.1
  • PyTorch: 2.5.1+cu124
  • Accelerate: 1.3.0
  • Datasets: 3.5.0
  • Tokenizers: 0.21.0

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",
}

MatryoshkaLoss

@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

@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
-
Safetensors
Model size
278M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for TuanNM171284/TuanNM171284-HaLong-embedding-medical

Finetuned
(28)
this model

Evaluation results