Introduction:

Cooking is hard work. Creating new recipes is even harder. A good dish combines the contrast of different tastes, textures, and colors. We’re not gonna put anyone through chef school, but we do hope to learn some interesting relationships between ingredients and the subtlety and structure of recipes using a deep learning model. By parsing and training on thousands upon thousands of recipes, we hope to eventually be able to generate a novel recipe of our own.

Related Work:

Stanford master students have previously worked on a paper named Forage: Optimizing Food Use With Machine Learning Generated Recipes. In the paper the researchers attempted to create an LSTM model to generate a recipe given a constrained list of ingredients in order to best make use of left-overs and fridge ingredients.

Forage: Optimizing Food Use With Machine Learning Generated Recipes

Data:

We will be using the meal-master dataset. There are up to 158k+ recipes in the MM database, and we will be selectively training on 100k of those recipes.

Methodology:

We first filter the meal-master dataset by putting a cap on the length of each recipe (ingredients + instructions). We have preliminarily set this value to be 2000 characters. We then pad recipes that have less than 2000 characters with a special character to denote the end of a recipe. For the word embeddings, we are tokenizing by characters to improve the model’s ability to handle unknown words. This way the model will be able to learn not only English grammar of words, but also the structure of words themselves and hopefully understand new words (are they actions or possibly ingredients?) We are using 256 for the embedding dimensions and 1028 for the LSTM hidden dimension. For the LSTM, we are going to be utilizing the keras model LSTM. I think getting the model to learn the lengths, form and format of a recipe will be hard. However, it’ll be even harder for it to remember the ingredients that it itself generated earlier in the paragraphs. If there is too much information to learn we may have to reduce the complexity our embeddings have to encode by increasing the vocabulary size (using words instead of just characters). We could also experiment with generating the recipes and the ingredients independently.

Metrics: What constitutes “success?”

Base goal

  • Legible English sentences generated by LSTM (regardless if food looks disgusting)
  • For the base goal we will simply eyeball this and present the results on our poster.

Target goal

  • Create recipes that are grammatically correct and instructions that can be followed to create a real dish (nothing like fry fish in water etc.)
  • We can show our peers recipes and random and blind test them. We want to achieve an rate of “10% is something you can realistically cook”.

Stretch goal

  • We can implement K-Means and try to evaluate the distance between centroids using Euclidean and Cosine distance.

Ethics:

Why is Deep Learning a good solution to this problem? Deep learning is a good approach to this problem because originality is a key metric. Normal statistical methods that simply connect ingredients to other ingredients don't work as well here because the resulting recipes would not be original or novel.

What broader societal issues are relevant to your chosen problem space? One potential societal issue of using deep learning for cooking is that the results could be used to benefit a small group of people. Training a really good ingredient algorithm will be really hard. Large NLP models on the scale of GPT-3 require thousands of hours and millions of dollars to train. This could mean that large restaurant chains and conglomerates would have an unfair advantage over mom and pop shops and further consolidate their reign. It would also be a big disaster for the environment.

Division of labor:

The main parts of our project are: data collection and cleaning, word embeddings, and designing and coding the model.

  • Laxman worked on data collection and cleaning since he has a lot of experience from past datathons and hackathons
  • Anthony worked on word embeddings and designing the model
  • Andrew worked on designing the model and making higher level decisions regarding the project such as character vs word embeddings We all collaborated on debugging the code and tuning the models

Initial Proposal

Midpoint-Reflection

Final Report

Built With

Share this project:

Updates

posted an update

Devpost 2: Team Salad Party

Introduction:

Cooking is hard work. Creating new recipes is even harder. A good dish combines the contrast of different tastes, textures, and colors. We hope to learn some interesting relationships between ingredients and the subtlety and structure of recipes using a deep learning model. By parsing and training on thousands upon thousands of recipes, we hope to eventually be able to generate a novel recipe of our own.

Challenges:

We wanted the model to be versatile so we chose a character based tokenizer instead of word based. However, it gave out very random characters for the title like “ujd$’2_%T5’8DAøs|Q‭unded strawberries” and “Ajy%3î••qpppllypook”. It has been really hard to overcome this, even after a lot of hyper parameter tuning. Another challenge was (and still is) to have the model come up with ‘high serendipity’ recipes. It’s nice and all that the model churns out recipes that make sense, but we want it to produce something that has never been seen before and also tastes good. We tried various things to achieve this: fusion recipes, character based tokenizer, using different recipe sources but our main focus has obviously been to have it churn out legible english. Insights: Are there any concrete results you can show at this point? As I mentioned earlier, we do have the character based model working but it’s outputting random characters in the title. Here is a sample output


Title: ujd$'2_%T5'8DAøs|Q‭unded strawberries
    Ingredients:
    1/4 cup blad puree, vinegar
      Salt and pepper to taste
Instructions: 
      Preheat oven to 400 degrees F0 to 10 minutes or until inoprediated and cooked through, are a little about 1 atchotuth. 
      Let stand ubte-remove excest foil. Then slice the should mixer until frag and hust as neel yenuper. Add the onions, garlic, and cool.
      Add the pecoass and vanilla ex cool off thyme begins to simmering craacher.
      Put the paumation in a packs in a bowl, combine the pastry for 1 minute. Scatting freeze rush of the sausage on top of the filling up simonid. Between the spoon mixture in the eggplant spreading it half with a lit (roaster Salt.) Turn ail inut sandwich and surranach with the same meal.;

Plan:

We definitely did not expect to have it work the first time, but we did expect it to output legible english. We now need to rethink the project a little bit and switch to a word based model. The downside to this is that if the user inputs an ingredient (word) that the model has not seen before, it wouldn’t work, so it is limiting in a sense. But at the same time, a good, large dataset should cover a solid amount of ingredients and not leave much behind.

Log in or sign up for Devpost to join the conversation.