CoolFace
Modelpublic

Chanisorn/thai-food-mpnet-new-v9

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes22downloads
Model Card

Thai Food Ingredients → Dish Prediction

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 Type: Sentence Transformer
  • —Base model: sentence-transformers/paraphrase-multilingual-mpnet-base-v2 <!-- at revision 84fccfe766bcfd679e39efefe4ebf45af190ad2d -->
  • —Maximum Sequence Length: 128 tokens
  • —Output Dimensionality: 768 dimensions
  • —Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown -->
  • —Language: th
  • —License: apache-2.0

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:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("thai_food_prediction1")
# 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]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Information Retrieval
MetricValue
cosine_accuracy@10.6053
cosine_accuracy@30.8421
cosine_accuracy@50.9605
cosine_accuracy@100.9737
cosine_precision@10.6053
cosine_precision@30.2807
cosine_precision@50.1921
cosine_recall@10.6053
cosine_recall@30.8421
cosine_recall@50.9605
cosine_ndcg@100.7949
cosine_mrr@100.736
cosine_map@1000.7372

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

Unnamed Dataset
  • —Size: 2,452 training samples
  • —Columns: <code>anchor</code> and <code>positive</code>
  • —Approximate statistics based on the first 1000 samples: | | anchor | positive | |:--------|:-----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 7 tokens</li><li>mean: 29.15 tokens</li><li>max: 125 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 9.91 tokens</li><li>max: 22 tokens</li></ul> |
  • —Samples: | anchor | positive | |:-----------------------------------------------------------------------------------------------------------------------|:-------------------------| | <code>ปลาหมึก, ซีอิ๊วดำ, ผงขมิ้น, น้ำปูนใส, กระเทียมสับ, รากผักชี, พริกแดง, น้ำตาลปี๊บ, เกลือ, น้ำปลา, น้ำมะนาว</code> | <code>ปลาหมึกย่าง</code> | | <code>ไปตกหมึกมา อยากทำอะไรกินง่ายๆ ได้รสชาติของปลาหมึกแท้ๆ </code> | <code>ปลาหมึกย่าง</code> | | <code>อยากกินปลาหมึกๆ ซีฟุ้ด อร่อยๆ</code> | <code>ปลาหมึกย่าง</code> |
  • —Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim"
  }

Evaluation Dataset

Unnamed Dataset
  • —Size: 76 evaluation samples
  • —Columns: <code>anchor</code> and <code>positive</code>
  • —Approximate statistics based on the first 76 samples: | | anchor | positive | |:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 4 tokens</li><li>mean: 47.42 tokens</li><li>max: 86 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 10.24 tokens</li><li>max: 20 tokens</li></ul> |
  • —Samples: | anchor | positive | |:-------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------| | <code>น้ำมันพืช, กระเทียม, น้ำตาลทราย, น้ำปลา, ซีอิ๊วขาว, ซอสปรุงรส, ซีอิ๊วดำเค็ม, น้ำส้มสายชู, พริกไทย, เส้นหมี่แห้ง, ลูกชิ้น, ถั่วงอก</code> | <code>หมี่คลุก</code> | | <code>น้ำมัน, กระเทียม, หมูหมัก, เส้นใหญ่, ซีอิ้วดำ, คะน้า, กระหล่ำปลี, แครอท, ไข่เป็ด, ไข่ไก่, ผงปรุงรส, น้ำตาลทราย, ซอสหอยนางรม, ซอสปรุงรส, พริกไทย</code> | <code>ผัดซีอิ้วเส้นใหญ่</code> | | <code>สะโพกหมู, น้ำตาลทราย, น้ำตาลปี๊บ, ซีอิ๊วขาว, เกลือ, น้ำเปล่า, ลูกผักชี, ยี่หร่า, กระเทียมไทย, สับละเอียด, น้ำมันพืช</code> | <code>หมูสวรรค์</code> |
  • —Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "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

<details><summary>Click to expand</summary>

  • —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: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': 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

</details>

Training Logs

EpochStepTraining LossValidation Lossthai-food-eval_cosine_ndcg@10
0.0971103.2623--
0.1942202.7506--
0.2913302.45--
0.3883402.1205--
0.4854502.0216--
0.5825601.7865--
0.6796701.7075--
0.7767801.4338--
0.8738901.5122--
0.97091001.4975--
1.0103-1.03370.6411
1.06801101.2398--
1.16501201.1619--
1.26211301.1641--
1.35921401.084--
1.45631500.992--
1.55341600.9877--
1.65051701.0527--
1.74761801.0431--
1.84471901.0235--
1.94172001.0231--
2.0206-0.69850.7429
2.03882100.8387--
2.13592200.6738--
2.23302300.7837--
2.33012400.8629--
2.42722500.6708--
2.52432600.8917--
2.62142700.7686--
2.71842800.7352--
2.81552900.6844--
2.91263000.7821--
3.0309-0.60230.7508
3.00973100.6968--
3.10683200.6536--
3.20393300.6157--
3.30103400.6562--
3.39813500.563--
3.49513600.6401--
3.59223700.6167--
3.68933800.5221--
3.78643900.5609--
3.88354000.6595--
3.98064100.5761--
4.0412-0.55410.7728
4.07774200.4465--
4.17484300.4011--
4.27184400.4988--
4.36894500.5891--
4.46604600.6107--
4.56314700.5573--
4.66024800.5007--
4.75734900.4907--
4.85445000.4756--
4.95155100.5233--
5.0515-0.48310.7920
5.04855200.4877--
5.14565300.5158--
5.24275400.4769--
5.33985500.4461--
5.43695600.4684--
5.53405700.347--
5.63115800.4203--
5.72825900.4448--
5.82526000.3725--
5.92236100.4598--
6.0618-0.47540.7938
6.01946200.5246--
6.11656300.3768--
6.21366400.3567--
6.31076500.4294--
6.40786600.356--
6.50496700.4915--
6.60196800.3908--
6.69906900.3245--
6.79617000.4382--
6.89327100.4935--
6.99037200.4248--
7.0721-0.49280.7886
7.08747300.2804--
7.18457400.3395--
7.28167500.3559--
7.37867600.4312--
7.47577700.3929--
7.57287800.3772--
7.66997900.3205--
7.76708000.3914--
7.86418100.4501--
7.96128200.4708--
8.0824-0.47660.7949
  • —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.8.1
  • —Datasets: 2.14.4
  • —Tokenizers: 0.21.2

Citation

BibTeX

Sentence Transformers
bibtex
@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
bibtex
@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}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->