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
- 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': 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
- Datasets:
dim_768
,dim_512
,dim_256
,dim_128
anddim_64
- Evaluated with
InformationRetrievalEvaluator
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
andpositive
- 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
: stepsper_device_eval_batch_size
: 4gradient_accumulation_steps
: 4learning_rate
: 2e-05lr_scheduler_type
: cosinewarmup_ratio
: 0.1bf16
: Trueload_best_model_at_end
: Trueoptim
: adamw_torch_fusedbatch_sampler
: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: stepsprediction_loss_only
: Trueper_device_train_batch_size
: 8per_device_eval_batch_size
: 4per_gpu_train_batch_size
: Noneper_gpu_eval_batch_size
: Nonegradient_accumulation_steps
: 4eval_accumulation_steps
: Nonetorch_empty_cache_steps
: Nonelearning_rate
: 2e-05weight_decay
: 0.0adam_beta1
: 0.9adam_beta2
: 0.999adam_epsilon
: 1e-08max_grad_norm
: 1.0num_train_epochs
: 3max_steps
: -1lr_scheduler_type
: cosinelr_scheduler_kwargs
: {}warmup_ratio
: 0.1warmup_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
: Falseuse_ipex
: Falsebf16
: Truefp16
: Falsefp16_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
: Trueignore_data_skip
: Falsefsdp
: []fsdp_min_num_params
: 0fsdp_config
: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}tp_size
: 0fsdp_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}deepspeed
: Nonelabel_smoothing_factor
: 0.0optim
: adamw_torch_fusedoptim_args
: Noneadafactor
: Falsegroup_by_length
: Falselength_column_name
: lengthddp_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
: Falsegradient_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
: Falseneftune_noise_alpha
: Noneoptim_target_modules
: Nonebatch_eval_metrics
: Falseeval_on_start
: Falseuse_liger_kernel
: Falseeval_use_gather_object
: Falseaverage_tokens_across_devices
: Falseprompts
: Nonebatch_sampler
: no_duplicatesmulti_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
- -
Model tree for TuanNM171284/TuanNM171284-HaLong-embedding-medical
Evaluation results
- Cosine Accuracy@1 on dim 768self-reported0.633
- Cosine Accuracy@3 on dim 768self-reported0.786
- Cosine Accuracy@5 on dim 768self-reported0.842
- Cosine Accuracy@10 on dim 768self-reported0.897
- Cosine Precision@1 on dim 768self-reported0.633
- Cosine Precision@3 on dim 768self-reported0.262
- Cosine Precision@5 on dim 768self-reported0.168
- Cosine Precision@10 on dim 768self-reported0.090
- Cosine Recall@1 on dim 768self-reported0.633
- Cosine Recall@3 on dim 768self-reported0.786