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({})
)pip install -U sentence-transformers1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("sentence_transformers_model_id")
5# Run inference
6queries = [
7 'mắm chưng trứng vịt muối',
8]
9documents = [
10 '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Đ',
11 "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Đ",
12 '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Đ',
13]
14query_embeddings = model.encode_query(queries)
15document_embeddings = model.encode_document(documents)
16print(query_embeddings.shape, document_embeddings.shape)
17# [1, 1024] [3, 1024]
18
19# Get the similarity scores for the embeddings
20similarities = model.similarity(query_embeddings, document_embeddings)
21print(similarities)
22# tensor([[0.8572, 0.1578, 0.2286]])validInformationRetrievalEvaluator| 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 |
query and positive| query | positive | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details |
|
|
| 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Đ |
MultipleNegativesRankingLoss with these parameters:
1{
2 "scale": 20.0,
3 "similarity_fct": "cos_sim",
4 "gather_across_devices": false,
5 "directions": [
6 "query_to_doc"
7 ],
8 "partition_mode": "joint",
9 "hardness_mode": null,
10 "hardness_strength": 0.0
11}per_device_train_batch_size: 2num_train_epochs: 2learning_rate: 2e-05gradient_accumulation_steps: 4fp16: Trueload_best_model_at_end: Trueper_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: {}| 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 |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{oord2019representationlearningcontrastivepredictive,
2 title={Representation Learning with Contrastive Predictive Coding},
3 author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
4 year={2019},
5 eprint={1807.03748},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG},
8 url={https://arxiv.org/abs/1807.03748},
9}