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
  • Maximum Sequence Length: 256 tokens
  • Output Dimensionality: 1024 dimensions
  • Similarity Function: Cosine Similarity
  • Supported Modality: Text

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:

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("sentence_transformers_model_id")
# Run inference
sentences = [
    'Giấy khám sức_khỏe đi du_học có giá_trị bao_nhiêu tháng ?',
    'positive: Điều 8 . Cấp Giấy khám sức_khỏe : 4 . Trường_hợp người được KSK có xét_nghiệm HIV dương_tính thì việc thông_báo kết_quả xét_nghiệm này phải theo quy_định của pháp_luật về phòng , chống HIV / AIDS.',
    'negative: Điều 3 . Giấy khám sức_khỏe : 4 . Giấy khám sức_khỏe chỉ có giá_trị khi : Ghi theo đúng mẫu quy_định ; viết bằng bút mực hoặc bút_bi màu xanh hoặc đen ; chữ_viết rõ_ràng , không tẩy xóa , không viết tắt ; ghi đầy_đủ các nội_dung trong Giấy khám sức_khỏe ; kết_luận của Hội_đồng khám sức_khỏe tuyển_chọn công_dân phục_vụ có thời_hạn trong CAND có giá_trị trong 06 ( sáu ) tháng kể từ ngày khám , nếu không có những diễn_biến đặc_biệt về sức_khỏe .',
]
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.5422, 0.0081],
#         [0.5422, 1.0000, 0.1163],
#         [0.0081, 0.1163, 1.0000]])

Training Details

Training Dataset

Unnamed Dataset

  • Size: 3,257 training samples
  • Columns: anchor, positive, and negative
  • Approximate statistics based on the first 100 samples:
    anchor positive negative
    type string string string
    modality text text text
    details
    • min: 16 tokens
    • mean: 39.72 tokens
    • max: 66 tokens
    • min: 37 tokens
    • mean: 163.3 tokens
    • max: 256 tokens
    • min: 36 tokens
    • mean: 163.17 tokens
    • max: 256 tokens
  • Samples:
    anchor positive negative
    Công_an xã xử_phạt lỗi không mang bằng lái_xe có đúng không ? positive: Điều 7 . Nhiệm_vụ của lực_lượng Cảnh_sát khác và Công_an xã : 1 . Bố_trí_lực_lượng tham_gia tuần_tra , kiểm_soát trật_tự , an_toàn giao_thông theo kế_hoạch . negative: Điều 4 . Quản_lý , sử_dụng biểu_mẫu sử_dụng trong xử_phạt vi_phạm hành_chính lĩnh_vực giao_thông đường_bộ , đường_sắt : 4 . Trường_hợp người vi_phạm hành_chính có giấy_phép lái_xe tích_hợp của giấy_phép lái_xe có thời_hạn và giấy_phép lái_xe không thời_hạn , bị áp_dụng hình_thức xử_phạt tước quyền sử_dụng giấy_phép lái_xe theo quy_định tại Nghị_định của Chính_phủ quy_định xử_phạt vi_phạm hành_chính trong lĩnh_vực giao_thông đường_bộ và đường_sắt , người có thẩm_quyền quyết_định xử_phạt phải ghi rõ trong quyết_định , xử_phạt vi_phạm hành_chính các hạng xe được phép điều_khiển theo giấy_phép lái_xe và áp_dụng hình_thức xử_phạt tước quyền sử_dụng giấy_phép lái_xe có thời_hạn hoặc giấy_phép lái_xe không thời_hạn đối_với loại xe đã sử_dụng khi thực_hiện_hành_vi vi_phạm ( xe ô_tô hoặc máy_kéo hoặc xe mô_tô ) . Người vi_phạm hành_chính được quyền điều_khiển những loại xe còn lại được ghi trong giấy_phép lái_xe .
    Phải thực_hiện thao_tác nạp mẫu vào bình chứa và xử_lý mẫu sơ_bộ bằng hóa_chất như thế_nào ? positive: Điều 11 . Tiến_hành lấy , bảo_quản mẫu : 2 . Thao_tác lấy mẫu
    a ) Việc lấy mẫu phải có_mặt chủ nguồn thải hoặc người đại_diện của cơ_sở có nguồn thải . Trường_hợp chủ nguồn thải hoặc người đại_diện vắng_mặt hoặc không hợp_tác thì trưởng_đoàn công_tác có trách_nhiệm lập biên_bản về sự vắng_mặt hoặc không hợp_tác và phải có người chứng_kiến việc lấy mẫu ;
    b ) Trước khi lấy mẫu phải cho chủ nguồn thải hoặc người đại_diện của cơ_sở có nguồn thải hoặc người chứng_kiến thấy dụng_cụ lấy và chứa mẫu đảm_bảo sạch , các dụng_cụ và hóa_chất đáp_ứng các tiêu_chuẩn quốc_gia về lấy mẫu . Chụp ảnh hoặc quay_phim về điểm thu mẫu và hoạt_động thu mẫu ;
    c ) Sử_dụng dụng_cụ lấy mẫu để múc nước_thải vào dụng_cụ chứa trung_gian ( xô bằng nhựa sạch có dung_tích từ 10 đến 15 lít ) . Nếu chiều sâu dòng nước_thải nhỏ hơn 01 mét , độ sâu lấy mẫu nước_thải nằm ở 1 / 3 chiều sâu dòng nước_thải tính từ bề_mặt_nước . Nếu chiều sâu dòng nước_thải lớn hơn 01 mét thì lấy ở độ sâu từ 20cm đến 50cm tính ...
    negative: Điều 12 . Nhãn mẫu : 2 . Dán nhãn lên bình_chứa mẫu : nhãn phải bám chắc vào bình chứa , không để bị thấm nước , phải dùng băng_dính trong suốt rộng bản ( bề rộng ≥ 4cm ) dán đè kín lên_mặt nhãn và bao tròn hơn một vòng_quanh bình chứa để cố_định chặt và kín toàn_bộ tem nhãn vào thành bình ( nhãn mẫu có_thể được ghi và dán lên bình chứa trước khi lấy mẫu ) .
    Trình_tự đánh_giá chất_lượng hàng năm đối_với Kiểm_soát viên được quy_định như thế_nào ? positive: Điều 13 . Trình_tự , thủ_tục đánh_giá : 1 . Đối_với người quản_lý doanh_nghiệp nhà_nước :
    a ) Người quản_lý doanh_nghiệp nhà_nước viết bản tự nhận_xét , đánh_giá theo nội_dung , tiêu_chí đánh_giá và tự nhận mức_độ xếp loại chất_lượng ;
    b ) Hội_đồng thành_viên họp nhận_xét , đánh_giá đối_với người quản_lý doanh_nghiệp . Cuộc họp đánh_giá , xếp loại chất_lượng được ghi thành biên_bản , trong đó nêu rõ thành_phần tham_dự , các ý_kiến tham_gia ;
    c ) Lấy ý_kiến bằng văn_bản về đánh_giá , xếp loại chất_lượng người quản_lý doanh_nghiệp của cấp ủy cùng cấp ;
    d ) Trên_cơ_sở ý_kiến của cấp ủy cùng cấp , Hội_đồng thành_viên hoặc Chủ_tịch công_ty xem_xét , quyết_định đánh_giá , xếp loại chất_lượng đối_với người quản_lý doanh_nghiệp theo thẩm_quyền hoặc báo_cáo kết_quả đánh_giá , xếp loại chất_lượng Chủ_tịch Hội_đồng thành_viên , thành_viên Hội_đồng thành_viên , Chủ_tịch công_ty gửi cơ_quan đại_diện chủ sở_hữu xem_xét , quyết_định .
    negative: Điều 8 . Xếp loại chất_lượng : Người quản_lý doanh_nghiệp nhà_nước , Kiểm_soát viên , người đại_diện phần vốn nhà_nước được đánh_giá , xếp loại chất_lượng hàng năm theo 4 mức_độ : Hoàn_thành xuất_sắc nhiệm_vụ , hoàn_thành tốt nhiệm_vụ , hoàn_thành nhiệm_vụ , không hoàn_thành nhiệm_vụ .
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "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: 32
  • warmup_steps: 100
  • gradient_accumulation_steps: 2
  • bf16: True
  • gradient_checkpointing: True
  • gradient_checkpointing_kwargs: {'use_reentrant': False}

All Hyperparameters

Click to expand
  • per_device_train_batch_size: 32
  • num_train_epochs: 3
  • max_steps: -1
  • learning_rate: 5e-05
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: None
  • warmup_steps: 100
  • optim: adamw_torch_fused
  • optim_args: None
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • optim_target_modules: None
  • gradient_accumulation_steps: 2
  • 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: True
  • gradient_checkpointing_kwargs: {'use_reentrant': False}
  • 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: None
  • trackio_bucket_id: None
  • trackio_static_space_id: None
  • 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: False
  • ignore_data_skip: False
  • restore_callback_states_from_checkpoint: False
  • full_determinism: False
  • seed: 42
  • data_seed: None
  • use_cpu: False
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • parallelism_config: None
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • 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_static_graph: None
  • ddp_backend: None
  • ddp_timeout: 1800
  • fsdp: None
  • fsdp_config: None
  • deepspeed: None
  • debug: []
  • skip_memory_metrics: True
  • do_predict: False
  • resume_from_checkpoint: None
  • warmup_ratio: None
  • local_rank: -1
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss
0.9804 50 0.7859
1.9608 100 0.2034
2.9412 150 0.1142

Training Time

  • Training: 4.1 minutes

Framework Versions

  • Python: 3.12.13
  • Sentence Transformers: 5.6.0
  • Transformers: 5.12.1
  • PyTorch: 2.12.0+cu130
  • Accelerate: 1.14.0
  • Datasets: 5.0.0
  • Tokenizers: 0.22.2

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{oord2019representationlearningcontrastivepredictive,
      title={Representation Learning with Contrastive Predictive Coding},
      author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
      year={2019},
      eprint={1807.03748},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/1807.03748},
}
Downloads last month
22
Safetensors
Model size
0.6B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for check2207/CS221_vietnamese_embedding

Base model

BAAI/bge-m3
Finetuned
(10)
this model

Papers for check2207/CS221_vietnamese_embedding