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 Type: Sentence Transformer
- Base model: sentence-transformers/paraphrase-multilingual-mpnet-base-v2
- Maximum Sequence Length: 128 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
- Language: th
- License: apache-2.0
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
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
- Dataset:
thai-food-nutrition-eval
- Evaluated with
InformationRetrievalEvaluator
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
andpositive
- 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
andpositive
- 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
: epochper_device_train_batch_size
: 24per_device_eval_batch_size
: 24learning_rate
: 5e-06num_train_epochs
: 8warmup_ratio
: 0.1load_best_model_at_end
: Truebatch_sampler
: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: epochprediction_loss_only
: Trueper_device_train_batch_size
: 24per_device_eval_batch_size
: 24per_gpu_train_batch_size
: Noneper_gpu_eval_batch_size
: Nonegradient_accumulation_steps
: 1eval_accumulation_steps
: Nonetorch_empty_cache_steps
: Nonelearning_rate
: 5e-06weight_decay
: 0.0adam_beta1
: 0.9adam_beta2
: 0.999adam_epsilon
: 1e-08max_grad_norm
: 1.0num_train_epochs
: 8max_steps
: -1lr_scheduler_type
: linearlr_scheduler_kwargs
: {}warmup_ratio
: 0.1warmup_steps
: 0log_level
: passivelog_level_replica
: warninglog_on_each_node
: Truelogging_nan_inf_filter
: Truesave_safetensors
: Truesave_on_each_node
: Falsesave_only_model
: Falserestore_callback_states_from_checkpoint
: Falseno_cuda
: Falseuse_cpu
: Falseuse_mps_device
: Falseseed
: 42data_seed
: Nonejit_mode_eval
: Falseuse_ipex
: Falsebf16
: Falsefp16
: Falsefp16_opt_level
: O1half_precision_backend
: autobf16_full_eval
: Falsefp16_full_eval
: Falsetf32
: Nonelocal_rank
: 0ddp_backend
: Nonetpu_num_cores
: Nonetpu_metrics_debug
: Falsedebug
: []dataloader_drop_last
: Falsedataloader_num_workers
: 0dataloader_prefetch_factor
: Nonepast_index
: -1disable_tqdm
: Falseremove_unused_columns
: Truelabel_names
: Noneload_best_model_at_end
: Trueignore_data_skip
: Falsefsdp
: []fsdp_min_num_params
: 0fsdp_config
: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap
: Noneaccelerator_config
: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed
: Nonelabel_smoothing_factor
: 0.0optim
: adamw_torchoptim_args
: Noneadafactor
: Falsegroup_by_length
: Falselength_column_name
: lengthddp_find_unused_parameters
: Noneddp_bucket_cap_mb
: Noneddp_broadcast_buffers
: Falsedataloader_pin_memory
: Truedataloader_persistent_workers
: Falseskip_memory_metrics
: Trueuse_legacy_prediction_loop
: Falsepush_to_hub
: Falseresume_from_checkpoint
: Nonehub_model_id
: Nonehub_strategy
: every_savehub_private_repo
: Nonehub_always_push
: Falsegradient_checkpointing
: Falsegradient_checkpointing_kwargs
: Noneinclude_inputs_for_metrics
: Falseinclude_for_metrics
: []eval_do_concat_batches
: Truefp16_backend
: autopush_to_hub_model_id
: Nonepush_to_hub_organization
: Nonemp_parameters
:auto_find_batch_size
: Falsefull_determinism
: Falsetorchdynamo
: Noneray_scope
: lastddp_timeout
: 1800torch_compile
: Falsetorch_compile_backend
: Nonetorch_compile_mode
: Noneinclude_tokens_per_second
: Falseinclude_num_input_tokens_seen
: Falseneftune_noise_alpha
: Noneoptim_target_modules
: Nonebatch_eval_metrics
: Falseeval_on_start
: Falseuse_liger_kernel
: Falseeval_use_gather_object
: Falseaverage_tokens_across_devices
: Falseprompts
: Nonebatch_sampler
: no_duplicatesmulti_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}
}
- Downloads last month
- 10
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
🙋
Ask for provider support
Model tree for Chanisorn/thai-food-mpnet-nutrition
Evaluation results
- Cosine Accuracy@1 on thai food nutrition evalself-reported0.646
- Cosine Accuracy@3 on thai food nutrition evalself-reported0.771
- Cosine Accuracy@5 on thai food nutrition evalself-reported0.854
- Cosine Accuracy@10 on thai food nutrition evalself-reported0.958
- Cosine Precision@1 on thai food nutrition evalself-reported0.646
- Cosine Precision@3 on thai food nutrition evalself-reported0.257
- Cosine Precision@5 on thai food nutrition evalself-reported0.171
- Cosine Recall@1 on thai food nutrition evalself-reported0.646
- Cosine Recall@3 on thai food nutrition evalself-reported0.771
- Cosine Recall@5 on thai food nutrition evalself-reported0.854