SHARE : a System for Hierarchical Assistive Recipe Editing (2022)

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.

## introduction cooking has played an integral role in human civilization and evolution for over 1.8 million years @xcite . a growing population follows some form of dietary restriction @xcite , with motivations ranging from socioeconomic to medical @xcite . home cooks browsing recipes on online recipe aggregators may often encounter an interesting recipe that does not fit their dietary needs (e.g. vegetarianism), and would benefit from a way to edit that recipe to fit their needs. these restrictions are easy for users to specify, but existing recipe websites offer few options for users with dietary constraints-even those with common restrictions like gluten intolerance ( to help such users, we introduce the task of controllable recipe editing: editing a base recipe so that it satisfies a user-specified dietary constraint (figure 1 ). controllable recipe editing can help home cooks of any experience level find diverse ways to satisfy their dietary needs and help develop interactive, personalized products like meal kits to accommodate individual needs and preferences. this is a challenging task: rule-based substitution methods and existing recipe generators cannot adequately account for both the dietary and structural impacts of ingredient substitutions. to tackle this task, we propose a system for hierarchical assistive recipe editing (share). we first use a transformer @xcite encoder-decoder to perform multiple simultaneous ingredient substitutions conditioned on a dietary restriction. we next employ a transformer language model to write new instructions conditioned on the edited ingredients, using a copy mechanism @xcite to increase ingredient-step coherence. we conduct experiments on a novel dataset of 83k recipe pairs from user-reviewed recipes on a popular recipe site. each pair is associated with a dietary restriction and contains a base recipe and a similar target recipe that satisfies the constraint. we evaluate edited recipes via automatic metrics to demonstrate that share produces diverse and high-fidelity recipes. we survey 672 home cooks to assess the quality of our edited recipes compared to human-written recipes, finding that share consistently produced the highest quality edits-in the process discovering several stylistic and structural aspects that cooks evaluate when searching for recipes. we also recruit seven home cooks to cook 21 recipes generated from share and evaluate both the cooking process and final product, showing that such recipes are delicious, easy to make, and satisfy dietary restrictions. we summarize our main contributions: 1) we propose the controllable recipe editing task to assist an under-served population of home cooks by editing recipes to satisfy their dietary constraints; 2) we create the novel recipepairs dataset-containing 83k pairs of recipes and versions thereof satisfying a dietary constraint-to facilitate recipe editing; 3) we train a hierarchical model for controllable recipe editing (share), finding via quantitative trials, human studies, and real-world cooking trials that share creates more coherent and constraint-respecting recipes compared to strong baselines-and that home cooks find its dishes appealing. ## related work we specifically aim to help a population underserved by existing resources: people with dietary restrictions. recent works in nutritional recipe recommendation @xcite aim to recommend generally healthier food options. to our knowledge, while prior work has focused on ingredient substitution or generating recipe directions, ours is the first to examine both to create a complete recipe. we are motivated by work on single ingredient substitution @xcite , but our system accommodates multiple simultaneous substitutions when predicting a target ingredient set. recent work in recipe generation has focused on improving coherence @xcite and ingredient specificity @xcite . we draw from these as well as sentence editing work that uses retrieved prototype sequences to control generated text @xcite , to improve conditioning on ingredients. the editing of procedural texts like recipes resembles conditional text generation and paraphrase generation. transformer @xcite language models have seen success in both fields @xcite , and @xcite demonstrated that such models can make use of a set of control codes for simultaneous multi-task learning. lee et al. (2020 ) train a single model for two tasksingredient extraction and recipe step generation conditioned on the recipe directions and ingredients, respectively. a user must thus provide either the complete set of ingredients or a full set of directions-neither of which may be known to home cooks looking for ways to adapt a recipe to their individual needs. @xcite explore ways to use browsing histories to personalize recipes for cooking website users. their model uses these histories, a recipe name, and ingredients as input to generate personalized instructions, but cannot be controlled to generate constraintsatisfying (e.g. gluten-free) recipes. ## recipepairs dataset several recipe corpora have been collected, including the 150k-recipe now you're cooking! dataset @xcite , recipe1m+ @xcite for cross-modal retrieval tasks, and the food.com (majumder et al., 2019) dataset. we extend the food.com dataset, aggregating user-provided category tags for each of the 459k recipes-comprising soft constraints (low-sugar, low-fat, low-carb, low-calorie) and strict/hard dietary restrictions (gluten-free, dairyfree, vegetarian). we compile a list of 501 ingredients that violate hard constraints following medical website guidance, foot_0 further filtering out any tagged recipes that contain banned ingredients to ensure each of our category tags is accurate. we pair recipes into a base recipe that does not satisfy any category (dietary constraint) and a target version that satisfies the constraint. to ensure base and target recipes are similar, we pair recipes by name, sampling target recipes whose name contains a base recipe name (e.g. 'healthy oat choco-late cookie' as a gluten-free version of 'chocolate cookie'). we also filtered out pairs of recipes with low ingredient overlap, as well as manually verifying a subset of 20% of recipe pairs to ensure quality. this process resulted in 83k total pairs in recipepairs comprising 36k unique base recipes and 60k unique targets. we split the data into 81k pairs for training and 1k disjoint pairs each for testing and validation. the large ingredient space contributes to the difficulty of the task. we normalize ingredients by stripping brand names and amounts (e.g. 'knoxville farms' or '1 tablespoon') and remove rare variants, resulting in 2,942 unique ingredients that appear across 10+ recipes in our dataset. in ## task to help home cooks discover delicious and appropriate recipes, we desire a system for controllable recipe editing. a user should be able to specify the base recipe they would like to edit and the constraint to satisfy. our model should output a similar but novel recipe that satisfies the constraint. to perform editing on the recipepairs corpus, we consider a base recipe r @xmath0; i b ; s b } comprising name n b , ingredients i b , and directions s b . this why isn't substitution enough? at first glance, it may seem acceptable to simply replace problematic ingredients with fixed substitutes. to test this, we compiled 269 dietary substitution rules ( ## share: a hierarchical edit model we pose controllable recipe editing as a supervised learning task: predict a target recipe conditioned on a base recipe and a provided constraint. our share model consists of two independently trained components for ingredient editing (section 5.1) and step prediction (section 5.2). as ingredient quantities in a recipe may vary based on serving size, we omit exact amounts when editing ingredient lists. when asked to cook recipes edited by our system, home cooks find it relatively easy to decide the amount of each ingredient to use (section 8). to ensure that recipes produced by our systems are 100% safe for cooks with dietary constraints, we can further filter edited ingredient lists and blacklist inappropriate ingredient tokens from being generated when using our system in the real world. we discuss the instrumentation and impact of filtering and blacklisting modules in section 7. ## experimental setup baselines while controllable recipe editing has not been attempted to our knowledge, we adapt state-of-the-art recipe generation models as strong baselines alongside the substitution rule method (rule) described in section 4. @xcite finetuned a large language model (lm) on recipe1m+ to extract ingredients from recipe directions and write directions given ingredients: recipegpt. we adapt recipegpt for multi-task editing (mt): 1) predict target ingredients from the category, base recipe name, and base recipe steps by modeling the concatenated sequence [c; n b ; s b ; i t ]; and 2) generate target steps from the category, base recipe name, and target recipe ingredients by modeling the concatenated sequence [c; n b ; i t ; s t ]. we next fine-tune recipegpt for end-to-end (e2e) recipe editing by priming the model @xcite with a dietary constraint and base recipe name [c; n b ] (e.g. 'low_fat cheesecake') to generate target ingredients and steps in a single sequence. e2e is twice as efficient as mt and simultaneously predicts ingredients and steps. we also investigate a form of prototype editing in our end-to-end model, by treating the full base recipe as a prototype which needs to be edited to accommodate a constraint (e2e-p). while methods for sentence editing use a latent edit vector in addition to a prototype sentence @xcite , we prime our model with the fully specified base recipe ([c; n b ; i b ; s b ]) in addition to the category to predict ingredients and steps of an edited recipe. ## human studies and discussion while automatic metrics can help gauge recipe appropriateness, we need human studies to accurately determine whether a recipe-a series of actions performed on a set of ingredients-can be followed. ## conclusion in this work, we propose the task of controllable recipe editing and present a system for hierarchical assistive recipe editing (share) to tackle this task in the context of dietary constraints. on a novel dataset of 83k pairs of recipes and versions that satisfy dietary constraints, we demonstrate that this is a challenging task that cannot be solved with rule-based ingredient substitutions or straightforward application of existing recipe generators. we show that share can edit recipes to produce coherent, diverse versions that accommodate desired dietary restrictions. human evaluation and cooking trials also reveal that share produces feasible recipes that can be followed by home cooks to create appealing dishes. in the future, we aim to leverage recipe workflows to generate flow graphs @xcite and explore editing recipes to accommodate more complex preferences like cuisines.