Vietnamese_Embedding_finetuned
This is a sentence-transformers model finetuned from AITeamVN/Vietnamese_Embedding on the json 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: AITeamVN/Vietnamese_Embedding
- Maximum Sequence Length: 8192 tokens
- Output Dimensionality: 1024 dimensions
- Similarity Function: Cosine Similarity
- Training Dataset:
- Language: vi
- License: apache-2.0
Model Sources
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: XLMRobertaModel
(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
model = SentenceTransformer("namnguyenba2003/Vietnamese_Law_Embedding_finetuned_v2")
sentences = [
'Điều 36. Kiểm tra, giám sát an ninh đối với người, phương tiện, đồ vật khi vào, ra và hoạt động tại khu vực hạn chế mà không phải hành khách, hành lý, hàng hóa, bưu gửi và đồ vật đưa lên tàu bay\n1. Nhân viên kiểm soát an ninh hàng không, nhân viên bảo vệ chịu trách nhiệm kiểm tra, giám sát an ninh đối với người, phương tiện, đồ vật đưa vào, ra và hoạt động tại khu vực hạn chế.\n2. Người, phương tiện, đồ vật đưa vào khu vực hạn chế ngoại trừ đối tượng quy định tại khoản 9 Điều này phải được kiểm tra an ninh hàng không các nội dung sau:\na) Thẻ, giấy phép kiểm soát an ninh hàng không;\nb) Người, đồ vật mang theo người và giấy tờ cần thiết (nếu có);\nc) Phương tiện và đồ vật trên phương tiện.\n3. Người, phương tiện, đồ vật đưa ra ngoài khu vực hạn chế được lực lượng kiểm soát an ninh hàng không kiểm tra khi có biểu hiện nghi ngờ như: trộm cắp tài sản, buôn lậu và gian lận thương mại hoặc trong các trường hợp tăng cường bảo đảm an ninh hàng không hoặc theo chỉ đạo của cơ quan quản lý nhà nước có thẩm quyền.',
'Trong những trường hợp nào nhân viên kiểm soát an ninh hàng không được phép kiểm tra người, phương tiện, đồ vật khi họ ra khỏi khu vực hạn chế của sân bay?',
'Bộ Tài chính quy định những hình thức hỗ trợ cụ thể nào cho việc quản lý các công trình vệ sinh công cộng và thu gom rác thải tại khu dân cư?',
]
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.7383 |
cosine_accuracy@3 |
0.7918 |
cosine_accuracy@5 |
0.8703 |
cosine_accuracy@10 |
0.9317 |
cosine_precision@1 |
0.7383 |
cosine_precision@3 |
0.6951 |
cosine_precision@5 |
0.4871 |
cosine_precision@10 |
0.2682 |
cosine_recall@1 |
0.2741 |
cosine_recall@3 |
0.7351 |
cosine_recall@5 |
0.843 |
cosine_recall@10 |
0.9231 |
cosine_ndcg@10 |
0.8368 |
cosine_mrr@10 |
0.785 |
cosine_map@100 |
0.8136 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.7359 |
cosine_accuracy@3 |
0.7887 |
cosine_accuracy@5 |
0.8656 |
cosine_accuracy@10 |
0.9324 |
cosine_precision@1 |
0.7359 |
cosine_precision@3 |
0.6924 |
cosine_precision@5 |
0.4842 |
cosine_precision@10 |
0.2683 |
cosine_recall@1 |
0.2733 |
cosine_recall@3 |
0.7325 |
cosine_recall@5 |
0.8382 |
cosine_recall@10 |
0.9234 |
cosine_ndcg@10 |
0.8352 |
cosine_mrr@10 |
0.7826 |
cosine_map@100 |
0.8113 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.7344 |
cosine_accuracy@3 |
0.7907 |
cosine_accuracy@5 |
0.8683 |
cosine_accuracy@10 |
0.9297 |
cosine_precision@1 |
0.7344 |
cosine_precision@3 |
0.6923 |
cosine_precision@5 |
0.4863 |
cosine_precision@10 |
0.2673 |
cosine_recall@1 |
0.273 |
cosine_recall@3 |
0.7319 |
cosine_recall@5 |
0.8421 |
cosine_recall@10 |
0.9204 |
cosine_ndcg@10 |
0.8337 |
cosine_mrr@10 |
0.7817 |
cosine_map@100 |
0.8106 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.7208 |
cosine_accuracy@3 |
0.7713 |
cosine_accuracy@5 |
0.8571 |
cosine_accuracy@10 |
0.9289 |
cosine_precision@1 |
0.7208 |
cosine_precision@3 |
0.6778 |
cosine_precision@5 |
0.4766 |
cosine_precision@10 |
0.2671 |
cosine_recall@1 |
0.2685 |
cosine_recall@3 |
0.7176 |
cosine_recall@5 |
0.8273 |
cosine_recall@10 |
0.9189 |
cosine_ndcg@10 |
0.8254 |
cosine_mrr@10 |
0.7695 |
cosine_map@100 |
0.7998 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.7107 |
cosine_accuracy@3 |
0.7619 |
cosine_accuracy@5 |
0.8443 |
cosine_accuracy@10 |
0.9115 |
cosine_precision@1 |
0.7107 |
cosine_precision@3 |
0.6687 |
cosine_precision@5 |
0.47 |
cosine_precision@10 |
0.2619 |
cosine_recall@1 |
0.2645 |
cosine_recall@3 |
0.708 |
cosine_recall@5 |
0.8153 |
cosine_recall@10 |
0.9015 |
cosine_ndcg@10 |
0.8121 |
cosine_mrr@10 |
0.7585 |
cosine_map@100 |
0.7896 |
Training Details
Training Dataset
json
- Dataset: json
- Size: 23,168 training samples
- Columns:
positive
and anchor
- Approximate statistics based on the first 1000 samples:
|
positive |
anchor |
type |
string |
string |
details |
- min: 109 tokens
- mean: 209.39 tokens
- max: 313 tokens
|
- min: 15 tokens
- mean: 37.15 tokens
- max: 93 tokens
|
- Samples:
positive |
anchor |
Khoản 1. Hộ gia đình, cá nhân có trách nhiệm sau đây: a) Giảm thiểu, phân loại chất thải rắn sinh hoạt tại nguồn, thu gom và chuyển rác thải sinh hoạt đã được phân loại đến đúng nơi quy định; b) Giảm thiểu, xử lý và xả nước thải sinh hoạt đúng nơi quy định; không để vật nuôi gây mất vệ sinh trong khu dân cư; c) Không phát tán khí thải, gây tiếng ồn, độ rung và tác động khác gây ô nhiễm môi trường, ảnh hưởng xấu đến cộng đồng dân cư xung quanh; d) Chi trả kinh phí dịch vụ thu gom, vận chuyển và xử lý chất thải theo quy định của pháp luật; đ) Tham gia hoạt động bảo vệ môi trường tại cộng đồng dân cư; e) Có công trình vệ sinh theo quy định. Trường hợp chưa có công trình, thiết bị xử lý nước thải, khi xây dựng mới hoặc cải tạo, sửa chữa nhà ở riêng lẻ tại đô thị, khu dân cư tập trung, phải xây lắp công trình, thiết bị xử lý nước thải tại chỗ đáp ứng yêu cầu về bảo vệ môi trường theo quy định. |
Luật Bảo vệ môi trường quy định những trách nhiệm gì đối với hộ gia đình, cá nhân trong việc quản lý chất thải rắn, xử lý nước thải và ngăn ngừa ô nhiễm môi trường? |
Điều 34. Đối tượng chịu sự kiểm tra, kiểm soát tần số vô tuyến điện 1. Tổ chức, cá nhân sử dụng tần số và thiết bị vô tuyến điện trên lãnh thổ nước Cộng hòa xã hội chủ nghĩa Việt Nam phải chịu sự kiểm tra, kiểm soát tần số vô tuyến điện của cơ quan nhà nước có thẩm quyền. 2. Người trực tiếp khai thác thiết bị vô tuyến điện, thiết bị vô tuyến điện lắp đặt trên tàu biển, tàu bay của Việt Nam và của nước ngoài khi vào lãnh thổ nước Cộng hòa xã hội chủ nghĩa Việt Nam phải tuân theo quy định của pháp luật Việt Nam, thỏa thuận quốc tế, điều ước quốc tế mà Cộng hòa xã hội chủ nghĩa Việt Nam là thành viên và phải chịu sự kiểm tra, kiểm soát tần số vô tuyến điện của cơ quan nhà nước có thẩm quyền. |
Cơ quan nhà nước nào có thẩm quyền thực hiện kiểm tra, kiểm soát tần số vô tuyến điện tại Việt Nam? |
Điều 34. Điều kiện bảo đảm chất lượng hàng hóa nhập khẩu 1. Hàng hóa nhập khẩu phải được công bố tiêu chuẩn áp dụng theo quy định tại Điều 23 của Luật này và ghi nhãn theo quy định của pháp luật về nhãn hàng hóa. 2. Hàng hóa nhập khẩu thuộc nhóm 2 phải được công bố hợp quy, chứng nhận hợp quy theo quy chuẩn kỹ thuật tương ứng liên quan đến quá trình sản xuất, sản phẩm cuối cùng bởi tổ chức chứng nhận được chỉ định hoặc được thừa nhận theo quy định tại Điều 26 của Luật này. 3. Hàng hóa nhập khẩu thuộc nhóm 2 không đáp ứng quy định tại khoản 2 Điều này khi nhập khẩu phải được tổ chức giám định được chỉ định hoặc được thừa nhận theo quy định tại Điều 26 của Luật này giám định tại cửa khẩu xuất hoặc cửa khẩu nhập. 4. Hàng hóa nhập khẩu thuộc nhóm 2 phải được kiểm tra chất lượng khi nhập khẩu theo nội dung quy định tại khoản 2 Điều 27, trình tự, thủ tục quy định tại Điều 35 của Luật này. |
Luật chất lượng sản phẩm, hàng hóa có quy định gì về việc kiểm tra chất lượng đối với hàng hóa nhập khẩu thuộc nhóm 2 khi nhập khẩu vào Việt Nam? |
- Loss:
MatryoshkaLoss
with these parameters:{
"loss": "MultipleNegativesRankingLoss",
"matryoshka_dims": [
1024,
768,
512,
256,
128
],
"matryoshka_weights": [
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy
: epoch
per_device_train_batch_size
: 64
per_device_eval_batch_size
: 64
gradient_accumulation_steps
: 8
learning_rate
: 2e-05
num_train_epochs
: 5
lr_scheduler_type
: cosine
warmup_ratio
: 0.1
fp16
: True
tf32
: True
dataloader_num_workers
: 8
load_best_model_at_end
: True
optim
: adamw_torch_fused
ddp_find_unused_parameters
: False
batch_sampler
: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir
: False
do_predict
: False
eval_strategy
: epoch
prediction_loss_only
: True
per_device_train_batch_size
: 64
per_device_eval_batch_size
: 64
per_gpu_train_batch_size
: None
per_gpu_eval_batch_size
: None
gradient_accumulation_steps
: 8
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
: 5
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
: False
fp16
: True
fp16_opt_level
: O1
half_precision_backend
: auto
bf16_full_eval
: False
fp16_full_eval
: False
tf32
: True
local_rank
: 0
ddp_backend
: None
tpu_num_cores
: None
tpu_metrics_debug
: False
debug
: []
dataloader_drop_last
: False
dataloader_num_workers
: 8
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}
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
: False
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_1024_cosine_ndcg@10 |
dim_768_cosine_ndcg@10 |
dim_512_cosine_ndcg@10 |
dim_256_cosine_ndcg@10 |
dim_128_cosine_ndcg@10 |
0.2210 |
10 |
6.2144 |
- |
- |
- |
- |
- |
0.4420 |
20 |
3.2176 |
- |
- |
- |
- |
- |
0.6630 |
30 |
2.2397 |
- |
- |
- |
- |
- |
0.8840 |
40 |
2.0719 |
- |
- |
- |
- |
- |
1.0 |
46 |
- |
0.8246 |
0.8218 |
0.8229 |
0.8114 |
0.7964 |
1.0884 |
50 |
1.558 |
- |
- |
- |
- |
- |
1.3094 |
60 |
1.2167 |
- |
- |
- |
- |
- |
1.5304 |
70 |
1.2956 |
- |
- |
- |
- |
- |
1.7514 |
80 |
1.2846 |
- |
- |
- |
- |
- |
1.9724 |
90 |
1.4133 |
- |
- |
- |
- |
- |
2.0 |
92 |
- |
0.8354 |
0.8349 |
0.8325 |
0.8187 |
0.8040 |
2.1768 |
100 |
0.9511 |
- |
- |
- |
- |
- |
2.3978 |
110 |
1.0338 |
- |
- |
- |
- |
- |
2.6188 |
120 |
1.0112 |
- |
- |
- |
- |
- |
2.8398 |
130 |
0.8881 |
- |
- |
- |
- |
- |
3.0 |
138 |
- |
0.8325 |
0.8309 |
0.8302 |
0.8235 |
0.8108 |
3.0442 |
140 |
0.858 |
- |
- |
- |
- |
- |
3.2652 |
150 |
0.7956 |
- |
- |
- |
- |
- |
3.4862 |
160 |
0.8804 |
- |
- |
- |
- |
- |
3.7072 |
170 |
0.9071 |
- |
- |
- |
- |
- |
3.9282 |
180 |
0.9237 |
- |
- |
- |
- |
- |
4.0 |
184 |
- |
0.8371 |
0.8352 |
0.8327 |
0.8245 |
0.8103 |
4.1326 |
190 |
0.7106 |
- |
- |
- |
- |
- |
4.3536 |
200 |
0.7552 |
- |
- |
- |
- |
- |
4.5746 |
210 |
0.9339 |
- |
- |
- |
- |
- |
4.7956 |
220 |
0.776 |
- |
- |
- |
- |
- |
5.0 |
230 |
0.8253 |
0.8368 |
0.8352 |
0.8337 |
0.8254 |
0.8121 |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.11.11
- Sentence Transformers: 4.1.0
- Transformers: 4.52.3
- PyTorch: 2.6.0+cu124
- Accelerate: 1.7.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}
}