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 retrieval.
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
- Supported Modality: Text
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
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
queries = [
'mắm chưng trứng vịt muối',
]
documents = [
'Mắm Chưng Trứng Vịt Muối Vissan Hộp 150G | Mắm Chưng Trứng Vịt Muối Vissan hộp 150G là sự kết hợp hài hòa giữa nạc heo, mỡ heo, mắm cá sặc đậm đà và trứng vịt muối béo ngậy. Sản phẩm được bổ sung thêm hành, tỏi, ớt, tiêu tạo nên hương vị thơm ngon, hấp dẫn. Với thành phần chất lượng, an toàn cho sức khỏe, Mắm Chưng Vissan mang đến bữa ăn tiệ | Danh mục: Thực Phẩm Đóng Hộp | Thương hiệu: Việt Nam | Giá: 29,900 VNĐ',
"Pizza 4P's Half Gà Teriyaki Hộp 150G | Thưởng thức hương vị Pizza 4P's Gà Teriyaki thơm ngon, đậm đà chuẩn Nhật Bản ngay tại nhà với hộp 150G tiện lợi. Vỏ bánh được làm từ bột mì mềm mịn, phủ lớp sốt Teriyaki đặc trưng, thịt gà mềm ngọt, phô mai béo ngậy quyện cùng rong biển và lá tía tô thanh mát. Sản phẩm được chế biến sẵn, chỉ cần vài | Danh mục: Thực Phẩm Chế Biến Sẵn | Thương hiệu: Việt Nam | Giá: 77,300 VNĐ",
'Nước Súc Miệng No Brand Strong Coolmint Hương Bạc Hà Chai 800Ml | Nước Súc Miệng No Brand Strong Coolmint Hương Bạc Hà Chai 800Ml mang đến giải pháp chăm sóc răng miệng toàn diện, cho hơi thở thơm mát suốt cả ngày. Sản phẩm chứa các thành phần như Ethanol, Glycerin, Xylitol, Sodium Fluoride, cùng chiết xuất từ các loại thảo mộc tự nhiên như đinh hương, bạch chỉ, h | Danh mục: Chăm Sóc Cá Nhân | Thương hiệu: Hàn Quốc | Giá: 95,000 VNĐ',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 1024] [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.8572, 0.1578, 0.2286]])
Evaluation
Metrics
Information Retrieval
- Dataset:
valid - Evaluated with InformationRetrievalEvaluator
| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.4029 |
| cosine_accuracy@3 | 0.5904 |
| cosine_accuracy@5 | 0.6775 |
| cosine_accuracy@10 | 0.7672 |
| cosine_precision@1 | 0.4029 |
| cosine_precision@3 | 0.1968 |
| cosine_precision@5 | 0.1355 |
| cosine_precision@10 | 0.0767 |
| cosine_recall@1 | 0.4029 |
| cosine_recall@3 | 0.5904 |
| cosine_recall@5 | 0.6775 |
| cosine_recall@10 | 0.7672 |
| cosine_ndcg@10 | 0.5768 |
| cosine_mrr@10 | 0.5166 |
| cosine_map@100 | 0.5247 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 20,441 training samples
- Columns: query and positive
- Approximate statistics based on the first 100 samples:
query positive type string string modality text text details min: 7 tokensmean: 10.26 tokensmax: 16 tokens min: 115 tokensmean: 138.31 tokensmax: 157 tokens - Samples:
query positive dinh dưỡng cho trẻ từ 1 đến 10 tuổi Combo 2 Thực phẩm bổ sung dinh dưỡng dành cho trẻ từ 1 đến 10 tuổi Kid Essentials Nutritionally Complete vị vani | Thực phẩm bổ sung dinh dưỡng Kid Essentials vị vani là giải pháp dinh dưỡng y học toàn diện, được thiết kế đặc biệt cho trẻ em từ 1 đến 10 tuổi biếng ăn. Sản phẩm cung cấp đầy đủ các dưỡng chất cần thiết, hỗ trợ trẻ phát triển khỏe mạnh và cải thiện tình trạng biếng ăn. Với hương vani thơm ngon, dễ | Danh mục: Sữa bột cao cấp | Thương hiệu: Kid Essentials | Giá: 765,000 VNĐ thực phẩm dinh dưỡng y học ensure gold Thực phẩm dinh dưỡng y học Ensure Gold 800g (bao bì cũ 850g, giao bao bì ngẫu nhiên) | Ensure Gold 800g là thực phẩm dinh dưỡng y học tiên tiến, bổ sung HMB giúp duy trì và phát triển khối cơ, cùng hệ dưỡng chất YBG tăng cường miễn dịch hiệu quả. Sản phẩm giàu Omega-3 và 12 loại vitamin thiết yếu, hỗ trợ cải thiện sức khỏe toàn diện chỉ sau 8 tuần sử dụng. Ensure Gold là lựa chọn lý t | Danh mục: Sữa bột cao cấp | Thương hiệu: Ensure | Giá: 935,000 VNĐ sữa abbott grow 2+ cho bé Sữa Abbott Grow 2+ 1,6kg (trên 2 tuổi) (tên cũ: Abbott Grow 4 1,7kg, giao bao bì ngẫu nhiên) | Sữa Abbott Grow 2+ 1,6kg là lựa chọn tuyệt vời cho bé trên 2 tuổi, hỗ trợ phát triển chiều cao vượt trội. Sản phẩm được thiết kế đặc biệt với công thức tiên tiến, cung cấp đầy đủ dưỡng chất cần thiết cho sự phát triển thể chất và trí tuệ của trẻ. Với hương vị thơm ngon, dễ uống, Abbott Grow 2+ sẽ là | Danh mục: Sữa bột cao cấp | Thương hiệu: Abbott Grow | Giá: 625,000 VNĐ - 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: 2num_train_epochs: 2learning_rate: 2e-05gradient_accumulation_steps: 4fp16: Trueload_best_model_at_end: True
All Hyperparameters
per_device_train_batch_size: 2num_train_epochs: 2max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 4average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Truebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 8prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Trueignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: Nonefsdp_config: Nonedeepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}
Training Logs
| Epoch | Step | Training Loss | valid_cosine_ndcg@10 |
|---|---|---|---|
| 0.0391 | 100 | 0.0033 | - |
| 0.0783 | 200 | 0.0048 | - |
| 0.1174 | 300 | 0.0046 | - |
| 0.1565 | 400 | 0.0053 | - |
| 0.1957 | 500 | 0.0014 | - |
| 0.2348 | 600 | 0.0047 | - |
| 0.2739 | 700 | 0.0052 | - |
| 0.3131 | 800 | 0.0108 | - |
| 0.3522 | 900 | 0.0021 | - |
| 0.3914 | 1000 | 0.0019 | - |
| 0.4305 | 1100 | 0.0024 | - |
| 0.4696 | 1200 | 0.0065 | - |
| 0.5088 | 1300 | 0.0032 | - |
| 0.5479 | 1400 | 0.0013 | - |
| 0.5870 | 1500 | 0.0015 | - |
| 0.6262 | 1600 | 0.0081 | - |
| 0.6653 | 1700 | 0.0035 | - |
| 0.7044 | 1800 | 0.0031 | - |
| 0.7436 | 1900 | 0.0020 | - |
| 0.7827 | 2000 | 0.0023 | - |
| 0.8218 | 2100 | 0.0017 | - |
| 0.8610 | 2200 | 0.0012 | - |
| 0.9001 | 2300 | 0.0088 | - |
| 0.9392 | 2400 | 0.0009 | - |
| 0.9784 | 2500 | 0.0037 | - |
| 1.0 | 2556 | - | 0.5521 |
| 1.0172 | 2600 | 0.0025 | - |
| 1.0564 | 2700 | 0.0047 | - |
| 1.0955 | 2800 | 0.0012 | - |
| 1.1346 | 2900 | 0.0044 | - |
| 1.1738 | 3000 | 0.0021 | - |
| 1.2129 | 3100 | 0.0032 | - |
| 1.2520 | 3200 | 0.0054 | - |
| 1.2912 | 3300 | 0.0097 | - |
| 1.3303 | 3400 | 0.0016 | - |
| 1.3694 | 3500 | 0.0037 | - |
| 1.4086 | 3600 | 0.0008 | - |
| 1.4477 | 3700 | 0.0024 | - |
| 1.4868 | 3800 | 0.0005 | - |
| 1.5260 | 3900 | 0.0034 | - |
| 1.5651 | 4000 | 0.0004 | - |
| 1.6042 | 4100 | 0.0027 | - |
| 1.6434 | 4200 | 0.0078 | - |
| 1.6825 | 4300 | 0.0003 | - |
| 1.7217 | 4400 | 0.0008 | - |
| 1.7608 | 4500 | 0.0029 | - |
| 1.7999 | 4600 | 0.0070 | - |
| 1.8391 | 4700 | 0.0002 | - |
| 1.8782 | 4800 | 0.0007 | - |
| 1.9173 | 4900 | 0.0071 | - |
| 1.9565 | 5000 | 0.0022 | - |
| 1.9956 | 5100 | 0.0055 | - |
| 2.0 | 5112 | - | 0.5768 |
Training Time
- Training: 1.5 hours
Framework Versions
- Python: 3.12.13
- Sentence Transformers: 5.6.0
- Transformers: 5.13.1
- PyTorch: 2.11.0+cu128
- Accelerate: 1.14.0
- Datasets: 4.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},
}