CoolFace
Modelpublic

batmangiaicuuthegioi/bi-encoders-embeddings

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

SentenceTransformer based on AITeamVN/Vietnamese_Embedding

This is a sentence-transformers model finetuned from AITeamVN/Vietnamese_Embedding on the zalo-legal-triplets 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 <!-- at revision 9f671cc30908f1d851787efcc05b7d15bad8b615 -->
  • —Maximum Sequence Length: 8192 tokens
  • —Output Dimensionality: 1024 dimensions
  • —Similarity Function: Cosine Similarity
  • —Training Dataset:
  • —zalo-legal-triplets <!-- - Language: Unknown --> <!-- - License: Unknown -->

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:

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("batmangiaicuuthegioi/bi-encoders-embeddings")
# Run inference
sentences = [
    'Quy định về trao đổi dữ liệu thi hành án hình sự được quy định như thế nào?',
    'Điều 12. Trao đổi dữ liệu giữa cơ sở dữ liệu về thi hành án hình sự và các cơ sở dữ liệu khác liên quan.  khoản 1. việc trao đổi dữ liệu giữa cơ sở dữ liệu về thi hành án hình sự và các cơ sở dữ liệu khác liên quan phải thực hiện theo quy định của pháp luật và quy định của bộ công an, bộ quốc phòng. ',
    'Điều 13. Quy định về bàn giao giữa các kíp trực. sau mỗi đợt kiểm tra, các kíp tuần tra, canh gác đê phải ghi chép đầy đủ tình hình diễn biến và hư hỏng đê điều vào sổ nhật ký tuần tra, canh gác theo mẫu quy định và bàn giao đầy đủ cho kíp sau. người thay mặt kíp giao và nhận phải ký và ghi rõ họ tên, ngày giờ vào sổ. sau mỗi ngày đội trưởng và cán bộ chuyên trách quản lý đê điều ký xác nhận tình hình trong ngày để theo dõi và làm cơ sở cho việc chi trả thù lao theo quy định.',
]
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]

<!--

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

Triplet
MetricValue
cosine_accuracy1.0
Triplet
MetricValue
cosine_accuracy1.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

zalo-legal-triplets
  • —Dataset: zalo-legal-triplets at 15e0566
  • —Size: 37,059 training samples
  • —Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
  • —Approximate statistics based on the first 1000 samples: | | anchor | positive | negative | |:--------|:----------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------| | type | string | string | string | | details | <ul><li>min: 7 tokens</li><li>mean: 22.08 tokens</li><li>max: 47 tokens</li></ul> | <ul><li>min: 13 tokens</li><li>mean: 82.98 tokens</li><li>max: 344 tokens</li></ul> | <ul><li>min: 25 tokens</li><li>mean: 76.65 tokens</li><li>max: 220 tokens</li></ul> |
  • —Samples: | anchor | positive | negative | |:------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Mức phạt đối với hành vi điều khiển xe máy dẫn, dắt theo súc vật ?</code> | <code>Điều 63. Xử phạt nhân viên đường sắt trực tiếp phục vụ chạy tàu (trừ lái tàu và phụ lái tàu) vi phạm quy định về nồng độ cồn hoặc sử dụng các chất kích thích khác mà pháp luật cấm sử dụng. điểm c) khi làm nhiệm vụ mà trong cơ thể có chất kích thích khác mà pháp luật cấm sử dụng.</code> | <code>Điều 4. Nhiệm vụ của lực lượng tuần tra, canh gác đê. khoản 5. đeo phù hiệu khi làm nhiệm vụ.</code> | | <code>Theo quy định pháp luật, dẫn xuất của các loài động vật, thực vật là gì?</code> | <code>Điều 3. Giải thích từ ngữ. khoản 26. mẫu vật săn bắt là mẫu vật có được từ các hoạt động săn bắt hợp pháp. </code> | <code>Điều 17. Trách nhiệm của Sở Nông nghiệp và Phát triển nông thôn. khoản 3. khi có báo động lũ từ cấp i trở lên, sở nông nghiệp và phát triển nông thôn phải chỉ đạo, tổ chức kiểm tra, đôn đốc công tác tuần tra, canh gác ở các tuyến đê.</code> | | <code>Mục tiêu của giáo dục nghề nghiệp từ tháng 7/2020 được quy định như thế nào?</code> | <code>Điều 36. Mục tiêu của giáo dục nghề nghiệp. giáo dục nghề nghiệp nhằm đào tạo nhân lực trực tiếp cho sản xuất, kinh doanh và dịch vụ, có năng lực hành nghề tương ứng với trình độ đào tạo; có đạo đức, sức khỏe; có trách nhiệm nghề nghiệp; có khả năng sáng tạo, thích ứng với môi trường hội nhập quốc tế; bảo đảm nâng cao năng suất, chất lượng lao động; tạo điều kiện cho người học sau khi hoàn thành khóa học có khả năng tìm việc làm, tự tạo việc làm hoặc học trình độ cao hơn.</code> | <code>Điều 3. Tiêu chuẩn của các thành viên thuộc lực lượng tuần tra, canh gác đê. khoản 2. có tinh thần trách nhiệm, chịu đựng gian khổ, khắc phục khó khăn, quen sông nước và biết bơi, có kiến thức, kinh nghiệm hộ đê, phòng, chống lụt, bão.</code> |
  • —Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Evaluation Dataset

zalo-legal-triplets
  • —Dataset: zalo-legal-triplets at 15e0566
  • —Size: 37,059 evaluation samples
  • —Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
  • —Approximate statistics based on the first 1000 samples: | | anchor | positive | negative | |:--------|:---------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------| | type | string | string | string | | details | <ul><li>min: 7 tokens</li><li>mean: 21.7 tokens</li><li>max: 47 tokens</li></ul> | <ul><li>min: 17 tokens</li><li>mean: 79.22 tokens</li><li>max: 327 tokens</li></ul> | <ul><li>min: 25 tokens</li><li>mean: 74.1 tokens</li><li>max: 220 tokens</li></ul> |
  • —Samples: | anchor | positive | negative | |:------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Nghiên cứu y sinh học liên quan đến con người là gì?</code> | <code>Điều 31. Thẩm định nghiên cứu theo quy trình rút gọn. khoản 4. ngoại trừ trường hợp họp khẩn cấp, tất cả tài liệu đề nghị xem xét phải được gửi tới thành viên hội đồng đạo đức được phân công nhận xét trước ít nhất 05 ngày làm việc so với ngày yêu cầu gửi lại phiếu nhận xét, đánh giá nghiên cứu. </code> | <code>Điều 10. Nội dung tuần tra canh gác cống qua đê. khoản 2. người tuần tra, canh gác phải kiểm tra kỹ phần tiếp giáp giữa thân cống, tường cánh gà của cống với đê; cánh cống, bộ phận đóng mở cánh cống, cửa cống, thân cống và khu vực thượng, hạ lưu cống để phát hiện kịp thời những sự cố xảy ra. </code> | | <code>Hồ sơ cấp lại Giấy chứng nhận đủ điều kiện hoạt động dịch vụ giám định công nghệ bao gồm những giấy tờ gì?</code> | <code>Điều 38. Hồ sơ cấp Giấy chứng nhận đủ điều kiện hoạt động dịch vụ giám định công nghệ. điểm e) mẫu chứng thư giám định của tổ chức. </code> | <code>Điều 6. Trang bị dụng cụ, sổ sách. khoản 7. việc giao nhận các dụng cụ và sổ sách trên đây phải được lập biên bản để quản lý, theo dõi.</code> | | <code>Chạy quá tốc độ bao nhiêu km thì xe ô tô sẽ bị giam bằng?</code> | <code>Điều 55. Xử phạt các hành vi vi phạm quy định quản lý, bảo trì kết cấu hạ tầng đường sắt. điểm b) thực hiện hành vi quy định tại điểm c khoản 3 điều này buộc phải tổ chức sửa chữa, bổ sung, gia cố, thay thế các hư hỏng kết cấu hạ tầng đường sắt để bảo đảm chất lượng theo công lệnh tốc độ, công lệnh tải trọng đã công bố.</code> | <code>Điều 9. Nội dung tuần tra, canh gác đê. điểm d) mỗi kíp tuần tra phải kiểm tra vượt quá phạm vi phụ trách về hai phía, mỗi phía 50m. đối với những khu vực đã từng xảy ra sự cố hư hỏng, phải kiểm tra quan sát rộng hơn để phát hiện sự cố. </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: 4
  • —per_device_eval_batch_size: 2
  • —num_train_epochs: 1
  • —warmup_ratio: 0.1
  • —fp16: True
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: 4
  • —per_device_eval_batch_size: 2
  • —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: 1
  • —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: 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: 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}
  • —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
  • —dispatch_batches: None
  • —split_batches: 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: batch_sampler
  • —multi_dataset_batch_sampler: proportional

</details>

Training Logs

EpochStepTraining LossValidation Losszalo_legal_cosine_accuracy
0.308420000.29780.07780.9996
0.616740000.17350.05221.0
0.925160000.11480.03301.0
1.06486--1.0

Framework Versions

  • —Python: 3.10.12
  • —Sentence Transformers: 3.3.1
  • —Transformers: 4.47.0
  • —PyTorch: 2.5.1+cu121
  • —Accelerate: 1.2.1
  • —Datasets: 3.3.1
  • —Tokenizers: 0.21.0

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. -->