Article·AI & Engineering·Dec 22, 2022

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

Ben Luks
By Ben Luks
PublishedDec 22, 2022
UpdatedJun 13, 2024

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. Drybitterunder-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:

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

Oops, didn’t quite finish.

Make the Best out of What You Already Have

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

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:

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:

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:

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 .

Unlock language AI at scale with an API call.

Get conversational intelligence with transcription and understanding on the world's best speech AI platform.