SentenceTransformer based on bkai-foundation-models/vietnamese-bi-encoder
This is a sentence-transformers model finetuned from bkai-foundation-models/vietnamese-bi-encoder. 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 Sources
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False}) with Transformer model: RobertaModel
(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})
)
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
model = SentenceTransformer("khanglt0004/ltk_embedding")
sentences = [
'Ai phải nộp lệ phí đăng ký nuôi con nuôi nước ngoài khi nộp hồ sơ xin nhận con nuôi tại Cục Con nuôi?',
'Điều 42. Đối tượng phải nộp lệ phí đăng ký nuôi con nuôi \n\n1. Công dân Việt Nam thường trú tại Việt Nam phải nộp lệ phí đăng ký nuôi con nuôi trong nước theo quy định tại khoản 1 Điều 40 của Nghị định này khi nộp hồ sơ đăng ký nuôi con nuôi tại Ủy ban nhân dân cấp xã. \xa0\xa0\xa0\n\n2. Người Việt Nam định cư ở nước ngoài, người nước ngoài không thường trú tại Việt Nam phải nộp lệ phí đăng ký nuôi con nuôi nước ngoài theo quy định tại khoản 2 Điều 40 của Nghị định này khi nộp hồ sơ xin nhận con nuôi tại Cục Con nuôi.\n\n3. Công dân Việt Nam tạm trú ở nước ngoài phải nộp lệ phí đăng ký nuôi con nuôi theo quy định tại khoản 3 Điều 40 của Nghị định này khi nộp hồ sơ xin nhận con nuôi tại Cơ quan đại diện.',
'Các hoạt động:\n\n\t- Xây dựng bộ công cụ giám sát chất lượng sau đào tạo đối với người cung cấp dịch vụ; các quy định về cơ sở thực hiện dịch vụ kế hoạch hóa gia đình có chất lượng;\n\n\t- Hướng dẫn tổ chức thực hiện việc giám sát chất lượng đối với cơ sở và người cung cấp dịch vụ kế hoạch hóa gia đình;\n\n\t- Kiểm định chất lượng phương tiện tránh thai và hàng hóa sức khỏe sinh sản.\n\nĐơn vị chủ trì: Tổng cục Dân số.\n\nĐơn vị phối hợp: Vụ Sức khỏe Bà mẹ - Trẻ em; Sở Y tế các tỉnh/thành phố và các đơn vị liên quan.\n\n\t4. Đẩy mạnh xã hội hóa, huy động nguồn lực thực hiện Chương trình\n\nĐẩy mạnh xã hội hóa dịch vụ kế hoạch hóa gia đình, tạo điều kiện thuận lợi cho các tổ chức, cá nhân tham gia Chương trình; huy động toàn bộ hệ thống y tế, dân số tham gia thực hiện Chương trình theo chức năng, nhiệm vụ được giao, ưu tiên bảo đảm hoạt động ở tuyến cơ sở, vùng khó khăn có mức sinh cao.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
Evaluation
Metrics
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.4835 |
cosine_accuracy@3 |
0.7157 |
cosine_accuracy@5 |
0.7898 |
cosine_accuracy@10 |
0.8593 |
cosine_precision@1 |
0.4835 |
cosine_precision@3 |
0.2386 |
cosine_precision@5 |
0.158 |
cosine_precision@10 |
0.0859 |
cosine_recall@1 |
0.4835 |
cosine_recall@3 |
0.7157 |
cosine_recall@5 |
0.7898 |
cosine_recall@10 |
0.8593 |
cosine_ndcg@10 |
0.6739 |
cosine_mrr@10 |
0.6141 |
cosine_map@100 |
0.6195 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.4827 |
cosine_accuracy@3 |
0.7105 |
cosine_accuracy@5 |
0.7873 |
cosine_accuracy@10 |
0.8613 |
cosine_precision@1 |
0.4827 |
cosine_precision@3 |
0.2368 |
cosine_precision@5 |
0.1575 |
cosine_precision@10 |
0.0861 |
cosine_recall@1 |
0.4827 |
cosine_recall@3 |
0.7105 |
cosine_recall@5 |
0.7873 |
cosine_recall@10 |
0.8613 |
cosine_ndcg@10 |
0.6724 |
cosine_mrr@10 |
0.6117 |
cosine_map@100 |
0.6168 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.4616 |
cosine_accuracy@3 |
0.6901 |
cosine_accuracy@5 |
0.7776 |
cosine_accuracy@10 |
0.8487 |
cosine_precision@1 |
0.4616 |
cosine_precision@3 |
0.23 |
cosine_precision@5 |
0.1555 |
cosine_precision@10 |
0.0849 |
cosine_recall@1 |
0.4616 |
cosine_recall@3 |
0.6901 |
cosine_recall@5 |
0.7776 |
cosine_recall@10 |
0.8487 |
cosine_ndcg@10 |
0.6553 |
cosine_mrr@10 |
0.5931 |
cosine_map@100 |
0.5986 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.4396 |
cosine_accuracy@3 |
0.6588 |
cosine_accuracy@5 |
0.743 |
cosine_accuracy@10 |
0.8251 |
cosine_precision@1 |
0.4396 |
cosine_precision@3 |
0.2196 |
cosine_precision@5 |
0.1486 |
cosine_precision@10 |
0.0825 |
cosine_recall@1 |
0.4396 |
cosine_recall@3 |
0.6588 |
cosine_recall@5 |
0.743 |
cosine_recall@10 |
0.8251 |
cosine_ndcg@10 |
0.6297 |
cosine_mrr@10 |
0.5674 |
cosine_map@100 |
0.5736 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.3904 |
cosine_accuracy@3 |
0.5958 |
cosine_accuracy@5 |
0.6767 |
cosine_accuracy@10 |
0.7727 |
cosine_precision@1 |
0.3904 |
cosine_precision@3 |
0.1986 |
cosine_precision@5 |
0.1353 |
cosine_precision@10 |
0.0773 |
cosine_recall@1 |
0.3904 |
cosine_recall@3 |
0.5958 |
cosine_recall@5 |
0.6767 |
cosine_recall@10 |
0.7727 |
cosine_ndcg@10 |
0.5745 |
cosine_mrr@10 |
0.512 |
cosine_map@100 |
0.5199 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 2,459 training samples
- Columns:
anchor
and positive
- Approximate statistics based on the first 1000 samples:
|
anchor |
positive |
type |
string |
string |
details |
- min: 13 tokens
- mean: 29.47 tokens
- max: 57 tokens
|
- min: 18 tokens
- mean: 207.63 tokens
- max: 256 tokens
|
- Samples:
anchor |
positive |
Quy định này áp dụng cho những đối tượng nào liên quan đến chính sách dân số và kế hoạch hóa gia đình? |
Đối tượng áp dụng
Quy định này quy định tiêu chuẩn, điều kiện, thẩm quyền xem xét kết nạp lại vào Đảng đối với đảng viên đã bị đưa ra khỏi Đảng do vi phạm chính sách dân số và kế hoạch hoá gia đình, kết nạp quần chúng vi phạm chính sách dân số và kế hoạch hoá gia đình có nguyện vọng phấn đấu vào Đảng.
Điều 2. Những trường hợp sinh con không bị coi là vi phạm chính sách dân số và kế hoạch hoá gia đình
1. Cặp vợ chồng sinh con thứ ba, nếu cả hai hoặc một trong hai người thuộc dân tộc có số dân dưới 10.000 người hoặc thuộc dân tộc có nguy cơ suy giảm số dân (tỉ lệ nhỏ hơn hoặc bằng tỉ lệ chết) theo công bố chính thức của Bộ Kế hoạch và Đầu tư.
2. Cặp vợ chồng sinh lần thứ nhất mà sinh ba con trở lên.
3. Cặp vợ chồng đã có một con đẻ, sinh lần thứ hai mà sinh hai con trở lên.
4. Cặp vợ chồng sinh lần thứ ba trở lên, nếu tại thời điểm sinh chỉ có một con đẻ còn sống, kể cả con đẻ đã cho làm con nuôi.
5. |
Trong trường hợp nào cặp vợ chồng sinh con thứ ba nhưng không bị coi là vi phạm chính sách dân số nếu thuộc dân tộc thiểu số? |
Đối tượng áp dụng
Quy định này quy định tiêu chuẩn, điều kiện, thẩm quyền xem xét kết nạp lại vào Đảng đối với đảng viên đã bị đưa ra khỏi Đảng do vi phạm chính sách dân số và kế hoạch hoá gia đình, kết nạp quần chúng vi phạm chính sách dân số và kế hoạch hoá gia đình có nguyện vọng phấn đấu vào Đảng.
Điều 2. Những trường hợp sinh con không bị coi là vi phạm chính sách dân số và kế hoạch hoá gia đình
1. Cặp vợ chồng sinh con thứ ba, nếu cả hai hoặc một trong hai người thuộc dân tộc có số dân dưới 10.000 người hoặc thuộc dân tộc có nguy cơ suy giảm số dân (tỉ lệ nhỏ hơn hoặc bằng tỉ lệ chết) theo công bố chính thức của Bộ Kế hoạch và Đầu tư.
2. Cặp vợ chồng sinh lần thứ nhất mà sinh ba con trở lên.
3. Cặp vợ chồng đã có một con đẻ, sinh lần thứ hai mà sinh hai con trở lên.
4. Cặp vợ chồng sinh lần thứ ba trở lên, nếu tại thời điểm sinh chỉ có một con đẻ còn sống, kể cả con đẻ đã cho làm con nuôi.
5. |
Cặp vợ chồng sinh lần thứ hai mà sinh hai con trở lên thì có bị xem là vi phạm chính sách dân số không? |
Đối tượng áp dụng
Quy định này quy định tiêu chuẩn, điều kiện, thẩm quyền xem xét kết nạp lại vào Đảng đối với đảng viên đã bị đưa ra khỏi Đảng do vi phạm chính sách dân số và kế hoạch hoá gia đình, kết nạp quần chúng vi phạm chính sách dân số và kế hoạch hoá gia đình có nguyện vọng phấn đấu vào Đảng.
Điều 2. Những trường hợp sinh con không bị coi là vi phạm chính sách dân số và kế hoạch hoá gia đình
1. Cặp vợ chồng sinh con thứ ba, nếu cả hai hoặc một trong hai người thuộc dân tộc có số dân dưới 10.000 người hoặc thuộc dân tộc có nguy cơ suy giảm số dân (tỉ lệ nhỏ hơn hoặc bằng tỉ lệ chết) theo công bố chính thức của Bộ Kế hoạch và Đầu tư.
2. Cặp vợ chồng sinh lần thứ nhất mà sinh ba con trở lên.
3. Cặp vợ chồng đã có một con đẻ, sinh lần thứ hai mà sinh hai con trở lên.
4. Cặp vợ chồng sinh lần thứ ba trở lên, nếu tại thời điểm sinh chỉ có một con đẻ còn sống, kể cả con đẻ đã cho làm con nuôi.
5. |
- 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
num_train_epochs
: 1
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
: 1
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 |
-1 |
-1 |
- |
0.5846 |
0.5778 |
0.5510 |
0.5090 |
0.4283 |
0.1299 |
10 |
5.2058 |
0.6314 |
0.6244 |
0.6004 |
0.5712 |
0.4874 |
0.2597 |
20 |
3.3976 |
0.6559 |
0.6534 |
0.6295 |
0.5986 |
0.5251 |
0.3896 |
30 |
3.4291 |
0.6574 |
0.6577 |
0.6355 |
0.6084 |
0.5438 |
0.5195 |
40 |
3.4904 |
0.6668 |
0.6642 |
0.6464 |
0.6225 |
0.5595 |
0.6494 |
50 |
3.379 |
0.6702 |
0.6672 |
0.6515 |
0.6237 |
0.5667 |
0.7792 |
60 |
2.5151 |
0.6732 |
0.6710 |
0.6536 |
0.6279 |
0.5720 |
0.9091 |
70 |
2.8592 |
0.6739 |
0.6724 |
0.6553 |
0.6297 |
0.5745 |
Framework Versions
- Python: 3.11.12
- Sentence Transformers: 4.1.0
- Transformers: 4.51.3
- PyTorch: 2.6.0+cu124
- Accelerate: 1.6.0
- Datasets: 3.6.0
- Tokenizers: 0.21.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",
}
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}
}