R ecipe NLG : A Cooking Recipes Dataset for Semi-Structured Text Generation (2020)

Abstract: Semi-structured text generation is a non-trivial problem. Although last years have brought lots of improvements in natural language generation, thanks to the development of neural models trained on large scale datasets, these approaches still struggle with producing structured, context- and commonsense-aware texts. Moreover, it is not clear how to evaluate the quality of generated texts. To address these problems, we introduce RecipeNLG – a novel dataset of cooking recipes. We discuss the data collection process and the relation between the semi-structured texts and cooking recipes. We use the dataset to approach the problem of generating recipes. Finally, we make use of multiple metrics to evaluate the generated recipes.

## introduction a cooking recipe is a very specific category of text, that facilitates sharing culinary ideas between people and provides algorithms for food preparation. although the recipes follow a set of informal rules which make the cooking experience understandable and reproducible @xcite , there are no strict rules on how this text should be structured. this makes it hard to estimate the recipe quality using any objective measures. recently, we have noticed a major growth of interest in using cooking recipes datasets for performing deep learning experiments. in particular, there is a number of interesting endeavors utilizing computer vision for finding @xcite or even generating @xcite cooking recipes matching the input food image. one of the results was the publication of the recipe1m+ @xcite dataset containing both recipes and images. this dataset, which was the largest publicly available recipes dataset at the time, boosted research in this area. however, while the demand is still emerging, there is currently no large scale cooking dataset tailored specifically for nlp tasks. the existing resources are either not sufficiently big to make efficient use of state of the art language models, or were created with computer vision in mind. in our work, we propose a novel dataset that builds on that previous work and resources. we hope that this resource, which is currently the largest cooking recipes dataset publicly available, may further empower research in the area. this work is composed of three parts. in section 3 we outline the problem of imitating cooking recipes and their structure. we show the limitations that caused us to recognize the existing resources as insufficient for generating complete cooking recipes. in section 4, we introduce a novel recipes dataset built for semi-structured @xcite text generation, which contains over 2 million recipes. we present detailed information about the process of data gathering, deduplication, and cleansing. finally, in section 5 we present the implementation details and results of our experiment. we make use of a named entity recognizer (ner) to extract food entities from the dataset and provide them as an input for the recipe generator, using special control tokens. this data is used to fine-tune a gpt-2 @xcite language model which generates new recipes based on the given list of food entities. we use a number of evaluation methods to compare the generated output to the real recipes using the same set of food entities. in summary, our work introduces recipenlg foot_0 -the novel dataset of cooking recipes, along with the language generation task based on this dataset. ## related work dissemination of artificial neural network architectures like gpt-2 @xcite , bert @xcite or lstm @xcite , @xcite allowed to ad- web scraped and acquired recipes ingr: ["3/4 lbs. lean beef", ...], instr: ["combine all ingredients." ...], title: "spicy stuffed peppers" input: [ "beef", ... ] constructing dataset extracting food @xmath0... <@xmath1. lean @xmath2...<@xmath3.<@xmath4... <@xmath5, 50267, 12023...] gpt2 evaluating recipes. original vs generated with the same input string adding control tokens to form a plain text input adding ner result tokenizing training the model generation starter test set generated recipes vance the field of text generation. recent developments in neural network architectures @xcite , @xcite have enabled images to text conversion and vice versa. publishing recipe1m+ dataset @xcite made it reasonable to utilize deep neural networks and initiated a series of new publications. @xcite combined the recipe1m+ dataset with 13 million food images to generate joint embeddings of recipes and images. their goal was to maximize the coherence of the generated text with its corresponding image. @xcite recognized and classified food images into 101 food categories, utilizing a dataset consisting of approximately 100k images. @xcite used the recipe1m+ to generate simplified recipes lacking ingredient quantities and units. they evaluated their model using a perplexity score as well as the adequacy between the generated text and the image. a number of efforts are underway to utilize neural language models on recipes datasets. @xcite used a dataset of 100k recipes to build an lstm-based discriminative language model for the task of named entity recognition. they utilized a cooking recipes dataset for evaluation. @xcite used a dataset with 31k recipes to propose reference-aware language models to generate instructions based on the ingredients provided. @xcite presented a recurrent neural network that models global coherence. it was used to generate individual instructions based on the title and the list of ingredients. they utilized a dataset with 150k cooking recipes for model evaluation. @xcite published a dataset consisting of approximately 20k recipes to generate question-answer pairs. @xcite built a custom dataset of food images and made use of the text to image approach to perform a storyboarding task for each recipe step. @xcite surveyed different approaches to the problem of food recognition and recipe analysis. they published a list of datasets, reported in the literature and their characteristics. we also propose a new task of generating full recipes with quantities and units. we publish a carefully prepared recipenlg dataset containing both recipes and tagged food entities, to ease the process of generating and evaluating recipes. ## recipes as datasets cooking recipes have a specific format which consists of: a title, a list of ingredients with given amounts, and the instructions in a step by step format. the shortest part of the recipe, the title, should accurately name it and summarize its content. the ingredients list has to contain entities consisting of the quantity, unit name, and ingredient name. the quantities of all ingredients have to be in line with the number of servings the recipe is made for. the unit name has to be in relation to the quantity. it must be appropriate to the ingredient form (liquid, dry countable, dry uncountable). finally, all the units in the recipe are expected to follow a single unit system -imperial or metric. the instructions section needs to accurately present the order of steps. the actions performed on every ingredient have to be taken into account in the following recipe steps, which should reflect the state of the ingredient after the given action. all the ingredients from list should be used, and their usage quantities match those given on the ingredient list. finally, some recipes use references to a step number of prior actions, which makes the step dependent on other steps and their ordinal numbers. we considered using the recipe1m+ dataset for our task, but it became clear that it has certain limitations regarding the validity of the recipe structure. to investigate these issues, we prepared a set of corresponding recipes built of 350, 141 pairs of recipes, identified by the same url. this implies that both recipes in the pair, originated in the same place. they are considered a duplicate, despite not having exactly the same content. example differences in content, as a result of different processing techniques is presented in during the data exploration process, we noticed that the number of instructions in the corresponding recipes varies, usually it is larger in r s . to explain this difference, we manually verified 100 randomly selected pairs of corresponding recipes and found that 34 of them had the same structure, and in 62 cases recipes from r s were malformed -had more steps than the original ones, while recipes from g s kept the original structure. we discovered that the recipe instructions in the recipe1m+ dataset might have been segmented into sentences instead of actual steps (see another issue we encountered during the data exploration, is the absence or malformation of fractions which we observed in recipe1m+ (see distortion of the fractions in this scale makes quantitative analyses pointless. moreover, the text generator trained on this data would be unable to create logically coherent lists of ingredients. ## recipenlg dataset the results presented in section 3 indicate the need for an enhanced dataset, appropriate for semi-structured text generation. we prepared a novel dataset named recipenlg, built on top of recipe1m+, but enhanced with new and corrected records. additional recipes were gathered from multiple cooking web pages, using automated scripts in a web scraping process. ## experiment we present our experiment performed on the recipenlg dataset. the goal was to prepare a model, which makes use of food entities to generate a complete cooking recipe. to accomplish this task, we prepared a ner model for identifying and extracting food entities. a gpt-2 model was fine-tuned for the recipe generation. the generated recipes were compared against the original recipes, using automatic evaluation metrics. ## conclusions & future work while the recipenlg dataset is based on the recipe1m+ dataset, it greatly expands the number of recipes available. what is even more important, the dataset comes with a changed scope -we didn't follow the idea of linking cooking recipes with their images, putting emphasis on the recipe text, structure and underlying logic. the new dataset provides over 1 million new, preprocessed and deduplicated recipes on top of the recipe1m+ dataset. to the best of our knowledge, it is the largest publicly available dataset in the domain. our dataset, contrary to recipe1m+, preserves unmodified ingredients quantities. it creates an opportunity to evaluate if the quantities are correctly generated by the model. in the future works, it could allow their normalization to a specific amount of servings. another interesting potential work is on unification of mostly ambiguous units (e.g. cups, pinch) with regards to the item they are describing, which could have many uses in and outside of the culinary world, and further unification using knowledge graphs @xcite . the challenges we faced can be generalized to the other examples of text generation tasks. therefore, we make this dataset public, expecting that it could enable new research in the area.