CoolFace
Modelpublic

phi010402/finetune-alqac-question-generation-3

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes13downloads
Model Card

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 <!-- at revision 96774e495327a2eabfff428e26f9c963bda0dfa6 -->
  • Maximum Sequence Length: 512 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

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:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
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]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Information Retrieval
MetricValue
cosine_accuracy@11.0
cosine_accuracy@21.0
cosine_accuracy@31.0
cosine_precision@11.0
cosine_precision@20.5
cosine_precision@30.3333
cosine_recall@11.0
cosine_recall@21.0
cosine_recall@31.0
cosine_ndcg@101.0
cosine_mrr@101.0
cosine_map@1001.0
Information Retrieval
MetricValue
cosine_accuracy@11.0
cosine_accuracy@21.0
cosine_accuracy@31.0
cosine_precision@11.0
cosine_precision@20.5
cosine_precision@30.3333
cosine_recall@11.0
cosine_recall@21.0
cosine_recall@31.0
cosine_ndcg@101.0
cosine_mrr@101.0
cosine_map@1001.0

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

Unnamed Dataset
  • Size: 740 training samples
  • Columns: <code>anchor</code> and <code>positive</code>
  • Approximate statistics based on the first 740 samples: | | anchor | positive | |:--------|:-----------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 8 tokens</li><li>mean: 33.01 tokens</li><li>max: 100 tokens</li></ul> | <ul><li>min: 19 tokens</li><li>mean: 262.36 tokens</li><li>max: 512 tokens</li></ul> |
  • Samples: | anchor | positive | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Độ tuổi con có thể tự mình quản lý tài sản riêng là khi nào ?</code> | <code>Quản lý tài sản riêng của con<br>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ý.<br><br>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.<br><br>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.<br><br>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 ...</code> | | <code>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?</code> | <code>Bản án phúc thẩm<br><br>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.<br><br>2. Bản án phúc thẩm gồm có:<br><br>a) Phần mở đầu;<br><br>b) Phần nội dung vụ án, kháng cáo, kháng nghị và nhận định;<br><br>c) Phần quyết định.<br><br>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ử.<br><br>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ị.<br><br>Tòa án phải căn cứ vào kết quả tranh tụng, các chứng cứ đã được...</code> | | <code>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?</code> | <code>Thông tin công dân không được tiếp cận<br><br>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.<br><br>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.<br><br>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ộ.</code> |
  • Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "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

<details><summary>Click to expand</summary>

  • 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: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • tp_size: 0
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': 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

</details>

Training Logs

EpochStepTraining Losscosine_ndcg@10
-1-1-1.0
0.021310.0168-
2.12771000.05921.0
4.25532000.01621.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
bibtex
@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
bibtex
@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}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->