Authors: Disha Moolya, Sakshi Pansare, Anushree Kshirsagar, Prof. Sonali Bodekar-Kale
Certificate: View Certificate
Finding new recipes daily with the ingredients in hand is a difficult task that leads to people looking at different recipe websites and cookbooks. But it is often not possible to find the recipe one is looking for with the constraint of ingredients. The objective of this paper is to build a web application so as to cater to this specific problem faced by people. The proposed system takes ingredients as an input and gives machine generated recipes with the help of deep learning to the user. The recipe generated model will consist of title, ingredients and instruction reflecting the dataset used to prepare the model for deep learning. The system also consists of interactive features in the user interface enabling the user to save and access the generated recipe later on.
Everyone enjoys new, delicious, healthy food and prefers homemade meals over food brought from outside. But when it comes to cooking we don’t want elaborate, long complex recipes instead we want quick, easy and efficient options. Even in terms of obtaining ingredients, sometimes getting ingredients can be tough as we experienced recently in pan- demic. Hence, it is often preferable to have recipes that use limited ingredients or to have recipes that match with personal availability.
With the ever growing popularity of various cooking sites, blogs and books it is evident that people are always on a lookout for innovative and interesting recipes.
It is also observed that the use of online media and digital medium makes cooking more accessible.This gives us more reason to find solutions to simple problems such as recipe generation using deep learning.
Cooking is considered no less than art, it is a creative process, procuring recipes consisting of the right combination of flavors. By creating a recipe generator we can allow the creation of unique dishes with unique combinations, it is a system that combines deep learning along with knowledge contributing to computational creativity. The system should be able to learn how to imitate human creativity, to be able to generate a recipe.
In this paper, we propose a cooking recipe generator which will produce a recipe as output when the user inputs ingredi- ents. A deep learning model is created and trained to generate the recipe. Our project focuses on creation of a number of unique and creative recipes based on the ingredients entered by the user, thus providing recipes as per the user’s ingredient availability.
A. Recipe Generation Using Deep Learning
With the use of deep learning it is possible to train the model based on the dataset and generate system derived unique recipes. The model is trained with the dataset that consists of three logical sections namely title, ingredients and instructions. The model learns how to generate instruction for a given set of ingredients in the training process. The title for the generated recipe is developed by the system using the ingredients along with a random generated word. With the use of Natural Language Generation the model is able to produce the instruction in the form of steps for the generated output recipe.
II. RELATED WORK
In this section we discuss about related works in terms of recipe generator. To get the better understanding of the methods used and how they are different from the existing recipe generation methods an overview of machine learning techniques which are applicable are given as a background. Our topic of recipe generation using machine learning algorithm is quite novel and, as a result, there were not too many previous works found.But there are few projects which are somewhat similar to our work.
In  a paper by Florian Pecune,Lucile Callebert,Stacy Marsella at Scotland,UK,proposed a model where their ap- proach was to use collaborative filtering and the algorithms they used were ALS,BPR, LMF in that they are basically inclined towards healthy dishes also,they have an additional feature wherein the users can rate the recipes on how it turns out. Our intake on this paper was to add a rating feature to the recipes generated by our machine.
In , the authors Keiji Yanai, Takuma Maruyama and Yoshiyuki Kawano at Tokyo,Japan,have proposed the model which was designed to scan a particular food item and give related recipes to the user. They used object recognition for allowing the system to suggest recipes and the algorithm they used is SVM classifier and from this we got an idea to scan multiple items collectively and come to a single recipe as a conclusion.
In the authors Chloe Kiddon, Luke Zettlemoyer, Yejin Choi, has proposed a system where their main aim is to build neural checklist model, a recurrent neural network that transforms data by storing and updating the outupt of text recipes which should be mentioned somewhere in the BLEU, METEOR, LSTM, HDC algorithms and techniques, thus the use of Recurrent Neural Network(RNN) language model can generates globally coherent text by keeping track.
In the author Neha Setia, has proposed a system where they generate chains of cooking events that fit to a list of ingredients given beforehand without direct supervision and experimented with generating novel chains of events that are still coherent on the same list and they further used LSTM, BLEU score(evaluation) algorithms. So we can use Neural Machine translation approach which can be further elaborated for recipe generation.
In paper ”Building a Food Recommendation System” the author Lu´?s Rita  has proposed the system where their main goal was to collect as large as possible and freely available collection of recipe data (Recipe1M+) and build a recommen- dation system.They used Word2Vec, SVC algorithms to build their model and our take on this paper was to build a dataset which includes varieties of food recipes which will enhance our model’s accuracy.
In paper they build a model using computational NLP solution based on the modern machine learning techniques to generate recipe.They used techniques such as SpaCy framework,GPT-2, TPU. From this we got to know the training on faster accelerators such as TPU cloud allowed this project to train larger GPT-2 versions, which may improve quality of generated recipes even further. Similar to the above paper the next one  where their main aim was to build a novel online recipe generation and evaluation system. That can provide two modes of text generation, namely instruction generation from given title and ingredients and next ingredient generation from recipe title and cooking instructions. They also used similar technique of Fine tuning GPT-2 and Tensorflow.The model opted in the paper consist of feature of saving the recipes in favorite section for future references and their recipe evaluation module also enabled the users to easily check the quality of the generated recipe and store the results for later reference.
Also there are similar works related as in  the authors of this paper has build and trained the model using NLP Techniques and then use character-based RNN to generate new ingredients .The NLP technique which the used is NLTK Unigram Tagger and this paper inspired us to use different techniques of NLP to generate list of ingredients.
III. PROPOSED METHODOLOGY
The objective of our project is to develop a recipe generator accessible to users that can input ingredients and receive an innovative recipe as output. The goal is to use the most efficient algorithm for recipe generation in order to generate a valid and coherent output. The proposed system will provide recipe by ingredient search to the users thus minimizing the hassle to find a recipe suitable for every individual user.
B. Project flow
Finding and gathering the most favorable dataset for the project in terms of content and size. Preparing the data to ensure it is ready to feed into the model and developing the model using deep learning.
The project flow from the user end can be perceived as the following: The user interface consists of a text box to input a number of ingredients, the input is processed into the back- end by the model and 3 different recipes will be displayed as output to the user.
C. Use Case
The user inputs ingredients and receives system generated recipes. The signup and login feature enables the user to save the generated recipes and retrieve them later from the favorites section.
For deep learning algorithms a large amount of data is required to train the model to perform well. Hence, a dataset that consists of data from Epicurious and recipe box which were freely available online is used in this project. The dataset has a combination of 20k recipes along with rating and nutrition from Epicurious and 125k recipes along with ingredients with proportions from Recipe box. The dataset was reduced to 3 attributes as title, ingredients and instructions (as in the procedure of the recipe).
B. Data Pre-Processing Steps
For creation of the model, in order for the data to be processed by the model it is essential to clean and preprocess the data. The data preprocessing for recipe generation model consisted of a number of steps such as:
4. Vectorizing dataset: word Embedding into dense vectors also called as vectors or numerical representation for words
5. Add padding to the sequence: adding a stop word to the end of each recipe with the use of utility function and to make them have the same length overall.
6. Split examples on ‘input‘ and ‘target‘ texts: creating a copy and forming the input and target texts.
C. Model Developement
Creating a text generation model using LSTM in keras tensorflow, making use of character based LSTM which essen- tially generates the entire text by predicting the next character. Use of different hyperparameters helps find the best suited to approach for next character prediction thus text generation. The number of layers used in the model development as well as the number of training epochs set were found to be defining factors in model performance. The project also made use of different optimizer and loss functions in order to improve the model performance.
For the minimization of loss a number of changes were made in terms of layers, epochs, learning rate, optimizers and loss functions.
We made use of different optimizer namely Adam optimizer and RMSProp that were trained and tested against different epochs, no of steps, learning rate to gauge the respective loss and accuracy so as to develop the most accurate model. Use of Adam optimizer with 500 epochs and learning rate 0.0005 resulted in the least loss.
Once ideal parameters were set and valid output was gen- erated by the model, it was deployed into a web application.
We would like to express gratitude towards our guide Prof.Sonali Bodekar-Kale of Usha Mittal Institute of Tech- nology for their support and mentorship in completion of our project on Recipe Generation using Deep Learning. Our sincere appreciation to our examiners from Computer Science and Technology Department for their valuable encouragement and insightful inputs.
We were able to develop and deploy a recipe generator that is able to generate a logically sound, valid with semantic mean- ing recipes. The project enabled understanding the changes in output affected by the change made in hyperparameters. After successful creation of the model generating seemingly precise model we can move ahead to the next step of adding features to enhance user interactions. In future the model can make use of pre-trained transformers for definite and cohesive text generation thus correcting the model prediction and accuracy. Furthermore to make the project ideal and efficient other filters for searching along with search by ingredients can be added, such as search by image, search by cuisine type, health monitoring of recipes generated. Adding another approach to recipe generation such as recipe generation from title rather than ingredients, can be an innovative direction to recipe generation using deep learning.
 Florian Pecune,Lucile Callebert,Stacy Marsella, ”A Recommender Sys- tem for Healthy and Personalized Recipe Recommendations”,University of Glasgow, Scotland:UK,September 2020.  Keiji Yanai, Takuma Maruyama and Yoshiyuki Kawano,”A Cooking Recipe Recommendation System with Visual Recognition of Food In- gredients”, The University of Electro- Communications,Tokyo:Japan,in 2014.  Lu´?s Rita ,”Building a Food Recommendation System”, Imperial College London ,in March 2020.  Neha Setia,”Generate recipes using multi-ingredient aware LSTM”,July 12, 2019.  Micha? Bien´, Micha? Gilski, Martyna Maciejewska, Wojciech Tais- ner,”Cooking recipes generator utilizing a deep learning-based language model”,February 2020.  Mikael Davidsson,”Using machine learning to generate recipes that actu- ally work Cooking with data science”, Apr 26.  Amaia Salvador, Michal Drozdzal, Xavier Giro-i-Nieto, Adriana Romero,”Inverse Cooking: Recipe Generation from Food Images”,June 16, 2016.  Laura Ana Maria Bostan,“Ingredient-driven Recipe Generation Using Neural and Distributional Models”,17 July 2017.  Rebecca Coulson ,”Generating a Dessert Ingredients List Using NLP”,February 14, 2021.  Chloe Kiddon, Luke Zettlemoyer,Yejin Choi,”Globally Coherent Text Generation with Neural Checklist Models”,[nd].  https://www.tensorflow.org/api docs/python/tf/keras/preprocessing/text/ Tokenizer  https://www.tensorflow.org/api docs/python/tf/keras/preprocessing/sequence/ pad sequences  Mike Kaput,Natural Language Generation (NLG): Everything You Need to Know,April 20th,2022.
Copyright © 2022 Disha Moolya, Sakshi Pansare, Anushree Kshirsagar, Prof. Sonali Bodekar-Kale. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.