Legal vietnamese-sbert
This is a sentence-transformers model finetuned from keepitreal/vietnamese-sbert. 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: keepitreal/vietnamese-sbert
- 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-sbert")
sentences = [
'Trường hợp bảo đảm bằng quyền sử dụng đất, tài sản gắn liền với đất thì hợp đồng thế chấp vẫn còn hiệu lực, biện pháp thế chấp vẫn còn hiệu lực đối kháng với người thứ ba khi tài sản gắn liền với đất hoặc quyền sử dụng đất không phải là tài sản bảo đảm được mua bán, được chuyển nhượng, được chuyển giao khác về quyền sở hữu hoặc được dùng để bảo đảm thực hiện nghĩa vụ. Hiệu lực của hợp đồng bảo đảm, hiệu lực đối kháng của biện pháp bảo đảm bằng tài sản được tạo lập từ quyền bề mặt, quyền hưởng dụng với người thứ ba không thay đổi hoặc không chấm dứt trong trường hợp quyền sử dụng đất có quyền bề mặt, tài sản là đối tượng của quyền hưởng dụng được mua bán, được chuyển nhượng, được chuyển giao khác về quyền sở hữu hoặc được dùng để bảo đảm thực hiện nghĩa vụ.',
'Bảo đảm bằng quyền sử dụng đất, tài sản gắn liền với đất và tài sản được tạo lập từ quyền bề mặt, quyền hưởng dụng được quy định như thế nào?',
'Thời hạn hủy bỏ quyết định tạm đình chỉ liên quan đến tham nhũng được quy định như thế nào?',
]
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.6106 |
cosine_accuracy@3 |
0.7558 |
cosine_accuracy@5 |
0.7888 |
cosine_accuracy@10 |
0.835 |
cosine_precision@1 |
0.6106 |
cosine_precision@3 |
0.2519 |
cosine_precision@5 |
0.1578 |
cosine_precision@10 |
0.0835 |
cosine_recall@1 |
0.6106 |
cosine_recall@3 |
0.7558 |
cosine_recall@5 |
0.7888 |
cosine_recall@10 |
0.835 |
cosine_ndcg@10 |
0.7257 |
cosine_mrr@10 |
0.6905 |
cosine_map@100 |
0.6949 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.6073 |
cosine_accuracy@3 |
0.7525 |
cosine_accuracy@5 |
0.7855 |
cosine_accuracy@10 |
0.8284 |
cosine_precision@1 |
0.6073 |
cosine_precision@3 |
0.2508 |
cosine_precision@5 |
0.1571 |
cosine_precision@10 |
0.0828 |
cosine_recall@1 |
0.6073 |
cosine_recall@3 |
0.7525 |
cosine_recall@5 |
0.7855 |
cosine_recall@10 |
0.8284 |
cosine_ndcg@10 |
0.7209 |
cosine_mrr@10 |
0.6862 |
cosine_map@100 |
0.6913 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.5743 |
cosine_accuracy@3 |
0.7426 |
cosine_accuracy@5 |
0.7789 |
cosine_accuracy@10 |
0.8251 |
cosine_precision@1 |
0.5743 |
cosine_precision@3 |
0.2475 |
cosine_precision@5 |
0.1558 |
cosine_precision@10 |
0.0825 |
cosine_recall@1 |
0.5743 |
cosine_recall@3 |
0.7426 |
cosine_recall@5 |
0.7789 |
cosine_recall@10 |
0.8251 |
cosine_ndcg@10 |
0.7045 |
cosine_mrr@10 |
0.6655 |
cosine_map@100 |
0.6705 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.571 |
cosine_accuracy@3 |
0.7063 |
cosine_accuracy@5 |
0.7558 |
cosine_accuracy@10 |
0.8119 |
cosine_precision@1 |
0.571 |
cosine_precision@3 |
0.2354 |
cosine_precision@5 |
0.1512 |
cosine_precision@10 |
0.0812 |
cosine_recall@1 |
0.571 |
cosine_recall@3 |
0.7063 |
cosine_recall@5 |
0.7558 |
cosine_recall@10 |
0.8119 |
cosine_ndcg@10 |
0.6905 |
cosine_mrr@10 |
0.6517 |
cosine_map@100 |
0.657 |
Information Retrieval
Metric |
Value |
cosine_accuracy@1 |
0.5347 |
cosine_accuracy@3 |
0.703 |
cosine_accuracy@5 |
0.7492 |
cosine_accuracy@10 |
0.802 |
cosine_precision@1 |
0.5347 |
cosine_precision@3 |
0.2343 |
cosine_precision@5 |
0.1498 |
cosine_precision@10 |
0.0802 |
cosine_recall@1 |
0.5347 |
cosine_recall@3 |
0.703 |
cosine_recall@5 |
0.7492 |
cosine_recall@10 |
0.802 |
cosine_ndcg@10 |
0.6703 |
cosine_mrr@10 |
0.628 |
cosine_map@100 |
0.6331 |
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: 5 tokens
- mean: 75.95 tokens
- max: 256 tokens
|
- min: 8 tokens
- mean: 24.4 tokens
- max: 56 tokens
|
- Samples:
positive |
anchor |
Mỗi năm có thể được rút ngắn thời gian thử thách 01 lần từ 03 tháng đến 02 năm. |
01 lần rút ngắn thời gian thử thách được bao nhiêu ngày? |
Đánh giá tác động của biến đổi khí hậu đến hoạt động kinh tế - xã hội và các vấn đề liên ngành, liên vùng, liên lĩnh vực, bao gồm các nội dung sau: a) Đánh giá các tác động tích cực, tiêu cực, ngắn hạn, dài hạn của biến đổi khí hậu đến hoạt động kinh tế - xã hội liên quan đến phạm vi của chiến lược, quy hoạch, kế hoạch; b) Đánh giá tác động tích cực, tiêu cực, ngắn hạn, dài hạn của biến đổi khí hậu đến các vấn đề liên ngành, liên vùng, liên lĩnh vực. |
Nội dung đánh giá tác động của biến đổi khí hậu đến hoạt động kinh tế - xã hội được quy định như thế nào? |
Không có thông tin liên quan tới trách nhiệm của Ngân hàng nhà nước trong hai đoạn văn trên. Hai đoạn văn trên chỉ đề cập tới việc thực hiện xác nhận đăng ký hoặc đăng ký thay đổi khoản vay nước ngoài được Chính phủ bảo lãnh và cập nhật thông tin tín dụng Quốc gia Việt Nam. |
Trách nhiệm của Ngân hàng nhà nước liên quan tới bảo lãnh Chính phủ đượ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
}
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: 4 tokens
- mean: 77.76 tokens
- max: 256 tokens
|
- min: 6 tokens
- mean: 24.18 tokens
- max: 73 tokens
|
- Samples:
positive |
anchor |
Căn cứ lập hồ sơ mời thầu dự án đầu tư có sử dụng đất bao gồm:
a) Danh mục dự án đầu tư có sử dụng đất cần lựa chọn nhà đầu tư được công bố theo quy định; b) Kế hoạch lựa chọn nhà đầu tư được duyệt; c) Quy định hiện hành của pháp luật về đất đai, nhà ở, kinh doanh bất động sản, đầu tư, xây dựng và quy định của pháp luật có liên quan. |
Lập hồ sơ mời thầu dự án đầu tư có sử dụng đất dựa trên những căn cứ nào? |
Phạt tiền từ 3.000.000 đồng đến 5.000.000 đồng đối với hành vi phá hoại cơ sở vật chất - kỹ thuật, kho bảo quản hàng dự trữ quốc gia. |
Mức phạt đối với hành vi phá hoại kho bảo quản hàng dự trữ quốc gia được quy định như thế nào? |
Hồ sơ đăng ký thành viên bù trừ bao gồm:
a) Giấy đăng ký thành viên bù trừ theo Mẫu số 48 Phụ lục ban hành kèm theo Nghị định này; b) Giấy chứng nhận đủ điều kiện cung cấp dịch vụ bù trừ, thanh toán giao dịch chứng khoán do Ủy ban Chứng khoán Nhà nước cấp; c) Bản thuyết minh về hạ tầng công nghệ thông tin, nhân sự, quy trình nghiệp vụ. |
Hồ sơ về đăng ký thành viên bù trừ chứng khoán Việt Nam đượ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 |
3.6588 |
2.3368 |
0.5313 |
0.5648 |
0.5747 |
0.4508 |
0.5856 |
1.8824 |
20 |
2.6403 |
- |
- |
- |
- |
- |
- |
1.9765 |
21 |
- |
1.7613 |
0.5788 |
0.5934 |
0.6062 |
0.5009 |
0.6134 |
2.8235 |
30 |
1.7794 |
- |
- |
- |
- |
- |
- |
2.9176 |
31 |
- |
1.5005 |
0.5999 |
0.6218 |
0.6274 |
0.5328 |
0.6299 |
3.7647 |
40 |
1.1983 |
- |
- |
- |
- |
- |
- |
3.9529 |
42 |
- |
1.2607 |
0.6128 |
0.6384 |
0.6492 |
0.5776 |
0.6461 |
4.7059 |
50 |
0.8626 |
- |
- |
- |
- |
- |
- |
4.9882 |
53 |
- |
1.1057 |
0.6176 |
0.6543 |
0.6542 |
0.5907 |
0.6591 |
5.6471 |
60 |
0.6381 |
- |
- |
- |
- |
- |
- |
5.9294 |
63 |
- |
1.0423 |
0.6338 |
0.6678 |
0.6704 |
0.6151 |
0.6755 |
6.5882 |
70 |
0.4149 |
- |
- |
- |
- |
- |
- |
6.9647 |
74 |
- |
0.8898 |
0.6350 |
0.6714 |
0.6828 |
0.6183 |
0.6739 |
7.5294 |
80 |
0.3352 |
- |
- |
- |
- |
- |
- |
8.0 |
85 |
- |
0.9243 |
0.6468 |
0.6679 |
0.6845 |
0.6244 |
0.6743 |
8.4706 |
90 |
0.2603 |
- |
- |
- |
- |
- |
- |
8.9412 |
95 |
- |
0.9162 |
0.6461 |
0.6758 |
0.6900 |
0.6247 |
0.6839 |
9.4118 |
100 |
0.2124 |
- |
- |
- |
- |
- |
- |
9.9765 |
106 |
- |
0.8410 |
0.6428 |
0.6623 |
0.6839 |
0.6247 |
0.6810 |
10.3529 |
110 |
0.1555 |
- |
- |
- |
- |
- |
- |
10.9176 |
116 |
- |
0.8458 |
0.6493 |
0.6660 |
0.6889 |
0.6271 |
0.6884 |
11.2941 |
120 |
0.1293 |
- |
- |
- |
- |
- |
- |
11.9529 |
127 |
- |
0.8563 |
0.6477 |
0.6650 |
0.6850 |
0.6306 |
0.6898 |
12.2353 |
130 |
0.1059 |
- |
- |
- |
- |
- |
- |
12.9882 |
138 |
- |
0.8598 |
0.6494 |
0.6703 |
0.6819 |
0.6217 |
0.6901 |
13.1765 |
140 |
0.1071 |
- |
- |
- |
- |
- |
- |
13.9294 |
148 |
- |
0.8248 |
0.6519 |
0.6627 |
0.6786 |
0.6278 |
0.6923 |
14.1176 |
150 |
0.0876 |
- |
- |
- |
- |
- |
- |
14.9647 |
159 |
- |
0.8213 |
0.6506 |
0.6693 |
0.6877 |
0.6342 |
0.6928 |
15.0588 |
160 |
0.0835 |
- |
- |
- |
- |
- |
- |
16.0 |
170 |
0.0685 |
0.8266 |
0.6515 |
0.6707 |
0.6835 |
0.6301 |
0.6953 |
16.9412 |
180 |
0.057 |
0.8119 |
0.6499 |
0.6714 |
0.6895 |
0.6305 |
0.6976 |
17.8824 |
190 |
0.0544 |
- |
- |
- |
- |
- |
- |
17.9765 |
191 |
- |
0.8226 |
0.6538 |
0.6671 |
0.6883 |
0.6347 |
0.7000 |
18.8235 |
200 |
0.0586 |
- |
- |
- |
- |
- |
- |
18.9176 |
201 |
- |
0.8241 |
0.6575 |
0.6716 |
0.6912 |
0.6324 |
0.6984 |
19.7647 |
210 |
0.0472 |
- |
- |
- |
- |
- |
- |
19.9529 |
212 |
- |
0.8270 |
0.6553 |
0.6709 |
0.6913 |
0.6323 |
0.6948 |
20.7059 |
220 |
0.0487 |
- |
- |
- |
- |
- |
- |
20.9882 |
223 |
- |
0.8276 |
0.6538 |
0.6727 |
0.6928 |
0.6325 |
0.6949 |
21.6471 |
230 |
0.046 |
- |
- |
- |
- |
- |
- |
21.9294 |
233 |
- |
0.8278 |
0.6569 |
0.6705 |
0.6929 |
0.6314 |
0.6949 |
22.5882 |
240 |
0.0427 |
- |
- |
- |
- |
- |
- |
22.9647 |
244 |
- |
0.8277 |
0.6569 |
0.6705 |
0.6929 |
0.6331 |
0.6949 |
23.5294 |
250 |
0.0466 |
0.8277 |
0.6570 |
0.6705 |
0.6913 |
0.6331 |
0.6949 |
- 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}
}