SentenceTransformer based on BAAI/bge-m3

This is a sentence-transformers model finetuned from BAAI/bge-m3. 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: BAAI/bge-m3
  • Maximum Sequence Length: 8192 tokens
  • Output Dimensionality: 1024 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 8192, 'do_lower_case': False, 'architecture': '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:

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("thaiquangphat/edukg_retrieval")
# Run inference
sentences = [
    'John thuộc về truyền_thống nào ?',
    'John thuộc học_viện nào ?',
    'Tại_sao Giăng không có truyền_thống ?',
]
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.8059, 0.0845],
#         [0.8059, 1.0000, 0.0498],
#         [0.0845, 0.0498, 1.0000]])

Evaluation

Metrics

Triplet

Metric Value
cosine_accuracy 0.935

Training Details

Training Dataset

Unnamed Dataset

  • Size: 8,352 training samples
  • Columns: anchor, positive, and negative
  • Approximate statistics based on the first 1000 samples:
    anchor positive negative
    type string string string
    details
    • min: 6 tokens
    • mean: 43.17 tokens
    • max: 257 tokens
    • min: 5 tokens
    • mean: 27.46 tokens
    • max: 202 tokens
    • min: 6 tokens
    • mean: 26.41 tokens
    • max: 205 tokens
  • Samples:
    anchor positive negative
    Trong thời_gian bình_luận , APHIS cũng tổ_chức bốn phiên điều_trần công_khai trong đó nhận được bình_luận bằng miệng và bằng văn_bản . APHIS đã tổ_chức hơn ba phiên điều_trần công_khai trong thời_gian bình_luận . APHIS đã tổ_chức hơn năm phiên điều_trần công_khai trong thời_gian bình_luận .
    Nếu họ có bất_kỳ manh_mối nào , hay 103 thì toàn_bộ việc sẽ vẫn nằm trong danh_mục tội_phạm chưa được phát_hiện ? Họ có thật_sự nghĩ rằng nó sẽ được giấu kín không ? Họ không nghĩ rằng nó sẽ không được phát_hiện , trên thực_tế họ biết nó sẽ được phát_hiện .
    Không , tôi nhớ khi tôi đang học đại_học tôi cũng không có thời_gian để làm những thứ đó . Khi tôi đang học đại_học , tôi cũng không có thời_gian để làm những việc như_vậy . Khi tôi đang học đại_học , tôi có nhiều thời_gian để làm những việc như_vậy .
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "gather_across_devices": false
    }
    

Evaluation Dataset

Unnamed Dataset

  • Size: 2,088 evaluation samples
  • Columns: anchor, positive, and negative
  • Approximate statistics based on the first 1000 samples:
    anchor positive negative
    type string string string
    details
    • min: 4 tokens
    • mean: 43.69 tokens
    • max: 263 tokens
    • min: 6 tokens
    • mean: 26.61 tokens
    • max: 160 tokens
    • min: 6 tokens
    • mean: 26.41 tokens
    • max: 197 tokens
  • Samples:
    anchor positive negative
    Năm 1982 và 1983 , de Kooning , không bị phân tâm bởi một thế_giới bên ngoài mà anh ta không_thể hiểu được nữa , vẽ với tốc_độ chưa từng có , hoàn_thành gần một bức tranh một tuần . De Kooning vẽ khoảng 50 bức tranh mỗi năm trong năm 1982 và 1983 . De Kooning không vẽ bất_kỳ bức tranh nào trong những năm 1980 .
    Uh một_chút ừ ừ Chỉ một_chút thôi . Chắc_chắn là rất nhiều .
    Bạn có sử_dụng rất nhiều thẻ tín_dụng hoặc tài_khoản thanh_toán của bạn khi bạn ra ngoài và mua những thứ Bạn có thường dùng thẻ tín_dụng để mua_sắm hay bạn thích sử_dụng tài_khoản thanh_toán của mình ? Tôi không muốn biết nếu bạn sử_dụng thẻ tín_dụng hoặc tài_khoản thanh_toán của bạn .
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "gather_across_devices": false
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 4
  • per_device_eval_batch_size: 4
  • learning_rate: 1e-05
  • num_train_epochs: 5
  • warmup_ratio: 0.1
  • fp16: True
  • load_best_model_at_end: 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: 4
  • per_device_eval_batch_size: 4
  • 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: 1e-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
  • 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: True
  • 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}
  • 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}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • 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
  • hub_revision: None
  • 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: no
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: True
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss Validation Loss all-nli-dev_cosine_accuracy
0.0005 1 0.5395 - -
0.0479 100 0.3501 - -
0.0958 200 0.3403 - -
0.1437 300 0.2836 - -
0.1916 400 0.2915 - -
0.2395 500 0.3073 - -
0.2874 600 0.3386 - -
0.3352 700 0.273 - -
0.3831 800 0.271 - -
0.4310 900 0.264 - -
0.4789 1000 0.3396 0.2744 0.9200
0.5268 1100 0.2826 - -
0.5747 1200 0.2761 - -
0.6226 1300 0.2394 - -
0.6705 1400 0.2768 - -
0.7184 1500 0.2574 - -
0.7663 1600 0.2854 - -
0.8142 1700 0.3389 - -
0.8621 1800 0.3172 - -
0.9100 1900 0.3292 - -
0.9579 2000 0.21 0.3338 0.9290
1.0057 2100 0.2504 - -
1.0536 2200 0.1347 - -
1.1015 2300 0.1377 - -
1.1494 2400 0.1718 - -
1.1973 2500 0.1623 - -
1.2452 2600 0.1232 - -
1.2931 2700 0.1777 - -
1.3410 2800 0.1279 - -
1.3889 2900 0.1391 - -
1.4368 3000 0.1176 0.3022 0.9290
1.4847 3100 0.136 - -
1.5326 3200 0.1753 - -
1.5805 3300 0.1605 - -
1.6284 3400 0.1475 - -
1.6762 3500 0.159 - -
1.7241 3600 0.1709 - -
1.7720 3700 0.131 - -
1.8199 3800 0.1507 - -
1.8678 3900 0.0933 - -
1.9157 4000 0.1253 0.2923 0.9300
1.9636 4100 0.1527 - -
2.0115 4200 0.1645 - -
2.0594 4300 0.0759 - -
2.1073 4400 0.0309 - -
2.1552 4500 0.0389 - -
2.2031 4600 0.0233 - -
2.2510 4700 0.0364 - -
2.2989 4800 0.0423 - -
2.3467 4900 0.0506 - -
2.3946 5000 0.0766 0.3016 0.9350

Framework Versions

  • Python: 3.12.9
  • Sentence Transformers: 5.2.0
  • Transformers: 4.57.3
  • PyTorch: 2.7.1+cu118
  • Accelerate: 1.12.0
  • Datasets: 4.4.1
  • Tokenizers: 0.22.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
17
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 thaiquangphat/edukg_retrieval

Base model

BAAI/bge-m3
Finetuned
(464)
this model

Papers for thaiquangphat/edukg_retrieval

Evaluation results