All posts

The What, Why, and How of AI-Generated Recipes Using ChatGPT

The What, Why, and How of AI-Generated Recipes Using ChatGPT

The New York Times recently published a video wherein GPT-3—the large language model (LLM) from OpenAI which can generate text with astounding similarity to that produced by a human writer—is tasked with generating recipes for a Thanksgiving spread. 

Giving the model thoughtful and personalized prompts, food writer and influencer extraordinaire Priya Krishna coaxes out a series of personalized Thanksgiving recipes. All told, I like the video. It playfully highlights the mysticism of these large language models without falling into the trappings of dystopian, “robots will enslave humanity” fear mongering while simultaneously avoiding the point-and-laugh spirit of some similar content. As a demonstration of a sophisticated generative AI model, it’s approachable to the layperson and, if you’re willing to use up your GPT-3 credits on a mediocre Thanksgiving meal, actionable.

After experimenting with prompts, Priya pumps out a series of creative takes on traditional Thanksgiving dishes that look professional with just the right touch of rustico. Looks can be deceiving, though. These recipes met resounding disapproval from the panel of veteran NYT food writers. Dry, bitter, under-sweetened: their criticisms are eerily similar to those you would expect of a meal prepared by a naive cook. Priya concludes the video by stating that such technologies are simply “not ready” for the task of recipe development.

In spite of its shortcomings, I’m not so ready to completely discount the utility of LLMs in the kitchen. Having used the technology myself, I’m convinced that these large language models (LLMs) can be an invaluable tool to the home cook. In this article, I hope to slightly demystify the inner-workings of such a model, convince you that you could and should give them a try, and even leave you with some pointers on how to get started using LLMs for your home cooking. This article is for anyone, from the seasoned research engineer, to the AI enthusiast, to those who had to google what “AI” stood for before finishing this sentence. It’s easy to be intimidated by these technologies, but with a little bit of critical thinking and creative adaptation, I think just about anyone can make LLMs a part of their home cooking arsenal.

How the Large Language Model sausage is made

I know, I know. There are about a million-and-one layperson explanations of machine learning out there already. I have no intention of further saturating that market. That being said, I figured a small primer might be useful to help readers better understand the results, and how to best shimmy the model towards the best possible outputs for your purposes.

A machine learning model approximates the data. That’s it. GPT-3 is trained to predict text scraped from throughout the internet. To grossly oversimplify the training process, the model is given a sentence from some text resource as a prompt, and trained to predict the following sentence(s). So when you give it your prompt, the text will be what is most likely to follow it, based on the text it’s seen during training. This isn’t new. In fact, it’s been a de facto standard for training LLMs (or language models in general) for quite some time. What makes GPT-3 innovative is the sheer amount of data used (over 175 billion variables!), as well as the breadth and specificity of its retention of the resources it’s seen.

In addition to GPT-3’s propensity for what I’ll call fill-in-the-blanks, I want to speak about language models and their ability to perform analogical reasoning. Essentially, language models quantify meaning based on the contexts in which the word appears. Because of this, the model can make analogous comparisons, associating words as being synonyms, opposites, or perform even finer analogous comparisons. For instance, the model has likely seen “asparagus” come up in contexts that tend to surround “vegetable. Same for “celeriac.” However, “asparagus” appears surrounded by words that pattern with “summer,” whereas “celeriac” patterns with “winter.” The model can therefore reason that celeriac is similar to asparagus insofar as they’re both vegetables, but belong to different seasons.

I hope this explanation eases your anxieties about trusting some black-box robot to make you dinner. You can think of GPT-3 as an aggregator of the internet’s food and recipe content (among a zillion other topic areas). Based on what you give it as input, the model stitches together information from different resources to best meet the conditions you set out with your prompt. As you’ll see, this can be as disappointing as it is mystifying.

So, LLMs can make recipes. They’re not magic, and, to put it crudely, they’re kind of just regurgitating bits and pieces of what they’ve found on the internet, so why use them? Let’s say you want to make chocolate chip cookies. What’s the best chocolate chip cookie recipe? Google it. “best chocolate chip cookie recipe”. Oh, hey, you found it! And you made it! What’s that? It wasn’t the best? You’re saying this amateur Allrecipes contributor failed to account for the fact that their oven runs 30 degrees cooler than the average person’s? Or you didn’t realize their Australian cups were different from the US cups used for the conversion chart you found online? 

“But Ben,” you say, “Allrecipes uses star ratings to favor higher-rated and more popular recipes.” You’re right. I’m in no position to question Chef John’s aptitude for developing approachable, working recipes. But if your search results turn up the quote-unquote “best” recipes first, then the same is true for the recipe developers who are doing their own research. These folks have baked a dozen odd batches of cookies based on recipes in proportion to their respective popularities. They’ve even read and considered the comments before settling on their own ratios and methodology. This newly developed, cutting-edge chocolate chip cookie recipe will in turn influence future recipe developers in proportion to its popularity and thus “good-ness” (said with naive optimism), defined as you so choose.

Why is this all relevant? Again, a model learns to approximate the data. This means that the parameters available to a model tasked with outputting a chocolate chip cookie recipe exist in proportion to the recipes it was fed during training. It may swap AP flour for bread flour, as many recipes do, it may brown the butter, or combine brown and granulated sugar in any number of proportions. But, you can rest assured that it won’t call for 2 cups of baking soda, or replace the chocolate chips with sardine heads. The ingredients aren’t the be-all-end-all of a model’s knowledge of cookies, but rather a sample from the realm of variations it was likely to have seen during training.

Great, so the recipe says cups. Are those US cups? Canadian? Australian? It makes a difference. Thankfully we can equalize that all by asking for weighted measurements. Will the recipe be the same? No. Can we at least trust it to work? I can’t tell you what to do, but I sure would.

Want to nudge the cookie recipe in one direction or another? Do you like the gooey kind, or are you on more of the short-bread-y, crumbly side of things? In either case, tell the model. It’s primed for further prompting. If you’re after that rigorous, chef’s-jacket, metal-prep-table laboratory precision of folks like ChefSteps, Kenji, and America’s Test Kitchen, then ask for weighted measurements. On the other hand, if you like the low commitment, set-it-and-forget it cozy cabin feel of a lifestyle blog recipe, try throwing in phrases like “easy,” “one-bowl,” “30-minute,” etc. Do you want overly verbose, dogmatic, and superfluous instructions to dirty extra dishes in pursuit of a sense of purpose? Then try Bon Appetit.

With LLM-generated recipes, you’re in control. Or, at least, you guide the process. Rather than scouring the internet for ingredients and methods that meet your resource and preference constraints, you can ask the model to write a recipe which meets you where you’re at.

LLMs As Recipe Co-Writer, by Way of Example

We’ve seen the what and why, now let’s delve into the how

Barring any in-depth guide on prompt engineering, I thought I’d throw together a couple of use cases to get you started working GeePee into your cooking routine, regardless of whether you’re a Michelin-starred chef or a newcomer to cooking at home. 

Here’s a list of principles for use, along with examples that I personally have found particularly useful. Note that these examples were performed with ChatGPT. I’ve referred to GPT-3 throughout this article not as a specific model, but as an umbrella for the derivatives of the GPT-3-derived models. The ChatGPT technology is an improvement on the original GPT-3 release, and as you’ll see, I think the ability to follow up on your queries is especially useful here. Lastly, and most importantly, ChatGPT  is free for the time being, so I’m not wasting any of my precious credits drumming up examples. Without further ado, here are some of my tips for including GeePee in your culinary adventures.

Generating inspiring meal plans

If you’re feeling bogged down by repetition or just looking for some creative inspiration, ask for open-ended suggestions:

suggest a multi course dinner party menu with winter ingredients

Here is a sample multi-course dinner party menu that features winter ingredients:

Appetizer: Baked brie with cranberry and pecan topping served with crackers

Soup: Creamy roasted chestnut soup with crispy pancetta

Salad: Mixed greens with roasted root vegetables and a maple vinaigrette

Entree: Braised short ribs with mashed sweet potatoes and steamed broccoli

Dessert: Spiced apple tart with a dollop of vanilla bean ice cream

This menu includes a variety of dishes that are perfect for a winter dinner party. The soup, salad, and tart can be made ahead of time, so that you can focus on cooking the entree just before serving. I hope this menu inspires you to create a delicious and memorable dinner party with winter ingredients! Let me know if you have any questions.

Now we’ve got a starting point. If you need some specifics, don’t be afraid to follow up.

can you give me a detailed recipe for the dessert?

Here is a detailed recipe for the spiced apple tart with vanilla bean ice cream:

Ingredients:

For the crust:

1 1/2 cups all-purpose flour

1/2 cup unsalted butter, cold and cubed

1/4 cup granulated sugar

1/4 tsp salt

1 large egg yolk

1 tbsp ice water

For the filling:

2 large apples, peeled and sliced

2 tbsp unsalted butter, melted

2 tbsp granulated sugar

1/2 tsp ground cinnamon

1/4 tsp ground nutmeg

For the vanilla bean ice cream:

2 cups heavy cream

1 cup whole milk

1 vanilla bean, split lengthwise and seeds scraped

3/4 cup granulated sugar

6 large egg yolks

Instructions:

To make the crust, combine the flour, butter, sugar, and salt in a food processor and pulse until the mixture resembles coarse meal. Add the egg yolk and ice water and pulse until the dough comes together. Turn the dough out onto a lightly floured surface and shape it into a disk. Wrap the dough in plastic wrap and chill in the refrigerator for at least 30 minutes.

Preheat your oven to 375°F (190°C) and lightly grease a 9-inch tart pan with removable bottom. On a lightly floured surface, roll out the dough to a 12-inch circle and transfer it to the prepared tart pan. Press the dough evenly into the bottom and up the sides of the pan. Trim the excess dough from the edges and prick the bottom of the crust with a fork.

To make the filling, combine the sliced apples, melted butter, sugar, cinnamon, and nutmeg in a large mixing bowl and toss to coat. Arrange the apple slices in a circular pattern on top of the crust, starting from the outer edge and working your way in.

Bake the tart for 35-40 minutes, or until the crust is golden brown and the apples are tender. Let the tart cool for at least 30 minutes before serving.

To make the vanilla bean

Oops, didn’t quite finish.

and how do you make the ice cream?

To make the vanilla bean ice cream, first combine the heavy cream, milk, and vanilla bean seeds in a medium saucepan and bring to a simmer over medium heat. In a separate bowl, whisk together the sugar and egg yolks until the mixture is pale and thick. Gradually whisk the hot cream mixture into the egg yolk mixture, then return the mixture to the saucepan. Cook over medium-low heat, stirring constantly, until the custard thickens and coats the back of a spoon.

Pour the custard through a fine-mesh strainer into a clean bowl and let it cool to room temperature. Cover the bowl with plastic wrap, making sure the plastic wrap touches the surface of the custard to prevent a skin from forming. Chill the custard in the refrigerator for at least 4 hours or overnight.

When the custard is well chilled, transfer it to an ice cream maker and churn according to the manufacturer's instructions. Transfer the ice cream to a container and freeze until firm, at least 2 hours. Serve the vanilla bean ice cream alongside the spiced apple tart. I hope you enjoy this recipe! Let me know if you have any questions.

Make the Best out of What You Already Have

Ask for suggestions for meals with the ingredients you have on hand:

how can i use up salmon, cabbage and sweet potato

There are many delicious ways to use salmon, cabbage, and sweet potato. One option is to roast the sweet potato and cabbage in the oven until they are tender, then top them with salmon that has been baked or pan-fried. You could also make a salmon and sweet potato soup by sautéing the vegetables in a pot, adding broth, and simmering the salmon in the broth until it is cooked through. Another option is to make a salmon and sweet potato curry by sautéing the vegetables in a pot, adding curry paste and coconut milk, and simmering the salmon in the sauce until it is cooked through.

You’ll notice that the suggested additional ingredients tend to be pantry staples or things you’ll likely have on hand anyway, such as onions, garlic, and oil.

Cut Right to the Chase

If you want quick, succinct advice and don't want to sift through bloggers' life stories, simply ask a question:

what flavors pair well with rabbit?

Rabbit pairs well with a variety of flavors, depending on the cooking method and the recipe you are using. Here are a few common flavors that go well with rabbit:

Herbs: Rabbit goes well with herbs such as rosemary, thyme, parsley, and sage. These herbs can be used to season the rabbit before cooking, and they can also be added to the cooking liquid or sauce.

Garlic: Garlic adds depth and flavor to rabbit dishes. It can be minced and added to the rabbit before cooking, or it can be roasted along with the rabbit.

Mustard: Mustard adds tanginess and a little bit of heat to rabbit dishes. It can be mixed with a little bit of oil or butter and brushed onto the rabbit before cooking, or it can be used to make a sauce or marinade.

Citrus: Citrus fruits such as lemon, lime, and orange add a bright and refreshing flavor to rabbit dishes. The juice and zest of these fruits can be used to marinate the rabbit, or they can be added to the cooking liquid or sauce.

Wine: Wine adds richness and depth to rabbit dishes. It can be used to deglaze the pan after searing the rabbit, or it can be added to the cooking liquid or sauce.

I hope these flavor suggestions inspire you to try new and interesting rabbit dishes at home! Let me know if you have any other questions.

Tread Carefully: You Get What You Ask For

The more specific you make your requests, the more generic you’ll want to be. This goes back to our earlier discussion about GPT-3 as an aggregator. If you ask for a cheesecake recipe, you’re drawing on a huge inventory of existing resources that GPT-3 has seen during training. However, circling back to Priya Krishna’s Thanksgiving, if you ask for an Indian spiced asparagus cheesecake recipe, that’s what you’re gonna get:

suggest an indian spiced asparagus cheesecake recipe

Here is a simple recipe for Indian-spiced asparagus cheesecake that you can try at home:

Ingredients:

1 cup graham cracker crumbs

1/4 cup melted butter

16 oz cream cheese, softened

1/2 cup sugar

3 eggs

1 tsp vanilla extract

1/2 tsp garam masala

1/4 tsp turmeric

1/4 tsp ground cumin

1/4 tsp ground coriander

1/4 tsp ground ginger

1/4 tsp ground cardamom

1/4 tsp black pepper

1/4 tsp salt

1 cup chopped asparagus

Directions:

Preheat your oven to 350°F (180°C) and lightly grease a 9-inch springform pan.

In a small mixing bowl, combine the graham cracker crumbs and melted butter. Press the mixture into the bottom of the prepared pan to form the crust.

In a large mixing bowl, beat the cream cheese and sugar together until smooth. Add the eggs, one at a time, beating well after each addition. Stir in the vanilla extract and the spices (garam masala, turmeric, cumin, coriander, ginger, cardamom, pepper, and salt).

Stir the chopped asparagus into the cream cheese mixture. Pour the mixture over the crust in the pan and smooth the top with a spatula.

Bake the cheesecake for 45-50 minutes, or until the center is set and the edges are golden brown. Let the cheesecake cool to room temperature, then chill in

LLMs may be able to write convincing text with style, but they have no taste. You can see the model Frankenstein-ing together “cheesecake,” “indian spices,” and… asparagus. Sure, one could conceivably conjure a savory cheesecake recipe which uses asparagus and this assortment of spices. But, like, is such a concoction even a cheesecake at that point? Seems more like a quiche overburdened by cream cheese, but I digress.

That being said, if you stick to the tried-and-true combinations, you’re set for success:

suggest a raspberry chocolate cheesecake recipe

Here is a simple recipe for raspberry chocolate cheesecake that you can try at home:

Ingredients:

1 cup graham cracker crumbs

1/4 cup melted butter

16 oz cream cheese, softened

1/2 cup sugar

3 eggs

1 tsp vanilla extract

1 cup dark chocolate chips

1 cup fresh or frozen raspberries

Directions:

Preheat your oven to 350°F (180°C) and lightly grease a 9-inch springform pan.

In a small mixing bowl, combine the graham cracker crumbs and melted butter. Press the mixture into the bottom of the prepared pan to form the crust.

In a large mixing bowl, beat the cream cheese and sugar together until smooth. Add the eggs, one at a time, beating well after each addition. Stir in the vanilla extract.

Melt the chocolate chips in a microwave-safe bowl or in a double boiler. Stir the melted chocolate into the cream cheese mixture until it is well combined.

Pour the cheesecake mixture over the crust in the pan and smooth the top with a spatula. Scatter the raspberries over the top of the cheesecake.

Bake the cheesecake for 45-50 minutes, or until the center is set and the edges are golden brown. Let the cheesecake cool to room temperature, then chill in the fridge for at least 2 hours before serving.

I hope you enjoy this delicious raspberry chocolate cheesecake! Let me know if you have any questions.

If you’re not sure what goes with what, then back to my previous point: just ask! It stands to reason that GeePee will understand food combinations that it itself suggests! So, again, specific and generic. As you move from the model’s aggregate knowledge to individual examples, you’ll see it regurgitating pieces of information, more so than anything that can be considered “creative reasoning”.

Where Do We Go From Here?

We’ve seen GPT-3 make a passable if somewhat haphazard plan for Thanksgiving dinner. We’ve learned enough about how the model works to best use it to our advantage, with some pointers for starting out. What now? Well, that’s up to you. Use up that wrinkly carrot sitting in the back of your crisper drawer, or put together a holiday feast. 

Who knows, maybe “an AI generated this recipe” could be the new “you know, that turkey is actually tofurkey”. Remember: The internet is huge; it’s all out there already. Think of GPT-3 as a tool for putting it together in ways that best suit your needs. You may be head chef in your kitchen, but why not consider GeePee as your sous?

🇳🇱 Eet smakelijk.

If you have any feedback about this post, or anything else around Deepgram, we'd love to hear from you. Please let us know in our GitHub discussions .

More with these tags:

Share your feedback

Thank you! Can you tell us what you liked about it? (Optional)

Thank you. What could we have done better? (Optional)

We may also want to contact you with updates or questions related to your feedback and our product. If don't mind, you can optionally leave your email address along with your comments.

Thank you!

We appreciate your response.