SHARE: a System for Hierarchical Assistive Recipe Editing

Shuyang Li, Yufei Li, Jianmo Ni, Julian J. McAuley

TL;DR

This paper introduces SHARE, a novel system for automatically editing existing recipes to meet specific dietary constraints. By decoupling ingredient substitution from step generation, SHARE produces more coherent, diverse, and constraint-compliant recipes than previous methods, making it easier for home cooks to find and prepare suitable meals.

What Problem Does This Paper Address?

A significant portion of the population adheres to dietary restrictions for various reasons, yet online recipe resources often fall short in providing suitable options. While users can easily specify their needs (e.g., gluten-free, vegetarian), existing recipe websites and generation models struggle to adapt recipes effectively. Simply replacing ingredients with predefined substitutions often leads to incoherent instructions or fails to account for the broader impact on the dish. This gap leaves many home cooks underserved, limiting their culinary options and potentially leading to frustration.

Methods

The core of SHARE is a hierarchical approach that breaks down the complex task of recipe editing into two sequential, independently trained components:

  1. Ingredient Editing: This component uses a Transformer encoder-decoder architecture to predict a new set of ingredients for a target recipe, conditioned on the original recipe's name, ingredients, and the desired dietary constraint. Crucially, it employs a Set Transformer strategy to treat ingredients as an unordered set, avoiding penalties for ingredient order.
  2. Step Generation: A separate Transformer language model then generates new recipe instructions based solely on the edited ingredient list. This component incorporates a copy attention mechanism to allow direct copying of ingredient tokens from the input, enhancing ingredient-step coherence.

This hierarchical design allows the system to focus on ingredient compatibility first, then generate instructions that naturally incorporate those ingredients, leading to more robust and contextually appropriate recipes.

Datasets

The authors introduce the RecipePairs dataset, a novel benchmark comprising 83,000 pairs of similar recipes. Each pair consists of a base recipe and a corresponding version that satisfies one of seven dietary constraints (low-carb, low-calorie, low-fat, low-sugar, vegetarian, gluten-free, dairy-free). This dataset was curated from the Food.com recipe aggregator and includes user-provided category tags.

Key Insights and Ideas

  • Decoupling is Key: Separating ingredient editing from step generation is crucial. It allows the system to first ensure the correct ingredients are present for the constraint, and then generate instructions that naturally use those ingredients, rather than trying to do both simultaneously.
  • Set-based Ingredient Prediction: Treating ingredients as an unordered set, rather than a sequence, is a more appropriate way to model ingredient lists, as the order of ingredients in a recipe doesn't fundamentally change the dish.
  • Copy Attention for Coherence: The ability to directly copy ingredient names from the input into the generated steps significantly improves the coherence between the ingredient list and the instructions.
  • Human-Cooked Validation: Real-world cooking trials and human evaluations are essential for truly assessing recipe quality, as automatic metrics can only capture certain aspects of coherence and adherence.

Key Results

  • Ingredient List Fidelity: SHARE achieved the highest accuracy (IoU and F1 scores) in editing ingredient lists compared to baselines, with a significantly lower percentage of edited recipes containing prohibited ingredients (less than 3%).
  • Recipe Step Quality: While automatic metrics for step quality (ROUGE, NTED) showed SHARE performing comparably to other models, human evaluations and cooking trials indicated that SHARE produced more diverse and structurally similar recipes to the target.
  • Constraint Adherence: Human evaluators found SHARE's generated recipes to be the most appropriate for the target dietary constraints, with a significantly lower constraint violation rate.
  • Efficiency: SHARE is considerably smaller than baseline models (12.5M parameters vs. 124M for RecipeGPT) and generates recipes significantly faster (0.9s vs. 3.9s).
  • Human Study Findings: Home cooks found SHARE's recipes easy to follow, inferring ingredient amounts using common sense. All cooks agreed the recipes met their dietary constraints, though some noted that the edited dishes sometimes differed stylistically from the original base recipe name.

Limitations and Future Work

  • Recipe Coherence: While SHARE produces readable and understandable recipes, there's still room for improvement in ensuring the generated directions make perfect sense in context and order, especially regarding the interaction of ingredients and cooking processes. Future work could involve generating recipes as structured graphs instead of raw text.
  • Recipe Safety: Despite high accuracy, a small risk of unsafe ingredients being referenced in directions remains. The authors caution against naive usage and stress the importance of manual inspection. Future work could involve removing problematic ingredient references more aggressively.
  • Ingredient Quantities: SHARE, like many prior models, does not output specific ingredient amounts or units. While experienced cooks can infer these, it remains a challenge for making assistive technologies more accessible to beginners. Future work will explore predicting ingredient ratios.
  • Complex Preferences: The current system focuses on dietary constraints. Future work aims to extend this to more complex preferences like cuisines (e.g., making a Chinese version of meatloaf) and to handle multiple dietary restrictions simultaneously.

Summary updated

Abstract

The large population of home cooks with dietary restrictions is under-served by existing cooking resources and recipe generation models. To help them, we propose the task of controllable recipe editing: adapt a base recipe to satisfy a user-specified dietary constraint. This task is challenging, and cannot be adequately solved with human-written ingredient substitution rules or existing end-to-end recipe generation models. We tackle this problem with SHARE: a System for Hierarchical Assistive Recipe Editing, which performs simultaneous ingredient substitution before generating natural-language steps using the edited ingredients. By decoupling ingredient and step editing, our step generator can explicitly integrate the available ingredients. Experiments on the novel RecipePairs dataset -- 83K pairs of similar recipes where each recipe satisfies one of seven dietary constraints -- demonstrate that SHARE produces convincing, coherent recipes that are appropriate for a target dietary constraint. We further show through human evaluations and real-world cooking trials that recipes edited by SHARE can be easily followed by home cooks to create appealing dishes.
BibTeX
@inproceedings{li2022share,
  author = {Shuyang Li and Yufei Li and Jianmo Ni and Julian J. McAuley},
  title = {{SHARE: a System for Hierarchical Assistive Recipe Editing}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.emnlp-main.761},
}
Figure