Machine Cuisine. I’m a data scientist most of the time…
By: Katie-Rose Skelly
Tags: Machine Learning, Recipe, Baking, Artificial Intelligence, Food

I’m a data scientist most of the time. I also have an enormous sweet tooth — it’s what has gotten me through sports practices (everyone is hungry after water polo), making new friends in college (I am not as antisocial as I seem), and most of my work relationships (I don’t like giving hugs, but I’ll leave still-warm cookies on your desk).

I want to bring together some of my favorite things: AI, baking, and complete absurdity. To do this, I leveraged the most cutting-edge tools available. I used GPT-2 text generation from OpenAI and Recipe1M+ from MIT for my dataset to create just what we none of us knew we needed — some really, really questionable food.

For the Non-Techies

Here’s the watered-down version of what that means: a company called OpenAI had a computer look at lots and lots of words, sentences, and paragraphs that it collected from all over, and in a lot of really clever and computer-savvy ways taught it how to write paragraphs that seemed like a reasonably smart human (but sometimes with the attention span of a goldfish) wrote them. From here on out I will be calling this thing that writes text The Model, or GPT-2. Around that time, a bunch of researchers at MIT collected together a list of over a million recipes for their own research project and posted it online. They called this Recipe1M+, and I showed it to The Model as an example of what recipes are. Think about it like teaching The Model how to read and write in English(what OpenAI did), and then teaching it how to read and write recipes (what I did). Then, without it ever learning anything any rules of cooking and with no other context than the recipes I showed it, I let The Model start coming up with its own stuff.

For the Techies

I started off with the small GPT-2 text-generation model that OpenAI released this year and a huge file that contained a subset of the million+ text-based recipes that a lab at MIT compiled and published online. I used this recipe corpus to continue training on the GPT-2 model — it already knew how to make text, now I wanted to teach it how to make food. So far, I’ve let it train for just a few hours on a few hundred thousand recipes, and here are the results.

Recipe Names

Dinner's Fritters!

Spaghetti & Grilled Peas

Salsa Curd

Candy Cookies

Branco Crisp

Grilled Goat-Stuffed Cheese Pancakes

Smoked Pork Fondue Pizza Recipe

Pizza Dough Pizza Dough

Miguel's French Cheese

Mexican Sandwich Pudding

Lemonade Soup

Cheese Oatmeal

Satin and Spaghetti With Lemon

Bake Baked Potato Muffins

Veggie Pasta with Peppers, Grated Parmesan, & Garlic Parmesan-Layered Parmesan

Egg Bunch Sandwich

Spicy Chicken Breasts with Poblano Cheese

Sushi-Cabbage Dressing

Lemonade Soup

Oatmeal with Pecans, Goat Cheese and Pecans

Glazed Peppers, Carrots and Onions

Parmesan-Pepper-Garlic Pastry with Peppers And Garlic Chorizo

Pork Stuffed Roasted Spinach

Ribs and Eggs and Sweet Chocolate Dip

Chilled Chicha Bread

Baked Chicken Pot Pie

Ginger Apple-Stuffed Rice Casserole (Low Carb & Low Sugar)

Easy Tomato Gravy

Creamy Lemon Cheesecake

Korean Vegetables and Vegetable Oil

Korean Vegetables and Kibun

Bread Puffs Baked Beans With Basil Soup Recipe

Chicken and Tomato Soup

Pork Noodle Soup

Oatmeal Cheesecake

Coffee and Pancake Cake Recipe

Raspberry Lime Pie

Easy Carrot Bread

Ginger Bread with Cream Cheese

Baked Eggs in A Bowl

Cookie Crisp Fudge

Shrimp Stuffed Shells With Cucumber Stuffing Recipe

Raspberries Recipe

Apple Pie with Caramel Sauce (M.I.J.B.) (Berkley Steak Dinner)

Hot Cocoa Cake

Raspberry, Basil and Cranberry Lemon

Cookie Light Cookies

Bacon Cobbler

Mixed Greens And Pita Patties

Spicy Asian Fish and Rice

Panko Pizza Dough

Raspberry Pomegranate Smoothie

Melt in Two Cups of Butter

Beet Stew With Spicy Dill and Carrot

Pork and Beans & Nectarine Recipe

Sesame and Herb Potato Soup

Stuffed Peppers on a Stove Top and Kabob Kabob Kabob Kabob Kabob Kab-B Kabob Kabim Kabob Kaboom.

Hazelnuts and Peanut Nuts Casserole

Shrimp Stuffed Shells With Cucumber Stuffing Recipe

Honestly, these look a lot better than I thought they would. At first glance, they might be part of the table of contents for an actual recipe book. At the very least, they all look like obvious food choices. Like most of the GPT-2 text generated, it takes a second to figure out that something is wrong.

Once that second has passed, though, things start to look… off. Second glance is still subtle, with plausible deniability that these are not human-made— what exactly does Panko Pizza Dough taste like? Why (and how) do you put Grilled Peas with Spaghetti? And then things get weird. Who wants to eat Smoked Pork Fondue Pizza? Or Lemonade Soup!? Repulsive. And is Shrimp Stuffed Shells With Cucumber Stuffing something anyone would ever ask for?

Recipes

On what really might be the bright side here, while the model was first training most of the recipes with the weirdest names didn’t even have the ingredients to back them up. Here’s the recipe for Cheese Oatmeal as an example:

Cheese Oatmeal 1 cup whole milk, plus sugar

2 1/2 ounces whole unsweetened applesauce, divided

2 2/3 cups all-purpose flour

1 dash baking soda

2 tablespoons milk

Instructions:

Melt milk 1 1/2 inch at 300 degree.

Turn dough out onto a lightly floured surface and kneading over medium speed, about an 8-inch pie dish.

Divide applesauce in half, breaking into 4 equal parts as above.

Wash 2 large apples roughly in cold water, then, when well beaten, divide applesauce each into thirds.

In a separate bowl whisk together milk and sugar; beat in flour until combined.

In small mixing bowls, stir milk, 1 1/2 ounces of all-purpose flour, baking soda, and 1–2 teaspoons of baking powder; mix until…

So there’s really no oatmeal or cheese at all, despite the misleading title. But even so… I probably would not eat it. Let’s check out another few recipes.

Lemonade Soup 1 cup all-purpose flour

1/2 cup sugar

7 cups water

1 cup frozen corn

1 pinch white sugar

2 cups lemonade

Instructions:

Mix the dry ingredients until puree begins to separate.

Set aside.

Combine remaining dry ingredients and water to a liquid bowl.

Gently stir into the soup and let cool.

Remove to a clean bowl to cool thoroughly.

Drain from the bottom of the bowl and pour out into a small plastic container.

Place in the hot pot and cover with ice.

The water is much less stirring.

Bake for 7 to 8 minutes or until they start to pour out. Stuffed Peppers on a Stove Top and Kabob Kabob Kabob Kabob Kabob Kab-B Kabob Kabim Kabob Kaboom. 1 baguette, sliced 9x7 inches

1 box spinach, cooked, drained, and crumbled (I use the regular sized spinach but substitute the less than I use in this recipe)

1 tablespoon olive oil

1/2 cup kung fu sauce

1 1/2 packages kombu balls

2 large tomatoes, cored and chopped

2 cups chicken broth

2 cups water

1 teaspoon salt

3 large tomatoes, diced

1 tablespoon sweet chili sauce

1 tablespoon balsamic vinegar

1 teaspoon minced green onion

1 teaspoon garlic powder

Instructions:

Preheat oven to 400 degrees F. Spray a 9x13 pan and set aside.

Heat the oil in a skillet over medium heat.

I usually do that in the microwave for 20 seconds, then in the oven for 8.

Once I hit the mark, start flipping over the baguette so it is browned on all sides.

Continue flipping over until browned on all sides.

Take the kabobs out of the heat.

Cut each baguette in half, slice the kabobs in half and put each half in the pan, so that the kabob half of the baguette slice ends up on the middle.

Now place the kabob Kabob Kabob Kabob Kabob Kabom Kabob Kabom Kabob Kabob Kaboom.

Stir well in the spinach, oil, and salt.

Pour on top the tomatoes and the diced kung fu.

Now I just pour over top the cooked spinach and bake for about 20 minutes, until the tomatoes are tender.

Honestly, I don’t even know what a lot of these words mean, and even google has not been able to explain what kung fu sauce is. But it is impressive that the title of the recipe seems to be continuing throughout, suggesting that the model has learned by this point that it’s relevant to the rest of the text.

To be fair to this model, it’s young. It had only ever even seen pretty free-form writing until a few hours ago, and I have just been able to show it a few thousand recipes to teach it what cooking even is. The fact that it learned even this much in such a short time is pretty impressive. But I think I’ll wait until it has seen a little more of the world of cooking before I try actually making any of the foods it suggests. It should be just a couple more days…

Bonus Recipes

But please don’t make these. I do not think they will taste good.

Spicy Pork Chops (with a nice side of food poisoning?) 2 teaspoons Garlic, Chopped

2 Tablespoons Red Wine With Sesame Oil

2 teaspoons Sesame Seeds, Finely Chopped

1 Tablespoon Chopped Paprika

2 Tablespoons Mayonnaise

1 Tablespoon Hot Sauce

1 teaspoon Sugar

2 teaspoons Salt

2 whole Pork Chops (I Prefer 2 Chops; You Can Use More)

Instructions:

1.

Toss all ingredients thoroughly.

2.

Transfer to a bowl and serve.

Notes: The Pork Chops make a fabulous meal for guests.

They are much better with fresh veggies, and you can put the pork chops in a larger, larger bowl.

I also added a tablespoon of mayo in the bowl for just this, and a little bit of sesame oil and paprika.

(The pork chops will make it a lot easier to make the chops.) Lime Sangria 4 orange zest cubes

1 12–1/2 gal. orange marmalade

1/2 cup fresh lime juice

Instructions:

Fill glass with orange zest.

Add marmalade and lime juice.

Add 1/4 cup to 1/2 cup of ice, swirling to coat. Zesty Italian Salsa 2 large cans of diced tomatoes

1 lb hot red pepper, chopped

2 12 lbs lean grnd beef

2 large onions, diced

8 tablespoons of hot sauce

2 beef bouillon cubes

12 cup Worcestershire sauce

1 teaspoon italian seasoning

2 teaspoons garlic powder

2 teaspoons poultry seasoning

34 cup red wine

12 tablespoon italian powder

1 teaspoon salt

1 12 cans artichoke hearts

12 cup crumbled tortilla chips

Instructions:

Drain chopped onions.

Mix all ingredients in large bowl with a spoon.

Refrigerate for 1–2 hours.

Serve on crackers.

Sprinkle with onions and serve.

Yum.

Thank You:

Amanda Guisbond for the inspiration for this

https://medium.com/@ngwaifoong92/beginners-guide-to-retrain-gpt-2-117m-to-generate-custom-text-content-8bb5363d8b7f for the great how-to on using GPT-2 to generate whatever I wanted (in this case recipes)

https://github.com/openai/gpt-2 OpenAI for the model

https://arxiv.org/abs/1810.06553 For a really excellent dataset