VietnamLegalText-SBERT-finetuned
This is a sentence-transformers model finetuned from hmthanh/VietnamLegalText-SBERT on the json dataset. 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: hmthanh/VietnamLegalText-SBERT
- Maximum Sequence Length: 256 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Training Dataset:
- json
- Language: vi
- 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("namnguyenba2003/VietnamLegalText-SBERT-finetuned")
# Run inference
sentences = [
'k) Thành viên phải duy trì số dư tài khoản thanh toán bảo đảm thực hiện các Lệnh thanh toán và quyết toán bù trừ qua Hệ thống TTLNH;\nl) Trường hợp thành viên, đơn vị thành viên chấm dứt tư cách thành viên, đơn vị thành viên, phải thực hiện thủ tục đề nghị thu hồi chứng thư số (nếu có) sử dụng trong TTLNH theo quy định tại Thông tư về việc quản lý, sử dụng chữ ký số, chứng thư số và dịch vụ chứng thực chữ ký số của Ngân hàng Nhà nước;\nm) Đảm bảo, duy trì hạ tầng kỹ thuật và nguồn lực quy định tại Điểm c, d Khoản 1 và Điểm a, b Khoản 3 Điều 40 Thông tư này;\nn) Đăng ký danh sách địa chỉ hộp thư điện tử để trao đổi các thông tin liên quan đến Hệ thống TTLNH được quy định trao đổi qua thư điện tử tại Thông tư này;\no) Chấp hành đúng các quy định về thời điểm áp dụng trong Hệ thống TTLNH để bảo đảm thanh toán được thực hiện thuận lợi, chính xác, kịp thời và an toàn tài sản;\np) Thành viên phải thường xuyên giám sát hạn mức nợ ròng hiện thời của mình để duy trì ở mức thích hợp;',
'Các thành viên, đơn vị thành viên của Hệ thống Thanh toán điện tử liên ngân hàng Quốc gia phải đảm bảo và duy trì những hạ tầng kỹ thuật và nguồn lực gì?',
'Bộ Quốc phòng quy định như thế nào về việc điều chỉnh tỷ lệ khấu hao tài sản cố định để đảm bảo phù hợp với lộ trình tính giá dịch vụ sự nghiệp công?',
]
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
- Datasets:
dim_768
,dim_512
,dim_256
,dim_128
anddim_64
- Evaluated with
InformationRetrievalEvaluator
Metric | dim_768 | dim_512 | dim_256 | dim_128 | dim_64 |
---|---|---|---|---|---|
cosine_accuracy@1 | 0.5425 | 0.5317 | 0.5161 | 0.4955 | 0.452 |
cosine_accuracy@3 | 0.5845 | 0.5755 | 0.5693 | 0.5417 | 0.5014 |
cosine_accuracy@5 | 0.6901 | 0.687 | 0.6812 | 0.6447 | 0.6027 |
cosine_accuracy@10 | 0.7852 | 0.7837 | 0.7794 | 0.7596 | 0.7157 |
cosine_precision@1 | 0.5425 | 0.5317 | 0.5161 | 0.4955 | 0.452 |
cosine_precision@3 | 0.5118 | 0.5021 | 0.4902 | 0.4687 | 0.4312 |
cosine_precision@5 | 0.3738 | 0.3706 | 0.3661 | 0.3468 | 0.3229 |
cosine_precision@10 | 0.2229 | 0.2219 | 0.2215 | 0.2142 | 0.2002 |
cosine_recall@1 | 0.2018 | 0.1983 | 0.1934 | 0.1859 | 0.1686 |
cosine_recall@3 | 0.5439 | 0.5336 | 0.5226 | 0.4999 | 0.4592 |
cosine_recall@5 | 0.6517 | 0.6459 | 0.6387 | 0.6055 | 0.5654 |
cosine_recall@10 | 0.7708 | 0.7684 | 0.7651 | 0.7409 | 0.6957 |
cosine_ndcg@10 | 0.6605 | 0.6542 | 0.6464 | 0.6218 | 0.5771 |
cosine_mrr@10 | 0.596 | 0.5874 | 0.5756 | 0.5524 | 0.5089 |
cosine_map@100 | 0.6377 | 0.6299 | 0.6202 | 0.5976 | 0.5557 |
Training Details
Training Dataset
json
- Dataset: json
- Size: 23,168 training samples
- Columns:
positive
andanchor
- Approximate statistics based on the first 1000 samples:
positive anchor type string string details - min: 107 tokens
- mean: 212.31 tokens
- max: 256 tokens
- min: 19 tokens
- mean: 38.3 tokens
- max: 140 tokens
- Samples:
positive anchor Khoản 1. Trường hợp đề xuất dự án thuộc quy mô nhóm C
a) Nhà đầu tư gửi đề xuất dự án tới đơn vị đầu mối quản lý hoạt động PPP.
b) Trong vòng 05 ngày làm việc kể từ ngày nhận được hồ sơ, đơn vị đầu mối quản lý hoạt động PPP kiểm tra hồ sơ và yêu cầu nhà đầu tư bổ sung nếu hồ sơ chưa đầy đủ, hợp lệ.
c) Trong vòng 20 ngày làm việc kể từ ngày nhận được hồ sơ đầy đủ và hợp lệ, đơn vị đầu mối quản lý hoạt động PPP tổ chức thẩm định đề xuất dự án.
d) Trong vòng 05 ngày làm việc kể từ ngày có kết luận thẩm định, đơn vị đầu mối quản lý hoạt động PPP trình Bộ trưởng Bộ Công Thương phê duyệt. Trường hợp kết luận thẩm định không thông qua đề xuất dự án, đơn vị đầu mối quản lý hoạt động PPP thông báo bằng văn bản tới nhà đầu tư đề xuất dự án và nêu rõ lý do.Đơn vị đầu mối quản lý hoạt động PPP có những trách nhiệm gì trong quá trình thẩm định và phê duyệt đề xuất dự án của nhà đầu tư?
Điều 11. Báo cáo kết quả thẩm định giá, Báo cáo kết quả xác định giá trị tài sản
1. Doanh nghiệp thẩm định giá có trách nhiệm cung cấp Chứng thư thẩm định giá và Báo cáo kết quả thẩm định giá theo quy định của Hệ thống tiêu chuẩn thẩm định giá Việt Nam.
2. Tổ chức có chức năng tư vấn về giá có trách nhiệm lập Báo cáo kết quả xác định giá trị tài sản theo Mẫu tại Phụ lục kèm theo Thông tư này.
3. Báo cáo kết quả thẩm định giá và Báo cáo kết quả xác định giá trị tài sản phải phản ánh trung thực, khách quan quá trình và kết quả xác định giá tài sản và là một căn cứ quan trọng để cơ quan quản lý nhiệm vụ khoa học và công nghệ trình cơ quan có thẩm quyền xem xét, phê duyệt giá trị của tài sản là kết quả của nhiệm vụ khoa học và công nghệ.Doanh nghiệp thẩm định giá có những trách nhiệm gì khi thực hiện thẩm định giá tài sản là kết quả của nhiệm vụ khoa học và công nghệ?
e) Họ tên, năm sinh, nơi cư trú của phạm nhân;
g) Lý do được tạm đình chỉ chấp hành án phạt tù;
h) Tên cơ quan thi hành án hình sự, Ủy ban nhân dân cấp xã, đơn vị quân đội được giao quản lý người được tạm đình chỉ. Trường hợp người được tạm đình chỉ bị bệnh nặng đang phải điều trị tại bệnh viện mà phải giao cho thân nhân chăm sóc thì ghi thêm họ tên, nơi cư trú của thân nhân và mối quan hệ giữa họ;
i) Thời hạn tạm đình chỉ chấp hành án phạt tù và hiệu lực thi hành.Thời hạn tạm đình chỉ chấp hành án phạt tù và thời điểm quyết định có hiệu lực thi hành đượ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
: 4lr_scheduler_type
: cosinewarmup_ratio
: 0.1fp16
: Truedataloader_num_workers
: 4load_best_model_at_end
: Trueoptim
: adamw_torch_fusedddp_find_unused_parameters
: Falsebatch_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
: 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
: 4max_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
: 4dataloader_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}tp_size
: 0fsdp_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
Training Logs
Epoch | Step | Training Loss | dim_768_cosine_ndcg@10 | dim_512_cosine_ndcg@10 | dim_256_cosine_ndcg@10 | dim_128_cosine_ndcg@10 | dim_64_cosine_ndcg@10 |
---|---|---|---|---|---|---|---|
0.2210 | 10 | 202.143 | - | - | - | - | - |
0.4420 | 20 | 59.6662 | - | - | - | - | - |
0.6630 | 30 | 28.2853 | - | - | - | - | - |
0.8840 | 40 | 17.9881 | - | - | - | - | - |
1.0 | 46 | - | 0.6067 | 0.6029 | 0.5918 | 0.5690 | 0.5172 |
1.0884 | 50 | 12.2072 | - | - | - | - | - |
1.3094 | 60 | 9.2488 | - | - | - | - | - |
1.5304 | 70 | 8.6885 | - | - | - | - | - |
1.7514 | 80 | 8.8927 | - | - | - | - | - |
1.9724 | 90 | 7.7438 | - | - | - | - | - |
2.0 | 92 | - | 0.6467 | 0.6451 | 0.6323 | 0.6056 | 0.5596 |
2.1768 | 100 | 6.1924 | - | - | - | - | - |
2.3978 | 110 | 6.3728 | - | - | - | - | - |
2.6188 | 120 | 5.7702 | - | - | - | - | - |
2.8398 | 130 | 5.0061 | - | - | - | - | - |
3.0 | 138 | - | 0.6560 | 0.6502 | 0.6445 | 0.6196 | 0.5736 |
3.0442 | 140 | 5.6389 | - | - | - | - | - |
3.2652 | 150 | 5.1059 | - | - | - | - | - |
3.4862 | 160 | 5.1945 | - | - | - | - | - |
3.7072 | 170 | 5.0158 | - | - | - | - | - |
3.9282 | 180 | 5.092 | 0.6605 | 0.6542 | 0.6464 | 0.6218 | 0.5771 |
- The bold row denotes the saved checkpoint.
Framework Versions
- Python: 3.11.11
- Sentence Transformers: 3.4.1
- Transformers: 4.51.3
- PyTorch: 2.6.0+cu124
- Accelerate: 1.5.2
- 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}
}
- Downloads last month
- 4
Model tree for namnguyenba2003/VietnamLegalText-SBERT-finetuned
Base model
keepitreal/vietnamese-sbertEvaluation results
- Cosine Accuracy@1 on dim 768self-reported0.543
- Cosine Accuracy@3 on dim 768self-reported0.584
- Cosine Accuracy@5 on dim 768self-reported0.690
- Cosine Accuracy@10 on dim 768self-reported0.785
- Cosine Precision@1 on dim 768self-reported0.543
- Cosine Precision@3 on dim 768self-reported0.512
- Cosine Precision@5 on dim 768self-reported0.374
- Cosine Precision@10 on dim 768self-reported0.223
- Cosine Recall@1 on dim 768self-reported0.202
- Cosine Recall@3 on dim 768self-reported0.544