SentenceTransformer based on intfloat/multilingual-e5-base
This is a sentence-transformers model finetuned from intfloat/multilingual-e5-base on the triplet and mnrl datasets. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: intfloat/multilingual-e5-base
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Supported Modality: Text
- Training Datasets:
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': 768, 'pooling_mode': 'mean', '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
model = SentenceTransformer("sentence_transformers_model_id")
sentences = [
'query: chống nhìn trộm iphone 17 pro max',
'passage: Miếng dán kính cường lực chống nhìn trộm iPhone 17 Pro Max UniQ | Giữ trọn sự riêng tư với miếng dán kính cường lực chống nhìn trộm dành riêng cho iPhone 17 Pro Max từ thương hiệu UniQ. Sản phẩm chính hãng không chỉ bảo vệ màn hình khỏi các tác động ngoại lực như va đập hay trầy xước, mà còn ngăn chặn hiệu quả tình trạng nhìn trộm từ các góc nhìn khác. Trải nghiệm | Danh mục: Miếng dán UniQ | Thương hiệu: UniQ | Giá: 441,000 VNĐ',
'passage: Miếng dán kính cường lực chống nhìn trộm iPhone 17 Mipow BJ710-BK | Bảo vệ tối ưu cho iPhone 17 của bạn với miếng dán kính cường lực chống nhìn trộm Mipow BJ716-BK. Sản phẩm chính hãng từ thương hiệu Mipow, mang đến khả năng chống nhìn trộm hiệu quả, giữ cho thông tin riêng tư của bạn an toàn khỏi những ánh mắt tò mò. Miếng dán được chế tác từ kính cường lực cao cấp | Danh mục: Miếng dán Mipow | Thương hiệu: Mipow | Giá: 405,000 VNĐ',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
similarities = model.similarity(embeddings, embeddings)
print(similarities)
Evaluation
Metrics
Triplet
| Metric |
Value |
| cosine_accuracy |
0.8745 |
Training Details
Training Datasets
triplet
mnrl
- Dataset: mnrl
- Size: 16,565 training samples
- Columns:
anchor and positive
- Approximate statistics based on the first 100 samples:
|
anchor |
positive |
| type |
string |
string |
| modality |
text |
text |
| details |
- min: 7 tokens
- mean: 9.73 tokens
- max: 14 tokens
|
- min: 114 tokens
- mean: 135.71 tokens
- max: 182 tokens
|
- Samples:
| anchor |
positive |
query: sách khoa học dễ hiểu cho trẻ |
passage: 10 Vạn Câu Hỏi Vì Sao - Khoa Học Dễ Hiểu (Tái bản năm 2024) | Bộ sách "10 Vạn Câu Hỏi Vì Sao - Khoa Học Dễ Hiểu" (Tái bản 2024) là cẩm nang không thể thiếu giúp các bậc phụ huynh giải đáp vô vàn thắc mắc về khoa học cho trẻ. Bao gồm nhiều chủ đề phong phú như Khoa Học Dễ Hiểu, Tự Nhiên Kỳ Thú, Khám Phá Trái Đất và Vũ Trụ, sách sử dụng câu hỏi và câu trả lời xá | Danh mục: Kiến Thức Bách Khoa | Thương hiệu: NXB Hồng Đức | Giá: 5,700,000 VNĐ |
query: áo ba lỗ nam thể thao |
passage: Áo ba lỗ active nam có hình in dáng thể thao | Áo ba lỗ active nam của CANIFA là lựa chọn lý tưởng cho những ai yêu thích sự thoải mái và năng động. Với phom regular, áo được làm từ 76% nylon và 24% spandex, mang lại cảm giác thoáng mát và dễ chịu trong mọi hoàn cảnh. Thiết kế có hình in thể thao tạo điểm nhấn cá tính, phù hợp cho các buổi tập l | Danh mục: Canifa Active | Thương hiệu: CANIFA | Giá: 149,000 VNĐ |
query: ca nấu mì |
passage: Ca Nấu Mì Đa Năng No Brand MCM-V2201 1.2L | Ca nấu mì đa năng No Brand MCM-V2201 1.2L là giải pháp nấu nướng nhanh gọn và tiện lợi. Dung tích 1.2L lý tưởng cho việc chuẩn bị các bữa ăn cá nhân hoặc gia đình nhỏ. Sản phẩm được chế tạo từ các vật liệu an toàn và bền bỉ như Polypropylene, kim loại (Thép không gỉ) và thủy tinh chịu nhiệt. Với côn | Danh mục: Nhà Cửa - Đời Sống | Thương hiệu: Trung Quốc | Giá: 439,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
}
Evaluation Dataset
triplet
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 32
num_train_epochs: 2
learning_rate: 1e-05
warmup_steps: 0.1
gradient_accumulation_steps: 2
fp16: True
log_on_each_node: False
per_device_eval_batch_size: 64
load_best_model_at_end: True
data_seed: 42
All Hyperparameters
Click to expand
per_device_train_batch_size: 32
num_train_epochs: 2
max_steps: -1
learning_rate: 1e-05
lr_scheduler_type: linear
lr_scheduler_kwargs: None
warmup_steps: 0.1
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: False
fp16: True
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: False
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: 64
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: 42
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 |
triplet loss |
valid_triplet_cosine_accuracy |
| 0.1855 |
100 |
0.8153 |
- |
- |
| 0.3711 |
200 |
0.3884 |
- |
- |
| 0.5566 |
300 |
0.3521 |
- |
- |
| 0.7421 |
400 |
0.3551 |
- |
- |
| 0.9276 |
500 |
0.3423 |
- |
- |
| 1.0 |
539 |
- |
0.3041 |
0.8670 |
| 1.1132 |
600 |
0.3333 |
- |
- |
| 1.2987 |
700 |
0.3108 |
- |
- |
| 1.4842 |
800 |
0.3037 |
- |
- |
| 1.6698 |
900 |
0.3015 |
- |
- |
| 1.8553 |
1000 |
0.2977 |
- |
- |
| 2.0 |
1078 |
- |
0.2872 |
0.8745 |
- The bold row denotes the saved checkpoint.
Training Time
Framework Versions
- Python: 3.12.13
- Sentence Transformers: 5.6.0
- Transformers: 5.12.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",
}
TripletLoss
@misc{hermans2017defense,
title={In Defense of the Triplet Loss for Person Re-Identification},
author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
year={2017},
eprint={1703.07737},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
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},
}