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
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("ictumuk/legal-vietnamese-bi-encoder")
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)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
Evaluation
Metrics
Information Retrieval
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
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
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
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
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
and anchor
- 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
and anchor
- 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
: epoch
per_device_train_batch_size
: 16
per_device_eval_batch_size
: 16
gradient_accumulation_steps
: 16
learning_rate
: 2e-05
num_train_epochs
: 25
lr_scheduler_type
: cosine
warmup_ratio
: 0.1
fp16
: 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
: epoch
prediction_loss_only
: True
per_device_train_batch_size
: 16
per_device_eval_batch_size
: 16
per_gpu_train_batch_size
: None
per_gpu_eval_batch_size
: None
gradient_accumulation_steps
: 16
eval_accumulation_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
: 25
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
: 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}
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
: False
hub_always_push
: False
gradient_checkpointing
: False
gradient_checkpointing_kwargs
: None
include_inputs_for_metrics
: False
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
dispatch_batches
: None
split_batches
: None
include_tokens_per_second
: False
include_num_input_tokens_seen
: False
neftune_noise_alpha
: None
optim_target_modules
: None
batch_eval_metrics
: False
batch_sampler
: no_duplicates
multi_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}
}