be-forkulous

This is the main embedding model for Forkulous, a free-as-in-freedom API for turning unstructured recipe data into nutrient information.

This model accepts either unparsed freetext ingredient lines and descriptions from USDA FoodDataCentral and outputs a vector in a 384-dimensional vector space.

This is not a model for sequence/token classification of single ingredient lines.

This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2. It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for retrieval.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: sentence-transformers/all-MiniLM-L6-v2
  • Maximum Sequence Length: 256 tokens
  • Output Dimensionality: 384 dimensions
  • Similarity Function: Cosine Similarity
  • Supported Modality: Text

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': 'BertModel'})
  (1): Pooling({'embedding_dimension': 384, '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

# Download from the 🤗 Hub
model = SentenceTransformer("Forkulous/be-forkulous")
# Run inference
queries = [
    'ingredient: 6 tablespoons mascarpone cheese softened to room temperature',
]
documents = [
    'usda: Cheese, tilsit',
    'usda: Sauce, NFS',
    'usda: Veal, variety meats and by-products, thymus, cooked, braised',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 384] [3, 384]

# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.6883, 0.4792, 0.2840]])

Evaluation

Metrics

Semantic Similarity

Metric Value
pearson_cosine 0.8612
spearman_cosine 0.8619

Training Details

Training Dataset

Unnamed Dataset

  • Size: 7,845 training samples
  • Columns: query, document, and score
  • Approximate statistics based on the first 100 samples:
    query document score
    type string string float
    modality text text
    details
    • min: 6 tokens
    • mean: 13.41 tokens
    • max: 30 tokens
    • min: 7 tokens
    • mean: 13.43 tokens
    • max: 28 tokens
    • min: 0.0
    • mean: 0.56
    • max: 1.0
  • Samples:
    query document score
    ingredient: 2/3 cup potato starch or corn starch usda: FLOUR, CORN, YELLOW (FINE MEAL) (ENRICHED) 0.4
    ingredient: 2 heads butter lettuce chopped usda: Lettuce, for use on a sandwich 1.0
    ingredient: whipped cream or ice cream, for serving usda: Beef with cream or white sauce 0.0
  • Loss: CoSENTLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "pairwise_cos_sim"
    }
    

Evaluation Dataset

Unnamed Dataset

  • Size: 2,055 evaluation samples
  • Columns: query, document, and score
  • Approximate statistics based on the first 100 samples:
    query document score
    type string string float
    modality text text
    details
    • min: 7 tokens
    • mean: 14.94 tokens
    • max: 37 tokens
    • min: 6 tokens
    • mean: 14.63 tokens
    • max: 36 tokens
    • min: 0.0
    • mean: 0.49
    • max: 1.0
  • Samples:
    query document score
    ingredient: 2/3 cup dark brown sugar packed soft usda: Cherries, dark red, sweet, raw 0.0
    ingredient: 1/4 granulated sugar I used raw usda: C&H Granulated White Sugar (OK1) - NFY040Y38 0.9
    ingredient: 1 cup yellow squash diced usda: Squash, yellow, raw 1.0
  • Loss: CoSENTLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "pairwise_cos_sim"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 32
  • num_train_epochs: 5
  • lr_scheduler_type: cosine
  • warmup_steps: 122.578125
  • per_device_eval_batch_size: 32
  • load_best_model_at_end: True

All Hyperparameters

Click to expand
  • per_device_train_batch_size: 32
  • num_train_epochs: 5
  • max_steps: -1
  • learning_rate: 5e-05
  • lr_scheduler_type: cosine
  • lr_scheduler_kwargs: None
  • warmup_steps: 122.578125
  • 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: 1
  • average_tokens_across_devices: True
  • max_grad_norm: 1.0
  • label_smoothing_factor: 0.0
  • bf16: False
  • fp16: False
  • 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: True
  • 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: 32
  • 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: Forkulous/be-forkulous
  • 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: None
  • 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
  • dataloader_multiprocessing_context: None
  • dataloader_in_order: True
  • 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
  • local_rank: -1
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}
  • warmup_ratio: None

Training Logs

Click to expand
Epoch Step Training Loss Validation Loss spearman_cosine
0.0407 10 7.8560 - -
0.0813 20 6.6645 - -
0.1220 30 6.6995 - -
0.1626 40 6.3168 - -
0.2033 50 6.0008 - -
0.2439 60 5.6803 - -
0.2846 70 5.4944 - -
0.3252 80 5.5124 - -
0.3659 90 5.5266 - -
0.4065 100 5.4270 - -
0.4472 110 5.5078 - -
0.4878 120 5.4180 - -
0.4959 122 - 5.3326 0.7899
0.5285 130 5.2544 - -
0.5691 140 5.3673 - -
0.6098 150 5.3187 - -
0.6504 160 5.2386 - -
0.6911 170 5.2490 - -
0.7317 180 5.4214 - -
0.7724 190 5.1935 - -
0.8130 200 5.2074 - -
0.8537 210 5.1898 - -
0.8943 220 5.2349 - -
0.9350 230 5.1351 - -
0.9756 240 5.3108 - -
0.9919 244 - 5.2236 0.8234
1.0163 250 4.8030 - -
1.0569 260 4.8858 - -
1.0976 270 5.0583 - -
1.1382 280 4.8510 - -
1.1789 290 4.9847 - -
1.2195 300 4.8511 - -
1.2602 310 5.0625 - -
1.3008 320 4.9002 - -
1.3415 330 4.8812 - -
1.3821 340 4.8602 - -
1.4228 350 4.9375 - -
1.4634 360 5.1199 - -
1.4878 366 - 5.2299 0.8481
1.5041 370 4.7782 - -
1.5447 380 4.9243 - -
1.5854 390 4.8123 - -
1.6260 400 5.1224 - -
1.6667 410 4.8130 - -
1.7073 420 4.8003 - -
1.7480 430 4.7271 - -
1.7886 440 4.9549 - -
1.8293 450 4.8807 - -
1.8699 460 4.8482 - -
1.9106 470 4.7049 - -
1.9512 480 4.9837 - -
1.9837 488 - 5.2740 0.8499
1.9919 490 4.9704 - -
2.0325 500 4.2136 - -
2.0732 510 4.3989 - -
2.1138 520 4.6642 - -
2.1545 530 4.6626 - -
2.1951 540 4.7278 - -
2.2358 550 4.5797 - -
2.2764 560 4.4921 - -
2.3171 570 4.5389 - -
2.3577 580 4.5522 - -
2.3984 590 4.3810 - -
2.4390 600 4.4543 - -
2.4797 610 4.4910 5.7227 0.8565
2.5203 620 4.4647 - -
2.5610 630 4.5019 - -
2.6016 640 5.1985 - -
2.6423 650 4.5147 - -
2.6829 660 4.3910 - -
2.7236 670 4.3696 - -
2.7642 680 4.4902 - -
2.8049 690 4.8663 - -
2.8455 700 4.5024 - -
2.8862 710 4.6200 - -
2.9268 720 4.5397 - -
2.9675 730 4.5980 - -
2.9756 732 - 5.5092 0.8602
3.0081 740 4.1333 - -
3.0488 750 4.1640 - -
3.0894 760 4.3004 - -
3.1301 770 4.3414 - -
3.1707 780 4.5028 - -
3.2114 790 4.1783 - -
3.2520 800 4.2447 - -
3.2927 810 4.1731 - -
3.3333 820 4.2797 - -
3.3740 830 4.4345 - -
3.4146 840 4.1085 - -
3.4553 850 4.2252 - -
3.4715 854 - 5.8100 0.8581
3.4959 860 4.2567 - -
3.5366 870 4.2262 - -
3.5772 880 4.2609 - -
3.6179 890 4.5412 - -
3.6585 900 4.2727 - -
3.6992 910 4.2478 - -
3.7398 920 4.1876 - -
3.7805 930 4.3053 - -
3.8211 940 4.2070 - -
3.8618 950 4.2778 - -
3.9024 960 4.2651 - -
3.9431 970 4.5292 - -
3.9675 976 - 5.8038 0.8604
3.9837 980 4.2689 - -
4.0244 990 3.5685 - -
4.0650 1000 4.0194 - -
4.1057 1010 4.0093 - -
4.1463 1020 4.1102 - -
4.1870 1030 3.9494 - -
4.2276 1040 4.2017 - -
4.2683 1050 4.0265 - -
4.3089 1060 4.2574 - -
4.3496 1070 4.4601 - -
4.3902 1080 4.0986 - -
4.4309 1090 4.1873 - -
4.4634 1098 - 5.9042 0.8620
4.4715 1100 4.0357 - -
4.5122 1110 3.9086 - -
4.5528 1120 4.0057 - -
4.5935 1130 4.2979 - -
4.6341 1140 4.3391 - -
4.6748 1150 3.9628 - -
4.7154 1160 3.9963 - -
4.7561 1170 4.1324 - -
4.7967 1180 4.1531 - -
4.8374 1190 3.9365 - -
4.8780 1200 3.8198 - -
4.9187 1210 4.0716 - -
4.9593 1220 4.3199 5.9275 0.8619
5.0 1230 3.3747 5.9275 0.8619

Training Time

  • Training: 1.9 minutes
  • Evaluation: 30.7 seconds
  • Total: 2.4 minutes

Framework Versions

  • Python: 3.13.11
  • Sentence Transformers: 5.5.1
  • Transformers: 5.15.0
  • PyTorch: 2.14.0.dev20260708
  • Accelerate: 1.14.0
  • Datasets: 5.0.1
  • 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",
}

CoSENTLoss

@article{10531646,
    author={Huang, Xiang and Peng, Hao and Zou, Dongcheng and Liu, Zhiwei and Li, Jianxin and Liu, Kay and Wu, Jia and Su, Jianlin and Yu, Philip S.},
    journal={IEEE/ACM Transactions on Audio, Speech, and Language Processing},
    title={CoSENT: Consistent Sentence Embedding via Similarity Ranking},
    year={2024},
    doi={10.1109/TASLP.2024.3402087}
}
Downloads last month
32
Safetensors
Model size
22.7M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Forkulous/be-forkulous

Dataset used to train Forkulous/be-forkulous

Paper for Forkulous/be-forkulous

Evaluation results