Downloads · 30 days
72
21% of all-time downloads
namnguyenba2003/Vietnamese_Law_Embedding_finetuned_v2
Vietnamese_Law_Embedding_finetuned_v2 is a sentence similarity model from namnguyenba2003. Use it when you need a score for how close two texts are. It is set up for sentence-transformers. The card lists the license as apache-2.0.
This is a sentence-transformers model finetuned from AITeamVN/VietnameseEmbedding on the json dataset. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for semantic textual simil…
Downloads · 30 days
72
21% of all-time downloads
All-time downloads
348
Public
Parameters
568M
2.3 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2.3 GB · 99%
From the Hugging Face model README
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.
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()
)
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("namnguyenba2003/Vietnamese_Law_Embedding_finetuned_v2")
# Run inference
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)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
<!--
### Direct Usage (Transformers)
<details><summary>Click to see the direct usage in Transformers</summary>
</details>
-->
<!--
### Downstream Usage (Sentence Transformers)
You can finetune this model on your own dataset.
<details><summary>Click to expand</summary>
</details>
-->
<!--
### Out-of-Scope Use
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
-->
dim_1024{
"truncate_dim": 1024
}
| 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 |
dim_768{
"truncate_dim": 768
}
| 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 |
dim_512{
"truncate_dim": 512
}
| 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 |
dim_256{
"truncate_dim": 256
}
| 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 |
dim_128{
"truncate_dim": 128
}
| 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 |
| positive | anchor | |
|---|---|---|
| type | string | string |
| details | <ul><li>min: 109 tokens</li><li>mean: 209.39 tokens</li><li>max: 313 tokens</li></ul> | <ul><li>min: 15 tokens</li><li>mean: 37.15 tokens</li><li>max: 93 tokens</li></ul> |
| positive | anchor |
|---|---|
| <code>Khoản 1. Hộ gia đình, cá nhân có trách nhiệm sau đây:<br>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;<br>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ư;<br>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;<br>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;<br>đ) Tham gia hoạt động bảo vệ môi trường tại cộng đồng dân cư;<br>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.</code> | <code>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?</code> |
| <code>Điều 34. Đối tượng chịu sự kiểm tra, kiểm soát tần số vô tuyến điện<br>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.<br>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.</code> | <code>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?</code> |
| <code>Điều 34. Điều kiện bảo đảm chất lượng hàng hóa nhập khẩu<br>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.<br>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.<br>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.<br>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.</code> | <code>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?</code> |
{
"loss": "MultipleNegativesRankingLoss",
"matryoshka_dims": [
1024,
768,
512,
256,
128
],
"matryoshka_weights": [
1,
1,
1,
1,
1
],
"n_dims_per_step": -1
}
eval_strategy: epochper_device_train_batch_size: 64per_device_eval_batch_size: 64gradient_accumulation_steps: 8learning_rate: 2e-05num_train_epochs: 5lr_scheduler_type: cosinewarmup_ratio: 0.1fp16: Truetf32: Truedataloader_num_workers: 8load_best_model_at_end: Trueoptim: adamw_torch_fusedddp_find_unused_parameters: Falsebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: epochprediction_loss_only: Trueper_device_train_batch_size: 64per_device_eval_batch_size: 64per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 8eval_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: 5max_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: Falsefp16: Truefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Truelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 8dataloader_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}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}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torch_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Falseddp_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| 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 |
@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",
}
@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}
}
@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}
}
<!--
## Glossary
*Clearly define terms in order to be accessible across audiences.*
-->
<!--
## Model Card Authors
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
-->
<!--
## Model Card Contact
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
-->