SentenceTransformer based on BAAI/bge-m3

This is a sentence-transformers model finetuned from BAAI/bge-m3. It maps sentences & paragraphs to a 1024-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: BAAI/bge-m3
  • Maximum Sequence Length: 768 tokens
  • Output Dimensionality: 1024 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 768, 'do_lower_case': False, 'architecture': 'XLMRobertaModel'})
  (1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
  (2): Normalize()
)

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("sentence_transformers_model_id")
# Run inference
sentences = [
    'Khoản 6 Điều 28 quy định Viện kiểm sát nhân dân có quyền yêu cầu các cơ quan, cá nhân liên quan đến việc thi hành án thực hiện những việc cụ thể nào và thời hạn thực hiện các yêu cầu đó được quy định ra sao?',
    'Theo khoản 6 Điều 28 Luật Tổ chức Viện kiểm sát nhân dân, Viện kiểm sát nhân dân có quyền yêu cầu Tòa án, cơ quan thi hành án dân sự cùng cấp và cấp dưới, Chấp hành viên, cơ quan, tổ chức và cá nhân liên quan đến việc thi hành án thực hiện các việc sau đây:\n1. Ra quyết định thi hành án đúng quy định của pháp luật (điểm a).\n2. Thi hành bản án, quyết định theo quy định của pháp luật (điểm b).\n3. Tự kiểm tra việc thi hành án và thông báo kết quả cho Viện kiểm sát nhân dân (điểm c).\n4. Cung cấp hồ sơ, tài liệu, vật chứng có liên quan đến việc thi hành án (điểm d).\n\nVề thời hạn thực hiện, các yêu cầu quy định tại các điểm a, b và d khoản này phải được thực hiện ngay. Riêng yêu cầu quy định tại điểm c khoản này phải được thực hiện trong thời hạn 30 ngày, kể từ ngày nhận được yêu cầu.',
    'Theo điểm d khoản 1 Điều 31 của Luật Bảo hiểm xã hội số 41/2024/QH15, các đối tượng quy định tại các điểm g, h, m và n khoản 1 Điều 2 của Luật này được quyền lựa chọn tiền lương làm căn cứ đóng bảo hiểm xã hội bắt buộc.\n\n*   **Về mức tối thiểu và tối đa:** Mức tiền lương làm căn cứ đóng bảo hiểm xã hội bắt buộc thấp nhất phải bằng mức tham chiếu và cao nhất bằng 20 lần mức tham chiếu tại thời điểm đóng.\n*   **Về thời điểm được lựa chọn lại:** Người lao động được lựa chọn lại tiền lương làm căn cứ đóng bảo hiểm xã hội sau khi đã thực hiện đóng bảo hiểm xã hội theo tiền lương làm căn cứ đóng đã lựa chọn ít nhất 12 tháng. Điều này mang lại sự linh hoạt cho người lao động trong việc điều chỉnh mức đóng phù hợp với thu nhập và nhu cầu của họ, nhưng vẫn đảm bảo tính ổn định trong một khoảng thời gian nhất định.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[ 1.0000,  0.8652,  0.0063],
#         [ 0.8652,  1.0000, -0.0242],
#         [ 0.0063, -0.0242,  1.0000]])

Evaluation

Metrics

Information Retrieval

Metric Value
cosine_accuracy@1 0.948
cosine_accuracy@3 0.9841
cosine_accuracy@5 0.9921
cosine_accuracy@10 0.9963
cosine_precision@1 0.948
cosine_precision@3 0.328
cosine_precision@5 0.1984
cosine_precision@10 0.0996
cosine_recall@1 0.948
cosine_recall@3 0.9841
cosine_recall@5 0.9921
cosine_recall@10 0.9963
cosine_ndcg@10 0.9743
cosine_mrr@10 0.967
cosine_map@100 0.9672

Training Details

Training Dataset

Unnamed Dataset

  • Size: 34,065 training samples
  • Columns: sentence_0 and sentence_1
  • Approximate statistics based on the first 1000 samples:
    sentence_0 sentence_1
    type string string
    details
    • min: 10 tokens
    • mean: 50.74 tokens
    • max: 143 tokens
    • min: 25 tokens
    • mean: 202.65 tokens
    • max: 768 tokens
  • Samples:
    sentence_0 sentence_1
    Việc Điều 174 Luật Tố tụng hành chính cho phép kháng cáo đối với "quyết định tạm đình chỉ, đình chỉ việc giải quyết vụ án của Toà án cấp sơ thẩm" có ý nghĩa như thế nào? Điều 174 quy định rằng không chỉ bản án mà cả "quyết định tạm đình chỉ, đình chỉ việc giải quyết vụ án của Toà án cấp sơ thẩm" cũng là đối tượng có thể bị kháng cáo. Điều này có ý nghĩa quan trọng trong việc đảm bảo quyền lợi của đương sự, cho phép họ yêu cầu Toà án cấp trên trực tiếp xem xét lại các quyết định mang tính tố tụng quan trọng, có thể ảnh hưởng đến tiến trình hoặc kết quả cuối cùng của vụ án, ngay cả khi chưa có bản án cuối cùng. Mục đích là để đảm bảo tính đúng đắn và khách quan của quá trình tố tụng hành chính.
    Giả sử một trường hợp trẻ em được xin nhận làm con nuôi nước ngoài từ một cơ sở nuôi dưỡng. Hãy mô tả chi tiết quy trình tổ chức lễ giao nhận con nuôi theo Điều 37 của Luật này, bao gồm các thành phần bắt buộc phải có mặt tại buổi lễ và các tài liệu cần được lập, cũng như trách nhiệm của Sở Tư pháp sau khi hoàn tất việc giao nhận. Theo khoản 3 và khoản 4 Điều 37 của Luật Nuôi con nuôi, đối với trường hợp trẻ em được xin nhận làm con nuôi nước ngoài từ một cơ sở nuôi dưỡng, quy trình tổ chức lễ giao nhận và các trách nhiệm liên quan được thực hiện như sau: Sở Tư pháp có trách nhiệm đăng ký việc nuôi con nuôi theo quy định của pháp luật về đăng ký hộ tịch và tổ chức lễ giao nhận con nuôi tại trụ sở Sở Tư pháp. Các thành phần bắt buộc phải có mặt tại buổi lễ bao gồm: đại diện Sở Tư pháp, trẻ em được nhận làm con nuôi, cha mẹ nuôi và đại diện cơ sở nuôi dưỡng. Việc giao nhận con nuôi phải được lập thành biên bản, có chữ ký hoặc điểm chỉ của các bên và đại diện Sở Tư pháp. Sau khi giao nhận con nuôi, Sở Tư pháp có trách nhiệm gửi Bộ Tư pháp quyết định cho trẻ em làm con nuôi nước ngoài của Ủy ban nhân dân cấp tỉnh và biên bản giao nhận con nuôi, đồng thời gửi các tài liệu này cho Ủy ban nhân dân cấp xã nơi thường trú của trẻ em được cho làm con nuôi nước ngoài.
    Người sử dụng lao động phải đảm bảo quyền lợi gì cho người lao động? Người sử dụng lao động phải đảm bảo quyền lợi về tiền lương, tiền thưởng cho người lao động theo hợp đồng lao động.
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "gather_across_devices": false,
        "directions": [
            "query_to_doc"
        ],
        "partition_mode": "joint",
        "hardness_mode": null,
        "hardness_strength": 0.0
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • fp16: True
  • multi_dataset_batch_sampler: round_robin

All Hyperparameters

Click to expand
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 5e-05
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1
  • num_train_epochs: 3
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: None
  • warmup_ratio: None
  • warmup_steps: 0
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • enable_jit_checkpoint: False
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • use_cpu: False
  • seed: 42
  • data_seed: None
  • bf16: False
  • fp16: True
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • local_rank: -1
  • ddp_backend: None
  • debug: []
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: False
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch_fused
  • optim_args: None
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • 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
  • push_to_hub: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • hub_revision: None
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • auto_find_batch_size: False
  • full_determinism: False
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • include_num_input_tokens_seen: no
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: True
  • use_cache: False
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: round_robin
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss legal-eval_cosine_ndcg@10
-1 -1 - 0.9489
0.2347 500 0.0125 0.9692
0.4695 1000 0.0046 0.9651
0.7042 1500 0.0039 0.9632
0.9390 2000 0.0038 0.9664
1.0 2130 - 0.9681
1.1737 2500 0.0041 0.9691
1.4085 3000 0.0028 0.9700
1.6432 3500 0.0009 0.9699
1.8779 4000 0.0028 0.9680
2.0 4260 - 0.9712
2.1127 4500 0.0015 0.9718
2.3474 5000 0.0012 0.9722
2.5822 5500 0.0013 0.9740
2.8169 6000 0.0012 0.9743

Framework Versions

  • Python: 3.12.13
  • Sentence Transformers: 5.3.0
  • Transformers: 5.0.0
  • PyTorch: 2.11.0+cu130
  • Accelerate: 1.13.0
  • Datasets: 4.8.4
  • Tokenizers: 0.22.2

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",
}

MultipleNegativesRankingLoss

@misc{oord2019representationlearningcontrastivepredictive,
      title={Representation Learning with Contrastive Predictive Coding},
      author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
      year={2019},
      eprint={1807.03748},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/1807.03748},
}
Downloads last month
4
Safetensors
Model size
0.6B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for cyhapun/vn-legal-embedding-v1

Base model

BAAI/bge-m3
Finetuned
(447)
this model

Datasets used to train cyhapun/vn-legal-embedding-v1

Papers for cyhapun/vn-legal-embedding-v1

Evaluation results