SentenceTransformer based on truro7/vn-law-embedding

This is a sentence-transformers model finetuned from truro7/vn-law-embedding. 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: truro7/vn-law-embedding
  • Maximum Sequence Length: 512 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: XLMRobertaModel 
  (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})
  (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("phi010402/finetune-alqac-question-generation-3")
# Run inference
sentences = [
    'Người có khó khăn trong nhận thức, làm chủ hành vi phải tự thực hiện yêu cầu cung cấp thông tin, đúng hay sai?',
    'Chủ thể thực hiện quyền tiếp cận thông tin\n\n1. Công dân thực hiện quyền tiếp cận thông tin theo quy định của Luật này.\n\n2. Người mất năng lực hành vi dân sự thực hiện yêu cầu cung cấp thông tin thông qua người đại diện theo pháp luật.\n\nNgười có khó khăn trong nhận thức, làm chủ hành vi thực hiện yêu cầu cung cấp thông tin thông qua người giám hộ.\n\n3. Người dưới 18 tuổi yêu cầu cung cấp thông tin thông qua người đại diện theo pháp luật, trừ trường hợp luật về trẻ em và luật khác có quy định khác.',
    'Tình nghĩa vợ chồng\n1. Vợ chồng có nghĩa vụ thương yêu, chung thủy, tôn trọng, quan tâm, chăm sóc, giúp đỡ nhau; cùng nhau chia sẻ, thực hiện các công việc trong gia đình.\n\n2. Vợ chồng có nghĩa vụ sống chung với nhau, trừ trường hợp vợ chồng có thỏa thuận khác hoặc do yêu cầu của nghề nghiệp, công tác, học tập, tham gia các hoạt động chính trị, kinh tế, văn hóa, xã hội và lý do chính đáng khác.',
]
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 Value
cosine_accuracy@1 1.0
cosine_accuracy@2 1.0
cosine_accuracy@3 1.0
cosine_precision@1 1.0
cosine_precision@2 0.5
cosine_precision@3 0.3333
cosine_recall@1 1.0
cosine_recall@2 1.0
cosine_recall@3 1.0
cosine_ndcg@10 1.0
cosine_mrr@10 1.0
cosine_map@100 1.0

Information Retrieval

Metric Value
cosine_accuracy@1 1.0
cosine_accuracy@2 1.0
cosine_accuracy@3 1.0
cosine_precision@1 1.0
cosine_precision@2 0.5
cosine_precision@3 0.3333
cosine_recall@1 1.0
cosine_recall@2 1.0
cosine_recall@3 1.0
cosine_ndcg@10 1.0
cosine_mrr@10 1.0
cosine_map@100 1.0

Training Details

Training Dataset

Unnamed Dataset

  • Size: 740 training samples
  • Columns: anchor and positive
  • Approximate statistics based on the first 740 samples:
    anchor positive
    type string string
    details
    • min: 8 tokens
    • mean: 33.01 tokens
    • max: 100 tokens
    • min: 19 tokens
    • mean: 262.36 tokens
    • max: 512 tokens
  • Samples:
    anchor positive
    Độ tuổi con có thể tự mình quản lý tài sản riêng là khi nào ? Quản lý tài sản riêng của con
    1. Con từ đủ 15 tuổi trở lên có thể tự mình quản lý tài sản riêng hoặc nhờ cha mẹ quản lý.

    2. Tài sản riêng của con dưới 15 tuổi, con mất năng lực hành vi dân sự do cha mẹ quản lý. Cha mẹ có thể ủy quyền cho người khác quản lý tài sản riêng của con. Tài sản riêng của con do cha mẹ hoặc người khác quản lý được giao lại cho con khi con từ đủ 15 tuổi trở lên hoặc khi con khôi phục năng lực hành vi dân sự đầy đủ, trừ trường hợp cha mẹ và con có thỏa thuận khác.

    3. Cha mẹ không quản lý tài sản riêng của con trong trường hợp con đang được người khác giám hộ theo quy định của Bộ luật dân sự; người tặng cho tài sản hoặc để lại tài sản thừa kế theo di chúc cho người con đã chỉ định người khác quản lý tài sản đó hoặc trường hợp khác theo quy định của pháp luật.

    4. Trong trường hợp cha mẹ đang quản lý tài sản riêng của con chưa thành niên, con đã thành niên mất năng lực hành vi dân sự mà con được giao cho người khác giám hộ thì tài sản riêng của con được giao lại ...
    Trong phần quyết định phải ghi rõ các căn cứ pháp luật, quyết định của Hội đồng xét xử về từng vấn đề phải giải quyết trong vụ án, về áp dụng biện pháp khẩn cấp tạm thời, về án phí sơ thẩm, phúc thẩm, chi phí tố tụng (nếu có), đúng hay sai? Bản án phúc thẩm

    1. Hội đồng xét xử phúc thẩm ra bản án phúc thẩm nhân danh nước Cộng hoà xã hội chủ nghĩa Việt Nam.

    2. Bản án phúc thẩm gồm có:

    a) Phần mở đầu;

    b) Phần nội dung vụ án, kháng cáo, kháng nghị và nhận định;

    c) Phần quyết định.

    3. Trong phần mở đầu phải ghi rõ tên của Tòa án xét xử phúc thẩm; số và ngày thụ lý vụ án; số bản án và ngày tuyên án; họ, tên của các thành viên Hội đồng xét xử, Thư ký phiên tòa, Kiểm sát viên, người giám định, người phiên dịch; tên, địa chỉ của người khởi kiện, người bị kiện, người có quyền lợi, nghĩa vụ liên quan, cơ quan, tổ chức khởi kiện; người đại diện hợp pháp, người bảo vệ quyền và lợi ích hợp pháp của họ; người kháng cáo, Viện kiểm sát kháng nghị; xét xử công khai hoặc xét xử kín; thời gian và địa điểm xét xử.

    4. Trong phần nội dung vụ án, kháng cáo, kháng nghị và nhận định phải tóm tắt nội dung vụ án, quyết định của Tòa án cấp sơ thẩm; nội dung kháng cáo, kháng nghị.

    Tòa án phải căn cứ vào kết quả tranh tụng, các chứng cứ đã được...
    Thông tin nào sẽ gây nguy hại đến lợi ích của Nhà nước nếu để công dân tiếp cận? Thông tin công dân không được tiếp cận

    1. Thông tin thuộc bí mật nhà nước, bao gồm những thông tin có nội dung quan trọng thuộc lĩnh vực chính trị, quốc phòng, an ninh quốc gia, đối ngoại, kinh tế, khoa học, công nghệ và các lĩnh vực khác theo quy định của luật.

    Khi thông tin thuộc bí mật nhà nước được giải mật thì công dân được tiếp cận theo quy định của Luật này.

    2. Thông tin mà nếu để tiếp cận sẽ gây nguy hại đến lợi ích của Nhà nước, ảnh hưởng xấu đến quốc phòng, an ninh quốc gia, quan hệ quốc tế, trật tự, an toàn xã hội, đạo đức xã hội, sức khỏe của cộng đồng; gây nguy hại đến tính mạng, cuộc sống hoặc tài sản của người khác; thông tin thuộc bí mật công tác; thông tin về cuộc họp nội bộ của cơ quan nhà nước; tài liệu do cơ quan nhà nước soạn thảo cho công việc nội bộ.
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • num_train_epochs: 5
  • warmup_ratio: 0.1
  • bf16: True
  • batch_sampler: no_duplicates

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • 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: 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.0
  • num_train_epochs: 5
  • max_steps: -1
  • lr_scheduler_type: linear
  • 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: True
  • fp16: False
  • 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: False
  • 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
  • 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: 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 cosine_ndcg@10
-1 -1 - 1.0
0.0213 1 0.0168 -
2.1277 100 0.0592 1.0
4.2553 200 0.0162 1.0

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

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
278M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for phi010402/finetune-alqac-question-generation-3

Finetuned
(6)
this model

Evaluation results