CoolFace
Modelpublic

YuITC/vietnamese-embedding-vn-legal

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes344downloads
Model Card

SentenceTransformer based on AITeamVN/Vietnamese_Embedding

This is a sentence-transformers model finetuned from AITeamVN/Vietnamese_Embedding. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for retrieval.

Model Details

Model Description

  • —Model Type: Sentence Transformer
  • —Base model: AITeamVN/Vietnamese_Embedding <!-- at revision dea33aa1ab339f38d66ae0a40e6c40e0a9249568 -->
  • —Maximum Sequence Length: 512 tokens
  • —Output Dimensionality: 1024 dimensions
  • —Similarity Function: Cosine Similarity
  • —Supported Modality: Text <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'XLMRobertaModel'})
  (1): Pooling({'embedding_dimension': 1024, 'pooling_mode': 'cls', '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("sentence_transformers_model_id")
# Run inference
sentences = [
    'Khi mở sổ, ghi sổ, khóa sổ và lưu trữ sổ kế toán thì doanh nghiệp siêu nhỏ phải thực hiện theo những quy định nào?',
    'Sổ kế toán\n1. Nội dung sổ kế toán, hệ thống sổ kế toán, việc mở sổ, ghi sổ, khóa sổ, lưu trữ sổ kế toán và sửa chữa sổ kế toán tại doanh nghiệp siêu nhỏ được thực hiện theo quy định tại Điều 24, Điều 25, Điều 26, 27 Luật kế toán và hướng dẫn cụ thể tại Thông tư này.',
    '"Điều 147. Thế chấp dự án đầu tư xây dựng nhà ở và thế chấp nhà ở hình thành trong tương lai\n1. Chủ đầu tư dự án xây dựng nhà ở được thế chấp dự án hoặc nhà ở xây dựng trong dự án tại tổ chức tín dụng đang hoạt động tại Việt Nam để vay vốn cho việc đầu tư dự án hoặc xây dựng nhà ở đó; trường hợp chủ đầu tư đã thế chấp nhà ở mà có nhu cầu huy động vốn góp để phân chia nhà ở theo quy định của pháp luật về nhà ở hoặc có nhu cầu bán, cho thuê mua nhà ở đó thì phải giải chấp nhà ở này trước khi ký hợp đồng huy động vốn góp, hợp đồng mua bán, thuê mua nhà ở với khách hàng, trừ trường hợp được bên góp vốn, bên mua, thuê mua nhà ở và bên nhận thế chấp đồng ý.\nViệc xác định nhà ở đã được giải chấp trước khi ký hợp đồng huy động vốn góp, hợp đồng mua bán, thuê mua nhà ở với khách hàng theo quy định tại khoản này được nêu rõ trong văn bản thông báo nhà ở đủ điều kiện được bán của cơ quan quản lý nhà ở cấp tỉnh nơi có nhà ở.\n2. Tổ chức, cá nhân xây dựng nhà ở hình thành trong tương lai trên thửa đất ở hợp pháp của mình; tổ chức, cá nhân mua nhà ở hình thành trong tương lai trong dự án đầu tư xây dựng nhà ở của chủ đầu tư được thế chấp nhà ở này tại tổ chức tín dụng đang hoạt động tại Việt Nam để vay vốn phục vụ cho xây dựng nhà ở hoặc để mua chính 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.8255, -0.0291],
#         [ 0.8255,  1.0000, -0.0851],
#         [-0.0291, -0.0851,  1.0000]])

<!--

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@10.906
cosine_accuracy@30.976
cosine_accuracy@50.99
cosine_accuracy@100.996
cosine_precision@10.906
cosine_precision@30.3493
cosine_precision@50.214
cosine_precision@100.1082
cosine_recall@10.8642
cosine_recall@30.9677
cosine_recall@50.9845
cosine_recall@100.9932
cosine_ndcg@10.906
cosine_ndcg@30.9414
cosine_ndcg@50.9489
cosine_ndcg@100.952
cosine_mrr@10.906
cosine_mrr@30.9385
cosine_mrr@50.9417
cosine_mrr@100.9426
cosine_map@1000.9362

<!--

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: 105,683 training samples
  • —Columns: <code>anchor</code> and <code>positive</code>
  • —Approximate statistics based on the first 1000 samples: | | anchor | positive | |:--------|:----------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 9 tokens</li><li>mean: 23.79 tokens</li><li>max: 47 tokens</li></ul> | <ul><li>min: 56 tokens</li><li>mean: 263.51 tokens</li><li>max: 512 tokens</li></ul> |
  • —Samples: | anchor | positive | |:------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Văn phòng Chính phủ là cơ quan thực hiện nhiệm vụ phát ngôn của Chính phủ có đúng không?</code> | <code>Nhiệm vụ và quyền hạn ...
  • —Về cung cấp thông tin cho công chúng a) Cung cấp thông tin cho công chúng về các hoạt động chủ yếu, những quyết định quan trọng trong lãnh đạo, chỉ đạo, điều hành của Chính phủ, Thủ tướng Chính phủ, những sự kiện chính trị, kinh tế, xã hội nổi bật và các thông tin khác theo quy định của pháp luật và chỉ đạo của Thủ tướng Chính phủ; b) Thực hiện nhiệm vụ phát ngôn của Chính phủ, Thủ tướng Chính phủ; c) Chủ trì, phối hợp với các bộ, ngành, Ủy ban nhân dân cấp tỉnh, các cơ quan, tổ chức liên quan tổ chức họp báo Chính phủ, cung cấp thông tin cho báo chí định kỳ, đột xuất; tham mưu trả lời phỏng vấn báo chí của Thủ tướng Chính phủ; thực hiện thông cáo báo chí theo quy định của pháp luật; d) Yêu cầu các cơ quan liên quan hiệu chỉnh, cơ quan báo chí cải chính, hiệu chỉnh nội dung thông tin không chính xác, chưa phù hợp với yêu cầu lãnh đạo, chỉ đạo, điều hành của Chính phủ, Thủ tướng Chính phủ theo quy định của pháp luật; đ) Thực hiện quản lý nhà nước về công báo...</code> | | <code>Đỗ xe trên dốc cầu Rạch Chiếc mà không chèn bánh thì bị xử phạt bao nhiêu tiền?</code> | <code>"Điều 5. Xử phạt người điều khiển xe ô tô và các loại xe tương tự xe ô tô vi phạm quy tắc giao thông đường bộ ....
  • —Phạt tiền từ 400.000 đồng đến 600.000 đồng đối với người điều khiển xe thực hiện một trong các hành vi vi phạm sau đây: a) Chuyển làn đường không đúng nơi cho phép hoặc không có tín hiệu báo trước, trừ các hành vi vi phạm quy định tại điểm g khoản 5 Điều này; b) Điều khiển xe chạy tốc độ thấp hơn các xe khác đi cùng chiều mà không đi về bên phải phần đường xe chạy, trừ trường hợp các xe khác đi cùng chiều chạy quá tốc độ quy định; c) Chở người trên buồng lái quá số lượng quy định; d) Không tuân thủ các quy định về nhường đường tại nơi đường bộ giao nhau, trừ các hành vi vi phạm quy định tại điểm m, điểm n khoản 3 Điều này; đ) Điều khiển xe có liên quan trực tiếp đến vụ tai nạn giao thông mà không dừng lại, không giữ nguyên hiện trường, không tham gia cấp cứu người bị nạn, trừ hành vi vi phạm quy định tại điểm b khoản 8 Điều này; e) Xe được quyền ưu tiên lắp đặt, sử dụng...</code> | | <code>Phẫu thuật kết hợp xương gãy khung chậu chỉ định trong những trường hợp nào?</code> | <code>PHẪU THUẬT KHX GÃY KHUNG CHẬU - TRẬT KHỚP MU<br>...<br>II. CHỈ ĐỊNH<br>Chỉ định mổ kết hợp xương khi gãy khung chậu toác khớp mu loại B, C theo phân loại của AO.<br>- Loại B: Gãy không hoàn toàn khung sau khung chậu, tổn thương không vững, xoay quanh trục ngang. Di lệch xoay mở quyển sách khi bị cơ chế ép trước sau.<br>- Loại C: Gãy hoàn toàn cung sau, tổn thương mất vững cả chiều ngang và chiều dọc.<br>...</code> |
  • —Loss: <code>CachedMultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim",
      "mini_batch_size": 64,
      "gather_across_devices": false,
      "directions": [
          "query_to_doc"
      ],
      "partition_mode": "joint",
      "hardness_mode": null,
      "hardness_strength": 0.0
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —per_device_train_batch_size: 64
  • —num_train_epochs: 1
  • —learning_rate: 1e-05
  • —lr_scheduler_type: cosinewithrestarts
  • —warmup_steps: 100
  • —weight_decay: 0.01
  • —bf16: True
  • —load_best_model_at_end: True
  • —dataloader_num_workers: 16
  • —dataloader_persistent_workers: True
  • —batch_sampler: no_duplicates
All Hyperparameters

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

  • —per_device_train_batch_size: 64
  • —num_train_epochs: 1
  • —max_steps: -1
  • —learning_rate: 1e-05
  • —lr_scheduler_type: cosinewithrestarts
  • —lr_scheduler_kwargs: None
  • —warmup_steps: 100
  • —optim: adamw_torch
  • —optim_args: None
  • —weight_decay: 0.01
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —optim_target_modules: None
  • —gradient_accumulation_steps: 1
  • —average_tokens_across_devices: True
  • —max_grad_norm: 1.0
  • —label_smoothing_factor: 0.0
  • —bf16: True
  • —fp16: False
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —gradient_checkpointing: False
  • —gradient_checkpointing_kwargs: None
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —use_liger_kernel: False
  • —liger_kernel_config: None
  • —use_cache: False
  • —neftune_noise_alpha: None
  • —torch_empty_cache_steps: None
  • —auto_find_batch_size: False
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —include_num_input_tokens_seen: no
  • —log_level: passive
  • —log_level_replica: warning
  • —disable_tqdm: False
  • —project: huggingface
  • —trackio_space_id: trackio
  • —per_device_eval_batch_size: 8
  • —prediction_loss_only: True
  • —eval_on_start: False
  • —eval_do_concat_batches: True
  • —eval_use_gather_object: False
  • —eval_accumulation_steps: None
  • —include_for_metrics: []
  • —batch_eval_metrics: False
  • —save_only_model: False
  • —save_on_each_node: False
  • —enable_jit_checkpoint: False
  • —push_to_hub: False
  • —hub_private_repo: None
  • —hub_model_id: None
  • —hub_strategy: every_save
  • —hub_always_push: False
  • —hub_revision: None
  • —load_best_model_at_end: True
  • —ignore_data_skip: False
  • —restore_callback_states_from_checkpoint: False
  • —full_determinism: False
  • —seed: 42
  • —data_seed: None
  • —use_cpu: False
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —parallelism_config: None
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 16
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: True
  • —dataloader_prefetch_factor: None
  • —remove_unused_columns: True
  • —label_names: None
  • —train_sampling_strategy: random
  • —length_column_name: length
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —ddp_backend: None
  • —ddp_timeout: 1800
  • —fsdp: []
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —deepspeed: None
  • —debug: []
  • —skip_memory_metrics: True
  • —do_predict: False
  • —resume_from_checkpoint: None
  • —warmup_ratio: None
  • —local_rank: -1
  • —prompts: None
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional
  • —router_mapping: {}
  • —learning_rate_mapping: {}

</details>

Training Logs

EpochStepTraining Lossval_ir_cosine_ndcg@10
00-0.8719
0.0303500.1413-
0.06051000.0658-
0.09081500.0637-
0.12112000.0550-
0.15132500.0666-
0.18163000.0702-
0.21193500.0538-
0.24214000.0541-
0.27244500.0506-
0.30275000.05200.9434
0.33295500.0491-
0.36326000.0520-
0.39356500.0512-
0.42377000.0505-
0.45407500.0505-
0.48438000.0448-
0.51458500.0529-
0.54489000.0455-
0.57519500.0450-
0.605310000.04290.9514
0.635610500.0376-
0.665911000.0434-
0.696111500.0451-
0.726412000.0427-
0.756712500.0448-
0.786913000.0442-
0.817213500.0426-
0.847514000.0518-
0.877714500.0372-
0.908015000.04730.9520
0.938315500.0350-
0.968516000.0426-
0.998816500.0378-
1.01652-0.952
  • —The bold row denotes the saved checkpoint.

Training Time

  • —Training: 38.5 minutes
  • —Evaluation: 1.3 minutes
  • —Total: 39.8 minutes

Framework Versions

  • —Python: 3.11.10
  • —Sentence Transformers: 5.4.1
  • —Transformers: 5.5.4
  • —PyTorch: 2.4.1+cu124
  • —Accelerate: 1.13.0
  • —Datasets: 4.8.4
  • —Tokenizers: 0.22.2

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",
}
CachedMultipleNegativesRankingLoss
bibtex
@misc{gao2021scaling,
    title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup},
    author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan},
    year={2021},
    eprint={2101.06983},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}

<!--

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