Model Overview & Purpose

This is a sentence-transformers model finetuned from sentence-transformers/all-distilroberta-v1. The model is specifically fine-tuned on culinary recipes. It maps recipes to a 768-dimensional dense vector space and can be used for:

  • Semantic textual similarity
  • Semantic search
  • Text classification and clustering

Motivation for Fine-Tuning

As detailed in our associated paper, “Cooking Up Creativity: Enhancing LLM Creativity through Structured Recombination” (https://arxiv.org/abs/2504.20643):

  • Problem with Standard SBERT: Initial experiments with the standard sentence-level SBERT model showed a tendency to group recipes based on textual instructions while overlooking key ingredients.
  • Failure Case: This resulted in the model failing to reliably distinguish both broad categories (e.g., salad vs. soup) and finer-grained distinctions (e.g., carrot cake vs. cheesecake).

Model Details

To address this, we fine-tuned the model to better handle true recipe similarity.

  • Dataset: Our fine-tuning dataset consisted of 30k pairs of recipes.
  • Target Similarity Scores: New similarity scores were calculated for these pairs by equally weighting the original Sentence-BERT score and a Rubicka-based similarity score of the two recipes’ ingredient lists (as computed in: https://arxiv.org/pdf/2210.17235).
  • Result: The resulting model has a specialized understanding of recipe similarity that incorporates both textual and ingredient-based features (see full details in the paper).

Model Description

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: RobertaModel 
  (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})
  (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("sentence_transformers_model_id")
# Run inference
sentences = [
    'Ingredients: 1 head cabbage, cored and shredded, 1/8 cup olive oil. Instructions: Place the shredded cabbage in a large bowl, and drizzle olive oil over it. Toss until evenly coated. Season with garlic powder, lemon juice and cilantro, and stir to blend in all of the flavors.',
    'Ingredients: 1/2 cup canola oil, 1/4 cup red wine vinegar, 1 tablespoon soy sauce, 6 tablespoons white sugar, 1 (8 ounce) package shredded cabbage. Instructions: Mix canola oil, red wine vinegar, soy sauce, and sugar in a large bowl, mixing until sugar has dissolved. Toss cabbage, green onions, almonds, and sunflower seed kernels into the dressing. Cover bowl and refrigerate at least 1 hour before serving; slaw tastes better when chilled overnight.',
    'Ingredients: 1/4 cup instant cocoa powder, 1 cup shredded coconut, 1/3 cup raisins, 1/2 cup cornflakes cereal, 1/4 cup chopped walnuts, 1 teaspoon sherry, 2 cups vanilla wafer crumbs, 1/4 cup sweetened condensed milk, 3 (1 ounce) squares unsweetened chocolate. Instructions: Lightly butter a 7 or 8 inch square pan. Put all ingredients (except chocolate squares) into mixing bowl: mix well together.  Press into pan; smooth surface. Melt chocolate in double broiler; spread evenly over top of mixture.  Score with fork.  Refrigerate until firm.  Cut into small bars.',
]
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

Semantic Similarity

Metric Value
pearson_cosine 0.9428
spearman_cosine 0.945
pearson_manhattan 0.934
spearman_manhattan 0.9423
pearson_euclidean 0.9368
spearman_euclidean 0.945
pearson_dot 0.9428
spearman_dot 0.945
pearson_max 0.9428
spearman_max 0.945

Training Details

Training Dataset

Unnamed Dataset

  • Size: 28,937 training samples
  • Columns: sentence_0, sentence_1, and label
  • Approximate statistics based on the first 1000 samples:
    sentence_0 sentence_1 label
    type string string float
    details
    • min: 57 tokens
    • mean: 230.8 tokens
    • max: 512 tokens
    • min: 44 tokens
    • mean: 235.93 tokens
    • max: 512 tokens
    • min: 0.02
    • mean: 0.48
    • max: 1.44
  • Samples:
    sentence_0 sentence_1 label
    Ingredients: 2 cups milk, 2 (.25 ounce) packages active dry yeast, 1/2 cup warm water, 1/3 cup white sugar, 1/3 cup vegetable oil, 1 tablespoon baking powder, 2 teaspoons salt, 1 egg, 7 cups all-purpose flour, 1 cup packed brown sugar, 1/2 cup butter, 2 tablespoons light corn syrup, 1 cup pecan halves, 1/4 cup butter, softened, 1/2 cup white sugar, 1 1/2 tablespoons ground cinnamon. Instructions: Warm the milk in a small saucepan until it bubbles, then remove from heat. Let cool until lukewarm. In a small bowl, dissolve yeast in warm water. Let stand until creamy, about 10 minutes. In a large bowl, combine yeast mixture, milk, sugar, oil, baking powder, salt, egg and 3 cups flour. Beat until smooth. Stir in the remaining flour, 1/2 cup at a time, beating well after each addition. When the dough has pulled together, turn it out onto a lightly floured surface and knead until smooth and elastic, about 8 minutes. Lightly oil a large bowl, place the dough in the bowl and turn to coat with oil. Cover with a damp cloth and let rise in a warm place until doubled in volume, about 1 hour. Heat brown sugar and 1/2 cup butter until melted. Remove from heat; stir in corn syrup. Divide mixture between two 9x13 inch baking pans. Sprinkle 1/2 cup pecans in each pan. When dough has doubled in size, punch down and turn out onto a lightly floured surface. Roll out into a large rectangle and spread with butter. Sprinkle with sugar and cinnamon. Starting with the long side, roll up the rectangle into a log, and slice into 1 inch wide rolls. Place the rolls slightly apart in pans. Wrap pans with aluminum foil and refrigerate at least 12 hours but no longer than 48. Remove rolls from refrigerator and let stand in a warm place until doubled in size, about 30 minutes. Meanwhile, preheat oven to 350 degrees F (175 degrees C). Bake uncovered in preheated oven until golden 30 to 35 minutes. Immediately invert pan on heatproof serving plate. Wait for 1 or 2 minutes before removing pan, so that caramel drizzles over rolls. Ingredients: 1/2 cup boiling water, 3/4 cup cold milk, 1 teaspoon white sugar, 1 1/2 teaspoons active dry yeast, 1 egg, beaten, 2 tablespoons butter, melted and cooled. Instructions: In a large bowl, stir together the water, milk, and sugar. Sprinkle the yeast over the top, and let stand for 5 minutes to dissolve. Stir the egg and butter into the yeast mixture, then stir in the salt, nutmeg, and 2 cups of the flour. Mix until everything is well blended. Mix in remaining flour, 1/2 cup at a time until the dough pulls away from the side of the bowl. Turn out onto a floured surface, and knead for 10 minutes (no cheating!). Place dough into a greased bowl, and let rise until doubled in size. Divide the dough into 8 balls, and let rest for another 20 minutes. Roll each ball out to 8 to 10 inches in diameter. Heat a cast-iron skillet over medium-high heat. Fry each of the pieces of bread fro 30 to 60 seconds on each side, or until light to medium brown spots appear. Keep covered with a damp cloth, or store in a plastic bag until serving. 0.7624140157295458
    Ingredients: 4 cups bread flour, or more as needed, 1/3 cup white sugar, 1 teaspoon salt, 1 (.25 ounce) package rapid-rise yeast, 1/3 cup unsalted butter, melted, 1 1/2 cups hot tap water, 1 large egg, 1 teaspoon oil, or as needed, 1/2 cup brown sugar, or as needed, 1/2 cup chopped pecans, or as needed, 2 tablespoons ground cinnamon, or as needed, 1/2 cup unsalted butter, melted, or as needed, 1 1/2 cups confectioners' sugar, 1/4 cup unsalted butter, softened. Instructions: Sift 2 cups flour, sugar, and salt for dough together into the bowl of a stand mixer fitted with the paddle attachment. Stir in yeast. Add butter and blend at low speed until combined. Add hot water (the hottest it comes from your tap) all at once with the mixer running. Mix in egg until fully incorporated. Add remaining 2 cups flour and mix briefly until dough is soft and flour is incorporated. Change to the dough hook and knead dough for 10 minutes. If dough does not knead, you may need to add a little bit more flour carefully while the mixer is running. Once the dough climbs up the dough hook you have the right consistency. Make dough into a ball. Oil a bowl. Place the dough into the bowl and turn to coat with oil. Cover with a cloth and let sit until doubled in size, 1 to 2 hours. Cover your countertop with flour and roll dough out to a large rectangle, roughly 18x24 inches. Sprinkle brown sugar, pecans, and cinnamon on the dough, then pour melted butter over top. Roll the dough up from the longer side and cut into twelve 2-inch pieces. Place the pieces in a baking pan or on a baking stone. Cover with a cloth and let rise until doubled in size, about 45 minutes. Keep a close eye on the rolls; if they start to fall or look deflated at all, bake them immediately. Preheat the oven to 375 degrees F (190 degrees C). Bake the rolls in the preheated oven until golden brown, 6 to 10 minutes. Meanwhile, combine confectioners' sugar, butter, cream cheese, vanilla, and salt in a large bowl; beat with an electric mixer until no lumps of cream cheese remain. Whip for 2 to 3 more minutes on medium speed. Spread icing on warm rolls and serve. Ingredients: 1 cup all-purpose flour, 1 cup rolled oats, 1 cup packed brown sugar, 1 teaspoon baking soda, 1/4 teaspoon salt, 1/2 cup butter, 2 eggs, 1 cup packed brown sugar, 1/2 teaspoon almond extract, 1 tablespoon all-purpose flour, 1 teaspoon baking powder, 1/2 teaspoon salt, 1 cup flaked coconut, 1 cup maraschino cherries, drained and juice reserved, 1/2 cup chopped pecans, 6 tablespoons butter, softened, 4 cups confectioners' sugar, 2 teaspoons vanilla extract. Instructions: Preheat oven to 350 degrees F (175 degrees C). In a medium bowl, stir together 1 cup flour, oats, 1 cup brown sugar, baking soda and 1/4 teaspoon salt. Rub in the 1/2 cup of butter until crumbly. Press into the bottom of a 9x13 inch baking pan. Bake for 10 minutes in the preheated oven. Remove and cool. Make the filling while the crust is baking. In a medium bowl, beat eggs, almond extract, 1 cup of brown sugar, 1 tablespoon of flour, baking powder and 1/2 teaspoon of salt until smooth. Stir in the coconut, cherries and pecans. Spread over the pre-baked crust. Bake for 25 minutes in the preheated oven, until light brown. Let cool before icing. To make the icing, mix together the remaining 6 tablespoons butter, confectioners' sugar and vanilla until smooth. Gradually add the reserved cherry juice until the desired consistency is reached. Drizzle over cooled bars before cutting into squares. 0.7566587642301353
    Ingredients: 1/2 cup butter, 1 7/8 cups white sugar, 4 egg yolks, 1 cup all-purpose flour, 1 cup unsweetened cocoa powder, 1 1/3 tablespoons baking powder, 1/2 teaspoon salt, 4 egg whites, 1 cup milk, 2 teaspoons vanilla extract, 2 cups semisweet chocolate chips, 3/4 cup sour cream, 1 teaspoon vanilla extract, 1 pinch salt. Instructions: Preheat oven to 325 degrees F (165 degrees C). Grease and flour three 9 inch round cake pans. In a large bowl, cream together the butter and sugar. Beat in the egg yolks, one at a time. Stir in 2 teaspoons vanilla. Combine the flour, cocoa, baking powder and salt, stir into the creamed mixture alternately with the milk. In a large clean glass or metal bowl, whip egg whites until soft peaks form. Fold 1/3 of whites into batter to lighten it, then quickly fold in remaining whites until no streaks remain. Divide batter into the 3 prepared pans. Bake for 20 to 25 minutes in the preheated oven, until a toothpick inserted into the center of the cake comes out clean. Cool in pans on a wire rack. To make the frosting: Melt the chocolate chips in the top of a double boiler, stirring occasionally until smooth. Remove from heat and stir in the sour cream, 1 teaspoon vanilla and pinch of salt. Frosting can be used warm to fill and frost the 3 layers. Ingredients: 1/2 cup butter, 2 cups all-purpose flour, 1 cup white sugar, 1/2 cup packed brown sugar, 2 eggs, 1 teaspoon baking powder, 1 teaspoon baking soda, 1 cup sour cream, 1 teaspoon vanilla extract, 1 teaspoon ground cinnamon, 1/4 cup brown sugar, 4 tablespoons milk, 1 cup confectioners' sugar, 1/4 ounce candy sprinkles (optional). Instructions: In a large bowl, blend together butter or margarine, white sugar, 1/2 cup brown sugar, sour cream, eggs, and vanilla. Add to these ingredients the flour, baking powder, and soda. Blend until smooth. To Make Filling: Combine cinnamon and 1/4 cup brown sugar. Grease and flour a large Bundt pan. Pour 1/2 of the batter into the prepared pan. Sprinkle the cinnamon sugar mix on top of the batter in the pan, and cover with the remaining batter. Bake at 350 degrees F (175 degrees C) for 45 to 50 minutes. Cool. Make a thick glaze by mixing together confectioners' sugar with 2 to 3 tablespoons milk until smooth. Pour over cooled cake, and add sprinkles if desired. 0.8263426596124509
  • Loss: CosineSimilarityLoss with these parameters:
    {
        "loss_fct": "torch.nn.modules.loss.MSELoss"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • num_train_epochs: 1
  • multi_dataset_batch_sampler: round_robin

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • learning_rate: 5e-05
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1
  • num_train_epochs: 1
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • 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: False
  • 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: False
  • hub_always_push: False
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • 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
  • dispatch_batches: None
  • split_batches: None
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: False
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: round_robin

Training Logs

Epoch Step Training Loss val-evaluator_spearman_max
0.0553 100 - 0.8950
0.1106 200 - 0.9175
0.1658 300 - 0.9211
0.2211 400 - 0.9221
0.2764 500 0.0093 0.9239
0.3317 600 - 0.9308
0.3870 700 - 0.9340
0.4422 800 - 0.9324
0.4975 900 - 0.9338
0.5528 1000 0.0063 0.9376
0.6081 1100 - 0.9379
0.6633 1200 - 0.9420
0.7186 1300 - 0.9419
0.7739 1400 - 0.9420
0.8292 1500 0.0057 0.9441
0.8845 1600 - 0.9446
0.9397 1700 - 0.9446
0.9950 1800 - 0.9450
1.0 1809 - 0.9450

Framework Versions

  • Python: 3.10.12
  • Sentence Transformers: 3.0.0
  • Transformers: 4.41.1
  • PyTorch: 2.3.0
  • Accelerate: 0.30.1
  • Datasets: 2.19.1
  • Tokenizers: 0.19.1

Citation

BibTeX

Cooking Up Creativity: Enhancing LLM Creativity through Structured Recombination

@article{mizrahi2025cooking,
  title={Cooking Up Creativity: Enhancing LLM Creativity through Structured Recombination},
  author={Mizrahi, Moran and Shani, Chen and Stanovsky, Gabriel and Jurafsky, Dan and Shahaf, Dafna},
  journal={arXiv preprint arXiv:2504.20643},
  year={2025}
}

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",
}
Downloads last month
63
Safetensors
Model size
82.1M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for moranmiz/recipe-sbert-model

Finetuned
(42)
this model

Evaluation results