Vietnamese_Embedding_finetuned

This is a sentence-transformers model finetuned from AITeamVN/Vietnamese_Embedding on the json dataset. 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: AITeamVN/Vietnamese_Embedding
  • Maximum Sequence Length: 8192 tokens
  • Output Dimensionality: 1024 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': 8192, 'do_lower_case': False}) with Transformer model: 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("namnguyenba2003/Vietnamese_Law_Embedding_finetuned")
# Run inference
sentences = [
    'Điều 9. Hồ sơ làm căn cứ để đánh giá đáp ứng GACP\n1. Đơn đề nghị đánh giá theo Mẫu số 1A Phụ lục I Thông tư này.\n2. Bản sao có xác nhận của đơn vị đối với Quyết định thành lập hoặc Giấy chứng nhận đăng ký kinh doanh hoặc Giấy phép đầu tư (đối với trường hợp quy định tại Điểm a Khoản 1 Điều 8 Thông tư này).\n3. Sơ đồ tổ chức và nhân sự của cơ sở (nêu rõ các bộ phận chủ chốt của cơ sở: họ tên, chức danh, trình độ chuyên môn và kinh nghiệm công tác của các trưởng bộ phận). Trường hợp cơ sở gồm nhiều hộ gia đình thì phải gửi kèm danh sách họ tên, địa chỉ, địa điểm, diện tích nuôi trồng, khai thác và hợp đồng thu mua giữa cơ sở với các hộ gia đình/đại diện các hộ gia đình.\n4. Sơ đồ phân lô khu vực nuôi trồng, khai thác và bản thuyết minh các khu vực nuôi trồng, khai thác, sơ chế, chế biến và bảo quản.\n5. Kế hoạch, nội dung và kết quả đào tạo về GACP cho nhân viên của cơ sở trong năm nộp hồ sơ.',
    'Theo quy định, cơ sở nuôi trồng, khai thác dược liệu phải cung cấp những thông tin gì về tổ chức và nhân sự của cơ sở để được đánh giá đáp ứng GACP?',
    'Nếu một đơn vị đã đưa tài sản cố định vào sử dụng nhưng chưa có quyết toán được phê duyệt, họ sẽ xác định nguyên giá tài sản như thế nào?',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]

Evaluation

Metrics

Information Retrieval

Metric Value
cosine_accuracy@1 0.7351
cosine_accuracy@3 0.7786
cosine_accuracy@5 0.8664
cosine_accuracy@10 0.9293
cosine_precision@1 0.7351
cosine_precision@3 0.6866
cosine_precision@5 0.484
cosine_precision@10 0.2677
cosine_recall@1 0.2735
cosine_recall@3 0.7252
cosine_recall@5 0.8354
cosine_recall@10 0.9222
cosine_ndcg@10 0.8336
cosine_mrr@10 0.781
cosine_map@100 0.8092

Information Retrieval

Metric Value
cosine_accuracy@1 0.7348
cosine_accuracy@3 0.7755
cosine_accuracy@5 0.866
cosine_accuracy@10 0.9278
cosine_precision@1 0.7348
cosine_precision@3 0.6841
cosine_precision@5 0.4834
cosine_precision@10 0.2673
cosine_recall@1 0.2739
cosine_recall@3 0.723
cosine_recall@5 0.8348
cosine_recall@10 0.9212
cosine_ndcg@10 0.8328
cosine_mrr@10 0.7801
cosine_map@100 0.8087

Information Retrieval

Metric Value
cosine_accuracy@1 0.725
cosine_accuracy@3 0.7701
cosine_accuracy@5 0.8598
cosine_accuracy@10 0.927
cosine_precision@1 0.725
cosine_precision@3 0.6782
cosine_precision@5 0.4795
cosine_precision@10 0.2668
cosine_recall@1 0.2696
cosine_recall@3 0.7167
cosine_recall@5 0.8281
cosine_recall@10 0.919
cosine_ndcg@10 0.827
cosine_mrr@10 0.7724
cosine_map@100 0.8016

Information Retrieval

Metric Value
cosine_accuracy@1 0.7177
cosine_accuracy@3 0.7604
cosine_accuracy@5 0.8505
cosine_accuracy@10 0.9223
cosine_precision@1 0.7177
cosine_precision@3 0.6703
cosine_precision@5 0.474
cosine_precision@10 0.2658
cosine_recall@1 0.2673
cosine_recall@3 0.7086
cosine_recall@5 0.8179
cosine_recall@10 0.9152
cosine_ndcg@10 0.8209
cosine_mrr@10 0.765
cosine_map@100 0.7947

Information Retrieval

Metric Value
cosine_accuracy@1 0.6901
cosine_accuracy@3 0.732
cosine_accuracy@5 0.8338
cosine_accuracy@10 0.9095
cosine_precision@1 0.6901
cosine_precision@3 0.6427
cosine_precision@5 0.4603
cosine_precision@10 0.2608
cosine_recall@1 0.2578
cosine_recall@3 0.6807
cosine_recall@5 0.7959
cosine_recall@10 0.8988
cosine_ndcg@10 0.7991
cosine_mrr@10 0.7398
cosine_map@100 0.7726

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: 110 tokens
    • mean: 204.39 tokens
    • max: 313 tokens
    • min: 19 tokens
    • mean: 36.62 tokens
    • max: 91 tokens
  • Samples:
    positive anchor
    Điều 7. Cấp chứng chỉ
    1. Người học được cơ sở đào tạo cấp Chứng chỉ đào tạo nghiệp vụ giám định pháp y hoặc giám định pháp y tâm thần khi đáp ứng đủ các yêu cầu sau đây:
    a) Không vi phạm các quy định của khóa đào tạo;
    b) Tham gia đầy đủ thời gian đào tạo và tích lũy đủ nội dung của chương trình đào tạo;
    c) Kết quả kiểm tra, đánh giá năng lực đạt yêu cầu của khóa đào tạo;
    d) Hoàn thành đầy đủ các nghĩa vụ của người học đối với cơ sở đào tạo.
    2. Mẫu Chứng chỉ đào tạo nghiệp vụ giám định pháp y hoặc nghiệp vụ giám định pháp y tâm thần được quy định tại Phụ lục ban hành kèm theo Thông tư này.
    3. Chứng chỉ đào tạo nghiệp vụ giám định pháp y và đào tạo nghiệp vụ giám định pháp y tâm thần là một trong những điều kiện để bổ nhiệm giám định viên tư pháp trong lĩnh vực pháp y và pháp y tâm thần theo quy định của Luật giám định tư pháp.
    Luật giám định tư pháp quy định những điều kiện gì để bổ nhiệm giám định viên tư pháp trong lĩnh vực pháp y và pháp y tâm thần?
    Điều 68. Nguyên tắc quản lý, sử dụng
    1. Người làm công tác thi hành án dân sự phải mặc trang phục có gắn bảng tên, phù hiệu, cấp hiệu thi hành án dân sự tại công sở và trong khi thi hành công vụ theo đúng chức vụ, chức danh đang đảm nhiệm.
    2. Việc cấp phát, quản lý, sử dụng trang phục, phù hiệu, cấp hiệu, Thẻ Chấp hành viên, Thẻ Thẩm tra viên thi hành án phải đúng mục đích, đúng đối tượng, đúng chế độ theo quy định của pháp luật.
    3. Nghiêm cấm việc sử dụng trang phục, phù hiệu, cấp hiệu, Thẻ Chấp hành viên, Thẻ Thẩm tra viên thi hành án để thực hiện các hành vi trái pháp luật.
    Việc sử dụng trang phục, phù hiệu, cấp hiệu, Thẻ Chấp hành viên, Thẻ Thẩm tra viên thi hành án để thực hiện các hành vi trái pháp luật bị nghiêm cấm như thế nào?
    Điều 8. Trách nhiệm của cơ sở cung cấp dịch vụ công tác xã hội
    1. Thường xuyên tổ chức giáo dục ý thức tuân thủ các quy định về tiêu chuẩn đạo đức nghề nghiệp đối với người làm công tác xã hội thuộc phạm vi quản lý.
    2. Phối hợp với các cơ sở đào tạo, cơ sở giáo dục nghề nghiệp để đào tạo, bồi dưỡng, nâng cao năng lực chuyên môn và đạo đức nghề nghiệp đối với người làm công tác xã hội.
    3. Công bố công khai tiêu chuẩn đạo đức nghề công tác xã hội để người làm công tác xã hội biết và nghiêm túc thực hiện.
    4. Tạo điều kiện thuận lợi và hỗ trợ để người làm công tác xã hội thực hiện tốt các tiêu chuẩn đạo đức nghề nghiệp trong quá trình thực hành công tác xã hội.
    5. Tiếp nhận, giải quyết các khiếu nại, tố cáo của đối tượng liên quan đến việc thực hiện đạo đức nghề nghiệp của người làm công tác xã hội theo thẩm quyền; xử lý nghiêm các hành vi vi phạm đạo đức nghề nghiệp thuộc phạm vi quản lý theo quy định của pháp luật.
    6. Thường xuyên kiểm tra, đánh giá kết quả việc thực hiện tiêu chuẩn đạo ...
    Các cơ sở cung cấp dịch vụ công tác xã hội phải làm gì để đảm bảo người làm công tác xã hội tuân thủ đạo đức nghề nghiệp?
  • Loss: MatryoshkaLoss with these parameters:
    {
        "loss": "MultipleNegativesRankingLoss",
        "matryoshka_dims": [
            1024,
            768,
            512,
            256,
            128
        ],
        "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: 64
  • per_device_eval_batch_size: 64
  • gradient_accumulation_steps: 8
  • learning_rate: 3e-05
  • num_train_epochs: 4
  • lr_scheduler_type: cosine
  • warmup_ratio: 0.1
  • fp16: True
  • tf32: True
  • dataloader_num_workers: 8
  • 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: 64
  • per_device_eval_batch_size: 64
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 8
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 3e-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: True
  • local_rank: 0
  • ddp_backend: None
  • tpu_num_cores: None
  • tpu_metrics_debug: False
  • debug: []
  • dataloader_drop_last: False
  • dataloader_num_workers: 8
  • 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: 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_1024_cosine_ndcg@10 dim_768_cosine_ndcg@10 dim_512_cosine_ndcg@10 dim_256_cosine_ndcg@10 dim_128_cosine_ndcg@10
0.2210 10 5.7308 - - - - -
0.4420 20 2.5237 - - - - -
0.6630 30 2.1593 - - - - -
0.8840 40 1.741 - - - - -
1.0 46 - 0.8236 0.8186 0.8173 0.8095 0.7822
1.0884 50 1.4595 - - - - -
1.3094 60 1.3117 - - - - -
1.5304 70 1.2627 - - - - -
1.7514 80 1.07 - - - - -
1.9724 90 1.03 - - - - -
2.0 92 - 0.8302 0.8300 0.8260 0.8177 0.7981
2.1768 100 0.8494 - - - - -
2.3978 110 1.0987 - - - - -
2.6188 120 0.8031 - - - - -
2.8398 130 0.8575 - - - - -
3.0 138 - 0.8323 0.8321 0.8259 0.8197 0.7984
3.0442 140 0.7405 - - - - -
3.2652 150 0.8546 - - - - -
3.4862 160 0.7658 - - - - -
3.7072 170 0.8311 - - - - -
3.9282 180 0.8719 - - - - -
4.0 184 - 0.8336 0.8328 0.827 0.8209 0.7991
  • The bold row denotes the saved checkpoint.

Framework Versions

  • Python: 3.11.11
  • Sentence Transformers: 4.1.0
  • Transformers: 4.52.3
  • PyTorch: 2.6.0+cu124
  • Accelerate: 1.7.0
  • 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
26
Safetensors
Model size
568M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for namnguyenba2003/Vietnamese_Law_Embedding_finetuned

Base model

BAAI/bge-m3
Finetuned
(3)
this model

Evaluation results