Legal 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 Type: Sentence Transformer
- Base model: bkai-foundation-models/vietnamese-bi-encoder
- Maximum Sequence Length: 256 tokens
- Output Dimensionality: 768 tokens
- Similarity Function: Cosine Similarity
- Language: en
- License: apache-2.0
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': 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
# Download from the 🤗 Hub
model = SentenceTransformer("ictumuk/legal-vietnamese-bi-encoder")
# Run inference
sentences = [
'Đối với các danh hiệu thi đua, hình thức khen thưởng cấp nhà nước, khi nhận được quyết định khen thưởng, thủ trưởng các đơn vị lập kế hoạch tổ chức đón nhận, trình Lãnh đạo Bộ cho ý kiến chỉ đạo thực hiện. Khi có ý kiến của Lãnh đạo Bộ phối hợp với Thường trực Hội đồng Bộ tổ chức công bố, trao tặng. Lễ trao tặng cần trang trọng, nên kết hợp với dịp Hội nghị tổng kết công tác, kỷ niệm ngày thành lập đơn vị hoặc lồng ghép với các nội dung khác để tiết kiệm thời gian và chi phí.',
'Tổ chức trao tặng danh hiệu thi đua ngành lao động thương binh và xã hội được quy định như thế nào?',
'Xử phạt bao nhiêu nếu nhân viên phục vụ xe du lịch không hỗ trợ, giúp đỡ hành khách là người khuyết tật?',
]
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
- Dataset:
dim_768
- Evaluated with
InformationRetrievalEvaluator
Metric | Value |
---|---|
cosine_accuracy@1 | 0.6931 |
cosine_accuracy@3 | 0.8284 |
cosine_accuracy@5 | 0.8416 |
cosine_accuracy@10 | 0.8746 |
cosine_precision@1 | 0.6931 |
cosine_precision@3 | 0.2761 |
cosine_precision@5 | 0.1683 |
cosine_precision@10 | 0.0875 |
cosine_recall@1 | 0.6931 |
cosine_recall@3 | 0.8284 |
cosine_recall@5 | 0.8416 |
cosine_recall@10 | 0.8746 |
cosine_ndcg@10 | 0.7874 |
cosine_mrr@10 | 0.7591 |
cosine_map@100 | 0.7617 |
Information Retrieval
- Dataset:
dim_512
- Evaluated with
InformationRetrievalEvaluator
Metric | Value |
---|---|
cosine_accuracy@1 | 0.6766 |
cosine_accuracy@3 | 0.8152 |
cosine_accuracy@5 | 0.8383 |
cosine_accuracy@10 | 0.8746 |
cosine_precision@1 | 0.6766 |
cosine_precision@3 | 0.2717 |
cosine_precision@5 | 0.1677 |
cosine_precision@10 | 0.0875 |
cosine_recall@1 | 0.6766 |
cosine_recall@3 | 0.8152 |
cosine_recall@5 | 0.8383 |
cosine_recall@10 | 0.8746 |
cosine_ndcg@10 | 0.7808 |
cosine_mrr@10 | 0.7501 |
cosine_map@100 | 0.753 |
Information Retrieval
- Dataset:
dim_256
- Evaluated with
InformationRetrievalEvaluator
Metric | Value |
---|---|
cosine_accuracy@1 | 0.6634 |
cosine_accuracy@3 | 0.8218 |
cosine_accuracy@5 | 0.8383 |
cosine_accuracy@10 | 0.8746 |
cosine_precision@1 | 0.6634 |
cosine_precision@3 | 0.2739 |
cosine_precision@5 | 0.1677 |
cosine_precision@10 | 0.0875 |
cosine_recall@1 | 0.6634 |
cosine_recall@3 | 0.8218 |
cosine_recall@5 | 0.8383 |
cosine_recall@10 | 0.8746 |
cosine_ndcg@10 | 0.7737 |
cosine_mrr@10 | 0.7407 |
cosine_map@100 | 0.7436 |
Information Retrieval
- Dataset:
dim_128
- Evaluated with
InformationRetrievalEvaluator
Metric | Value |
---|---|
cosine_accuracy@1 | 0.6238 |
cosine_accuracy@3 | 0.7921 |
cosine_accuracy@5 | 0.8119 |
cosine_accuracy@10 | 0.868 |
cosine_precision@1 | 0.6238 |
cosine_precision@3 | 0.264 |
cosine_precision@5 | 0.1624 |
cosine_precision@10 | 0.0868 |
cosine_recall@1 | 0.6238 |
cosine_recall@3 | 0.7921 |
cosine_recall@5 | 0.8119 |
cosine_recall@10 | 0.868 |
cosine_ndcg@10 | 0.7505 |
cosine_mrr@10 | 0.7125 |
cosine_map@100 | 0.7158 |
Information Retrieval
- Dataset:
dim_64
- Evaluated with
InformationRetrievalEvaluator
Metric | Value |
---|---|
cosine_accuracy@1 | 0.6205 |
cosine_accuracy@3 | 0.7426 |
cosine_accuracy@5 | 0.7921 |
cosine_accuracy@10 | 0.8383 |
cosine_precision@1 | 0.6205 |
cosine_precision@3 | 0.2475 |
cosine_precision@5 | 0.1584 |
cosine_precision@10 | 0.0838 |
cosine_recall@1 | 0.6205 |
cosine_recall@3 | 0.7426 |
cosine_recall@5 | 0.7921 |
cosine_recall@10 | 0.8383 |
cosine_ndcg@10 | 0.7262 |
cosine_mrr@10 | 0.6905 |
cosine_map@100 | 0.6945 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 2,720 training samples
- Columns:
positive
andanchor
- Approximate statistics based on the first 1000 samples:
positive anchor type string string details - min: 4 tokens
- mean: 76.83 tokens
- max: 256 tokens
- min: 6 tokens
- mean: 24.09 tokens
- max: 70 tokens
- Samples:
positive anchor Việc tổ chức sát hạch theo định kỳ 06 tháng một lần hoặc đột xuất theo yêu cầu thực tế tại các địa điểm tổ chức sát hạch đủ điều kiện theo quy định.
Thi sát hạch cấp CCHN kiến trúc được tổ chức vào thời gian nào?
Bộ Nông nghiệp và Phát triển nông thôn chủ trì, phối hợp với các Bộ, ngành có liên quan khẩn trương nghiên cứu trình Thủ tướng Chính phủ ban hành chính sách đối với công chức kiểm lâm. Tiếp tục đầu tư cho lực lượng kiểm lâm thông qua các dự án đào tạo nâng cao năng lực; đầu tư bảo vệ rừng và phòng cháy chữa cháy rừng; tăng cường trang bị vũ khí quân dụng và công cụ hỗ trợ cho kiểm lâm. Giai đoạn 2011 - 2015 đào tạo chuyên môn, nghiệp vụ cho khoảng 8.000 lượt người thuộc lực lượng bảo vệ rừng cơ sở và lực lượng kiểm lâm; đầu tư phương tiện, trang thiết bị phục vụ công tác phòng cháy, chữa cháy rừng và bảo vệ rừng (khoảng 1.000 tỷ đồng).
Chính sách nâng cao năng lực, hiệu quả hoạt động đối với lực lượng Kiểm lâm được quy định như thế nào?
Phạt tiền từ 1.000.000 đồng đến 3.000.000 đồng.
Công chứng viên không giao giấy nhận lưu giữ cho người lập di chúc khi nhận lưu giữ di chúc phạt bao nhiêu?
- 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 }
Evaluation Dataset
Unnamed Dataset
- Size: 303 evaluation samples
- Columns:
positive
andanchor
- Approximate statistics based on the first 1000 samples:
positive anchor type string string details - min: 7 tokens
- mean: 77.55 tokens
- max: 256 tokens
- min: 9 tokens
- mean: 24.21 tokens
- max: 54 tokens
- Samples:
positive anchor Hồ sơ cấp lại Thẻ công chứng viên gồm các giấy tờ sau đây:
a) Giấy đề nghị cấp lại Thẻ công chứng viên (Mẫu TP-CC-07);
b) 01 ảnh chân dung cỡ 2cm x 3cm (ảnh chụp không quá 06 tháng trước ngày nộp hồ sơ);
c) Thẻ công chứng viên đang sử dụng (trong trường hợp Thẻ bị hỏng).Hồ sơ cấp lại Thẻ công chứng viên gồm những giấy tờ gì?
"Tổ chức tôn giáo phải có tên bằng tiếng Việt."
Tổ chức tôn giáo có được sử dụng tên tiếng anh?
Mức độ bảo đảm khi đăng nhập tài khoản thực hiện thủ tục hành chính trên môi trường điện tử được quy định như sau:
a) Mức độ bảo đảm của danh tính điện tử của tổ chức, cá nhân được dùng để đăng nhập dựa trên xác minh được các thông tin của danh tính điện tử do tổ chức, cá nhân cung cấp là chính xác thông qua việc so sánh, đối chiếu tự động với các thông tin, dữ liệu hệ thống đang quản lý hoặc được kết nối, chia sẻ; hoặc so sánh với các bằng chứng mà tổ chức, cá nhân đó cung cấp trực tiếp;
b) Mức độ bảo đảm xác thực người dùng khi đăng nhập tài khoản dựa trên ít nhất một yếu tố xác thực của tổ chức, cá nhân.
Mức độ bảo đảm xác thực người dùng khi thực hiện thủ tục hành chính do cơ quan, tổ chức xây dựng, cung cấp dịch vụ công trực tuyến xác định. Trường hợp mức độ bảo đảm xác thực khi thực hiện thủ tục hành chính yêu cầu cao hơn so với mức độ khi đăng nhập, tổ chức, cá nhân bổ sung giải pháp xác thực theo hướng dẫn cụ thể của cơ quan cung cấp thủ tục hành chính tại Cổng dịch vụ công quốc gia hoặc Cổng dịch vụ công cấp bộ, cấp tỉnh.Mức độ bảo đảm khi đăng nhập tài khoản thực hiện thủ tục hành chính trên môi trường điện tử được quy định như thế nào?
- 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
: epochper_device_train_batch_size
: 16per_device_eval_batch_size
: 16gradient_accumulation_steps
: 16learning_rate
: 2e-05num_train_epochs
: 25lr_scheduler_type
: cosinewarmup_ratio
: 0.1fp16
: Trueload_best_model_at_end
: Trueoptim
: adamw_torch_fusedbatch_sampler
: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: epochprediction_loss_only
: Trueper_device_train_batch_size
: 16per_device_eval_batch_size
: 16per_gpu_train_batch_size
: Noneper_gpu_eval_batch_size
: Nonegradient_accumulation_steps
: 16eval_accumulation_steps
: Nonelearning_rate
: 2e-05weight_decay
: 0.0adam_beta1
: 0.9adam_beta2
: 0.999adam_epsilon
: 1e-08max_grad_norm
: 1.0num_train_epochs
: 25max_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
: 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}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
: 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
: Falsehub_always_push
: Falsegradient_checkpointing
: Falsegradient_checkpointing_kwargs
: Noneinclude_inputs_for_metrics
: Falseeval_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
: Nonedispatch_batches
: Nonesplit_batches
: Noneinclude_tokens_per_second
: Falseinclude_num_input_tokens_seen
: Falseneftune_noise_alpha
: Noneoptim_target_modules
: Nonebatch_eval_metrics
: Falsebatch_sampler
: no_duplicatesmulti_dataset_batch_sampler
: proportional
Training Logs
Epoch | Step | Training Loss | loss | dim_128_cosine_map@100 | dim_256_cosine_map@100 | dim_512_cosine_map@100 | dim_64_cosine_map@100 | dim_768_cosine_map@100 |
---|---|---|---|---|---|---|---|---|
0.9412 | 10 | 2.0053 | 1.3422 | 0.6805 | 0.6979 | 0.7146 | 0.6315 | 0.7193 |
1.8824 | 20 | 1.3864 | - | - | - | - | - | - |
1.9765 | 21 | - | 0.9838 | 0.6810 | 0.7072 | 0.7361 | 0.6481 | 0.7497 |
2.8235 | 30 | 0.9121 | - | - | - | - | - | - |
2.9176 | 31 | - | 0.8075 | 0.6928 | 0.7228 | 0.7385 | 0.6565 | 0.7449 |
3.7647 | 40 | 0.5327 | - | - | - | - | - | - |
3.9529 | 42 | - | 0.7225 | 0.7061 | 0.7330 | 0.7497 | 0.6707 | 0.7543 |
4.7059 | 50 | 0.3222 | - | - | - | - | - | - |
4.9882 | 53 | - | 0.6622 | 0.7039 | 0.7309 | 0.7473 | 0.6697 | 0.7509 |
5.6471 | 60 | 0.2505 | - | - | - | - | - | - |
5.9294 | 63 | - | 0.6895 | 0.7049 | 0.7381 | 0.7518 | 0.6757 | 0.7598 |
6.5882 | 70 | 0.1677 | - | - | - | - | - | - |
6.9647 | 74 | - | 0.6428 | 0.7167 | 0.7431 | 0.7535 | 0.6823 | 0.7575 |
7.5294 | 80 | 0.122 | - | - | - | - | - | - |
8.0 | 85 | - | 0.6084 | 0.7039 | 0.7392 | 0.7478 | 0.6762 | 0.7573 |
8.4706 | 90 | 0.0956 | - | - | - | - | - | - |
8.9412 | 95 | - | 0.6338 | 0.7079 | 0.7428 | 0.7515 | 0.6840 | 0.7591 |
9.4118 | 100 | 0.0748 | - | - | - | - | - | - |
9.9765 | 106 | - | 0.6446 | 0.7128 | 0.7429 | 0.7477 | 0.6834 | 0.7582 |
10.3529 | 110 | 0.0582 | - | - | - | - | - | - |
10.9176 | 116 | - | 0.6115 | 0.7095 | 0.7375 | 0.7467 | 0.6850 | 0.7567 |
11.2941 | 120 | 0.0509 | - | - | - | - | - | - |
11.9529 | 127 | - | 0.6557 | 0.7091 | 0.7433 | 0.7474 | 0.6803 | 0.7552 |
12.2353 | 130 | 0.0446 | - | - | - | - | - | - |
12.9882 | 138 | - | 0.6356 | 0.7130 | 0.7430 | 0.7530 | 0.6867 | 0.7562 |
13.1765 | 140 | 0.0356 | - | - | - | - | - | - |
13.9294 | 148 | - | 0.6487 | 0.7079 | 0.7380 | 0.7466 | 0.6868 | 0.7531 |
14.1176 | 150 | 0.0308 | - | - | - | - | - | - |
14.9647 | 159 | - | 0.6595 | 0.7102 | 0.7384 | 0.7494 | 0.6885 | 0.7566 |
15.0588 | 160 | 0.0301 | - | - | - | - | - | - |
16.0 | 170 | 0.0279 | 0.6594 | 0.7170 | 0.7434 | 0.7532 | 0.6924 | 0.7617 |
16.9412 | 180 | 0.0202 | 0.7014 | 0.7138 | 0.7438 | 0.7557 | 0.6902 | 0.7601 |
17.8824 | 190 | 0.0197 | - | - | - | - | - | - |
17.9765 | 191 | - | 0.7127 | 0.7124 | 0.7417 | 0.7518 | 0.6893 | 0.7594 |
18.8235 | 200 | 0.0157 | - | - | - | - | - | - |
18.9176 | 201 | - | 0.7047 | 0.7127 | 0.7423 | 0.7521 | 0.6914 | 0.7611 |
19.7647 | 210 | 0.0157 | - | - | - | - | - | - |
19.9529 | 212 | - | 0.6954 | 0.7160 | 0.7437 | 0.7534 | 0.6931 | 0.7610 |
20.7059 | 220 | 0.0133 | - | - | - | - | - | - |
20.9882 | 223 | - | 0.6913 | 0.7170 | 0.7438 | 0.7533 | 0.6945 | 0.7619 |
21.6471 | 230 | 0.0157 | - | - | - | - | - | - |
21.9294 | 233 | - | 0.6902 | 0.7158 | 0.7436 | 0.7530 | 0.6943 | 0.7618 |
22.5882 | 240 | 0.016 | - | - | - | - | - | - |
22.9647 | 244 | - | 0.6900 | 0.7156 | 0.7434 | 0.7528 | 0.6943 | 0.7615 |
23.5294 | 250 | 0.0159 | 0.6901 | 0.7158 | 0.7436 | 0.7530 | 0.6945 | 0.7617 |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.10.13
- Sentence Transformers: 3.0.1
- Transformers: 4.41.2
- PyTorch: 2.1.2
- Accelerate: 0.30.1
- Datasets: 2.19.2
- Tokenizers: 0.19.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}
}
- Downloads last month
- 0
Inference API (serverless) is not available, repository is disabled.
Model tree for ictumuk/legal-vietnamese-bi-encoder
Base model
bkai-foundation-models/vietnamese-bi-encoder
Finetuned
this model
Evaluation results
- Cosine Accuracy@1 on dim 768self-reported0.693
- Cosine Accuracy@3 on dim 768self-reported0.828
- Cosine Accuracy@5 on dim 768self-reported0.842
- Cosine Accuracy@10 on dim 768self-reported0.875
- Cosine Precision@1 on dim 768self-reported0.693
- Cosine Precision@3 on dim 768self-reported0.276
- Cosine Precision@5 on dim 768self-reported0.168
- Cosine Precision@10 on dim 768self-reported0.087
- Cosine Recall@1 on dim 768self-reported0.693
- Cosine Recall@3 on dim 768self-reported0.828