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

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

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 and anchor
  • 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: epoch
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • gradient_accumulation_steps: 16
  • learning_rate: 2e-05
  • num_train_epochs: 4
  • lr_scheduler_type: cosine
  • warmup_ratio: 0.1
  • fp16: True
  • dataloader_num_workers: 4
  • load_best_model_at_end: True
  • optim: adamw_torch_fused
  • ddp_find_unused_parameters: False
  • 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
  • torch_empty_cache_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: 4
  • 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: 4
  • 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}
  • tp_size: 0
  • 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: False
  • 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: None
  • hub_always_push: False
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • include_for_metrics: []
  • 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
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: False
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_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
Safetensors
Model size
135M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for namnguyenba2003/VietnamLegalText-SBERT-finetuned

Finetuned
(22)
this model

Evaluation results