Chanisorn's picture
End of training
7299179 verified
metadata
language:
  - th
license: apache-2.0
tags:
  - sentence-transformers
  - sentence-similarity
  - feature-extraction
  - generated_from_trainer
  - dataset_size:1572
  - loss:MultipleNegativesRankingLoss
  - thai
  - semantic-search
  - food
  - ingredients
  - retrieval
base_model: sentence-transformers/paraphrase-multilingual-mpnet-base-v2
widget:
  - source_sentence: >-
      หมูสับ,  พริกเขียว, กระเทียม,  ใบกะเพรา,  ซีอิ๊วขาว,  น้ำปลา,  พริกไทย |
      แคลอรี่:แคลกลาง, โปรตีน:โปรตีนน้อย, ไขมัน:ไขมันน้อย, คาร์บ:คาร์บกลาง
    sentences:
      - แกงส้มมะละกอปลากระป๋อง
      - เทคนิค กะเพราหมูสับ แบบแห้ง อร่อยกว่าร้าน
      - ไอศกรีมโยเกิร์ตเยลลี่ปีโป้
  - source_sentence: >-
      คอหมู, ไข่เป็ด, พริกจินดา, แคร์รอต, กระเทียม, กะหล่ำปลี,
      บะหมี่กึ่งสำเร็จรูป, ผงหมัก, น้ำมันหอย, บะหมี่กึ่งสำเร็จรูป |
      แคลอรี่:แคลกลาง, โปรตีน:โปรตีนกลาง, ไขมัน:ไขมันกลาง, คาร์บ:คาร์บน้อย
    sentences:
      - ผัดมาม่าคอหมูย่างไข่ดาว
      - ขนมจีนน้ำยา สูตรเด็ด
      - ยำวุ้นเส้นเครื่องล้น
  - source_sentence: >-
      หมูสับ,  หนำเลี๊ยบ,  ซีอิ๊วขาว,  น้ำมันหอย,  พริกไทย,  กระเทียม,  น้ำมัน, 
      ผงปรุงรส, น้ำตาลทราย | แคลอรี่:แคลมาก, โปรตีน:โปรตีนน้อย, ไขมัน:ไขมันสูง,
      คาร์บ:คาร์บกลาง
    sentences:
      - หมูสับผัดหนำเลี๊ยบ
      - ผัดฟักทองใส่ไข่ นิ่ม ฟิน
      - แกงส้มปลาทู (แกงส้มใต้)
  - source_sentence: >-
      มัน,  ปลาทู,  น้ำพริก,  น้ำเปล่า,  น้ำปลา,  น้ำตาลปี๊บ,  น้ำมะขามเปียก, 
      ส้มแขก,  น้ำมะนาว, กะปิ | แคลอรี่:แคลมาก, โปรตีน:โปรตีนกลาง,
      ไขมัน:ไขมันน้อย, คาร์บ:คาร์บสูง
    sentences:
      - วิธีทำเต้าส่วน
      - ข้าวกะเพราไก่ไข่ดาว
      - แกงส้มใต้มันขี้หนู
  - source_sentence: >-
      กะปิ,  ข้าวสวย,  หมูสามชั้น,  น้ำตาล,  กระเทียม, สัปปะรด,  กุนเชียง, 
      ไข่ไก่,  ไข่เค็ม,  ปลาทู,  ถั่วฝักยาว,  หอมแดง,  พริกขี้หนู,  มะม่วง, 
      กุ้งแห้ง,  ผักชี,  ซีอิ้วดำ | แคลอรี่:แคลมาก, โปรตีน:โปรตีนสูง,
      ไขมัน:ไขมันกลาง, คาร์บ:คาร์บสูง
    sentences:
      - แกงจืดไข่ม้วนไส้ผักกาดขาวหมูสับ
      - มันบดกระเทียมย่าง
      - ข้าวคลุกกะปิ
pipeline_tag: sentence-similarity
library_name: sentence-transformers
metrics:
  - cosine_accuracy@1
  - cosine_accuracy@3
  - cosine_accuracy@5
  - cosine_accuracy@10
  - cosine_precision@1
  - cosine_precision@3
  - cosine_precision@5
  - cosine_recall@1
  - cosine_recall@3
  - cosine_recall@5
  - cosine_ndcg@10
  - cosine_mrr@10
  - cosine_map@100
model-index:
  - name: Thai Food Retriever with Nutrition
    results:
      - task:
          type: information-retrieval
          name: Information Retrieval
        dataset:
          name: thai food nutrition eval
          type: thai-food-nutrition-eval
        metrics:
          - type: cosine_accuracy@1
            value: 0.6458333333333334
            name: Cosine Accuracy@1
          - type: cosine_accuracy@3
            value: 0.7708333333333334
            name: Cosine Accuracy@3
          - type: cosine_accuracy@5
            value: 0.8541666666666666
            name: Cosine Accuracy@5
          - type: cosine_accuracy@10
            value: 0.9583333333333334
            name: Cosine Accuracy@10
          - type: cosine_precision@1
            value: 0.6458333333333334
            name: Cosine Precision@1
          - type: cosine_precision@3
            value: 0.2569444444444444
            name: Cosine Precision@3
          - type: cosine_precision@5
            value: 0.1708333333333333
            name: Cosine Precision@5
          - type: cosine_recall@1
            value: 0.6458333333333334
            name: Cosine Recall@1
          - type: cosine_recall@3
            value: 0.7708333333333334
            name: Cosine Recall@3
          - type: cosine_recall@5
            value: 0.8541666666666666
            name: Cosine Recall@5
          - type: cosine_ndcg@10
            value: 0.7926146014031555
            name: Cosine Ndcg@10
          - type: cosine_mrr@10
            value: 0.7406746031746033
            name: Cosine Mrr@10
          - type: cosine_map@100
            value: 0.7420634920634921
            name: Cosine Map@100

Thai Food Retriever with Nutrition

This is a sentence-transformers model finetuned from sentence-transformers/paraphrase-multilingual-mpnet-base-v2. It maps sentences & paragraphs to a 768-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 Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 128, 'do_lower_case': False}) with Transformer model: XLMRobertaModel 
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)

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("thai-food-mpnet-nutrition_2")
# Run inference
sentences = [
    'กะปิ,  ข้าวสวย,  หมูสามชั้น,  น้ำตาล,  กระเทียม, สัปปะรด,  กุนเชียง,  ไข่ไก่,  ไข่เค็ม,  ปลาทู,  ถั่วฝักยาว,  หอมแดง,  พริกขี้หนู,  มะม่วง,  กุ้งแห้ง,  ผักชี,  ซีอิ้วดำ | แคลอรี่:แคลมาก, โปรตีน:โปรตีนสูง, ไขมัน:ไขมันกลาง, คาร์บ:คาร์บสูง',
    'ข้าวคลุกกะปิ',
    'มันบดกระเทียมย่าง',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]

Evaluation

Metrics

Information Retrieval

Metric Value
cosine_accuracy@1 0.6458
cosine_accuracy@3 0.7708
cosine_accuracy@5 0.8542
cosine_accuracy@10 0.9583
cosine_precision@1 0.6458
cosine_precision@3 0.2569
cosine_precision@5 0.1708
cosine_recall@1 0.6458
cosine_recall@3 0.7708
cosine_recall@5 0.8542
cosine_ndcg@10 0.7926
cosine_mrr@10 0.7407
cosine_map@100 0.7421

Training Details

Training Dataset

Unnamed Dataset

  • Size: 1,572 training samples
  • Columns: anchor and positive
  • Approximate statistics based on the first 1000 samples:
    anchor positive
    type string string
    details
    • min: 34 tokens
    • mean: 58.71 tokens
    • max: 128 tokens
    • min: 5 tokens
    • mean: 10.0 tokens
    • max: 22 tokens
  • Samples:
    anchor positive
    พริกแห้ง, หอมแดง, กระเทียม, น้ำมัน, หมูสับ, น้ำสะอาด, น้ำตาลปี๊บ, น้ำปลา, มะขามเปียก แคลอรี่:แคลมาก, โปรตีน:โปรตีนน้อย, ไขมัน:ไขมันสูง, คาร์บ:คาร์บกลาง
    มีพริิกแห้งเยอะมาก หอมแดง กระเทียม และอยากให้เป็นเมนูที่ใส่หมูสับเยอะๆๆ แคลอรี่:แคลมาก, โปรตีน:โปรตีนน้อย, ไขมัน:ไขมันสูง, คาร์บ:คาร์บกลาง
    มีพริกแห้ง, หอมแดง, กระเทียม, หมูสับ ทำอะไรได้บ้าง แคลอรี่:แคลมาก, โปรตีน:โปรตีนน้อย, ไขมัน:ไขมันสูง, คาร์บ:คาร์บกลาง
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim"
    }
    

Evaluation Dataset

Unnamed Dataset

  • Size: 48 evaluation samples
  • Columns: anchor and positive
  • Approximate statistics based on the first 48 samples:
    anchor positive
    type string string
    details
    • min: 42 tokens
    • mean: 71.1 tokens
    • max: 112 tokens
    • min: 4 tokens
    • mean: 9.83 tokens
    • max: 19 tokens
  • Samples:
    anchor positive
    หมูสับ, หนำเลี๊ยบ, ซีอิ๊วขาว, น้ำมันหอย, พริกไทย, กระเทียม, น้ำมัน, ผงปรุงรส, น้ำตาลทราย แคลอรี่:แคลมาก, โปรตีน:โปรตีนน้อย, ไขมัน:ไขมันสูง, คาร์บ:คาร์บกลาง
    ใบกะเพรา, เส้นสปาเก็ตตี้, เห็ด, เนื้อหมู, กุ้ง, ปลาหมึก, ผัก, พริก, กระเทียม, ซอสหอยนางรม, ซีอิ๊วขาว, น้ำปลา, ซีอิ๊วดำ, น้ำตาล, น้ำมัน แคลอรี่:แคลมาก, โปรตีน:โปรตีนกลาง, ไขมัน:ไขมันสูง, คาร์บ:คาร์บน้อย
    ไข่ไก่, กุ้ง, ซีอิ้วขาว, น้ำมัน, พริกไทย แคลอรี่:แคลน้อย, โปรตีน:โปรตีนกลาง, ไขมัน:ไขมันน้อย, คาร์บ:คาร์บน้อย
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: epoch
  • per_device_train_batch_size: 24
  • per_device_eval_batch_size: 24
  • learning_rate: 5e-06
  • num_train_epochs: 8
  • warmup_ratio: 0.1
  • load_best_model_at_end: True
  • batch_sampler: no_duplicates

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: epoch
  • prediction_loss_only: True
  • per_device_train_batch_size: 24
  • per_device_eval_batch_size: 24
  • 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: 5e-06
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1.0
  • num_train_epochs: 8
  • 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
  • use_ipex: False
  • bf16: False
  • fp16: False
  • 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}
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • 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
  • 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: False
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_dataset_batch_sampler: proportional

Training Logs

Epoch Step Training Loss Validation Loss thai-food-nutrition-eval_cosine_ndcg@10
0.1515 10 3.2223 - -
0.3030 20 2.6833 - -
0.4545 30 2.0425 - -
0.6061 40 1.733 - -
0.7576 50 1.5859 - -
0.9091 60 1.526 - -
1.0 66 - 1.4714 0.6588
1.0606 70 1.3475 - -
1.2121 80 1.3117 - -
1.3636 90 1.2059 - -
1.5152 100 1.0191 - -
1.6667 110 0.978 - -
1.8182 120 1.0044 - -
1.9697 130 0.9256 - -
2.0 132 - 1.0963 0.7210
2.1212 140 0.6237 - -
2.2727 150 0.8119 - -
2.4242 160 0.7516 - -
2.5758 170 0.8185 - -
2.7273 180 0.7367 - -
2.8788 190 0.7747 - -
3.0 198 - 1.0376 0.7125
3.0303 200 0.7151 - -
3.1818 210 0.6482 - -
3.3333 220 0.6579 - -
3.4848 230 0.729 - -
3.6364 240 0.5395 - -
3.7879 250 0.5708 - -
3.9394 260 0.5773 - -
4.0 264 - 0.9310 0.7597
4.0909 270 0.4705 - -
4.2424 280 0.496 - -
4.3939 290 0.4644 - -
4.5455 300 0.4732 - -
4.6970 310 0.5906 - -
4.8485 320 0.4255 - -
5.0 330 0.4799 0.8683 0.7795
5.1515 340 0.3249 - -
5.3030 350 0.5088 - -
5.4545 360 0.4819 - -
5.6061 370 0.4046 - -
5.7576 380 0.4829 - -
5.9091 390 0.4504 - -
6.0 396 - 0.8820 0.7925
6.0606 400 0.399 - -
6.2121 410 0.3227 - -
6.3636 420 0.3962 - -
6.5152 430 0.391 - -
6.6667 440 0.4882 - -
6.8182 450 0.3662 - -
6.9697 460 0.3808 - -
7.0 462 - 0.8607 0.783
7.1212 470 0.349 - -
7.2727 480 0.3512 - -
7.4242 490 0.3958 - -
7.5758 500 0.2765 - -
7.7273 510 0.413 - -
7.8788 520 0.4138 - -
8.0 528 - 0.8727 0.7926
  • The bold row denotes the saved checkpoint.

Framework Versions

  • Python: 3.11.13
  • Sentence Transformers: 4.1.0
  • Transformers: 4.52.4
  • PyTorch: 2.6.0+cu124
  • Accelerate: 1.7.0
  • Datasets: 2.14.4
  • Tokenizers: 0.21.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}
}