Prompt Like a Cook: AI Lessons from the Kitchen
Mastering the Art and Science of AI Interactions Through Culinary Wisdom
It was a spring afternoon—I must have been around 7 years old—when my parents went out shopping for grocery, and I decided to bake. Having watched my mother bake cakes many times, I knew exactly how to start: Take some butter and mix it well with sugar. Then add some eggs and whisk until the mixture turns a pale color. But what came next? I realized I had forgotten some crucial ingredient. So I stood in the kitchen until my mother came back to help me finish my creation. (Spoiler: It was the flour).
Everybody has their own "missing flour" or "too much chili sauce" moments in cooking. While feeling embarrassed back then, I now know that this episode taught me a valuable lesson: When you cook, you need to know your basics, your ingredients, and techniques.
Using Large Language Models (LLMs), like ChatGPT, often feels like cooking. You pick an approach, gather your utensils and ingredients, and get going. If you know your basics, you will bake something good. Even better: You won't have to wash up afterwards.
Selecting Quality Ingredients for Your Prompts
Using quality ingredients is crucial for a good dish. Yes, you can still make use of that neglected cabbage hermit in the back of your fridge, but the best soup is made from fresh stock. The right amounts are also important. As counterintuitive as it seems, salt makes sweet dishes taste richer—but only if you use a pinch. (I once mixed up the sugar and salt bowls in the preparation of a Tiramisu; it was the worst dessert ever.)
Just as the finest dish demands the right balance of high-quality ingredients, crafting prompts for LLMs like ChatGPT requires similarly high-quality input. When working with chat-based AI tools, your ingredients are symbols—this mostly means words and sentences, but also includes signs, punctuation, emojis, and other expressions of meaning. LLMs are trained on billions of these symbols, which teaches them to react to new words their users give them. The quality and arrangement of these symbols are the only things they can base their responses on, so choosing them wisely is important.
"Quality" means using the right words for a specific context in a logical structure. The more precisely a word fits the task you give the LLM, the better it will be able to find the right words to answer. This can mean replacing vague words with specific ones (vague: "How can I become good at chess?", specific: "How can I become strategic at chess?") or adding information to increase precision (vague: "Tell me about animals", specific: "Tell me about endangered mammals in Southern Africa"). Subtle context cues are also important: If you are working on tasks for a specific cultural context, choosing your input language will matter. For example, using the German words for whipped cream, "Schlagsahne", "Schlagobers", or "Schlagrahm" will indicate whether the sentence is used in a German, Austrian, or Swiss context. This will increase the probability that the following words will be based in the same context as well, increasing coherence.
Hence, a prompt engineer has to understand their ingredients just as well as a cook and use them carefully, context-specific, and well-balanced.
Try it yourself: In your next prompt, try to identify which words you could replace with more precise ones. Compare the results of both prompts.
Mastering Utensils and Techniques
In any craft, there is an interplay between the tools a master has at their disposal and the technique they know how to apply. In cooking, having the right knife with the necessary sharpness will allow you to julienne or chiffonade your vegetables into the desired form. If you want to sauté mushrooms, you will need to apply heat control and use quick movements in combination with the right pan. In this equation, knowledge and skill are much more important: The right skills will allow you to work with bad tools, but the best tools won't help you if you don't know how to use them.
The same is true for using LLMs: There are many different models out there to choose from, but if you don't know how to craft a prompt, it won't matter whether you use Bard, ChatGPT, or Claude: Your output will be of little use. Just as a chef knows when to apply a certain cooking method, a prompt engineer should know which technique to apply in a given scenario.
There are various techniques you can use and combine in prompt engineering. A simple one is persona/audience, where you define the role the LLM is speaking from, and to whom it is speaking. For example: "Act as an Ashtanga Yoga teacher assuming you are talking to a 60-year-old man with average fitness and no yoga experience.", which would focus the task or question that follows afterwards. Some other techniques include:
Output templates: You can force your AI to use a structure for output that needs to be in a specific form. This is important if you want your output to always be in the same format—just like using muffin cups in baking. For example: "Restructure the following dialogue. I will give you a template for your output. Anything in <angled brackets> are placeholders for your output. Please preserve the formatting and overall template that I provide. This is the template: <Speaker's last name>: '<Speaker's text>' ".
Infinite Generation: This technique allows you to continuously generate output without having to remind the LLM of the original command. This makes repetitive tasks much easier, like using a hand mixer for stirring ingredients. For example: "From now on, I want you to generate ideas for startups until I say stop, 5 ideas at a time. Start now."
Analyze and Utilize: With this technique, you have the LLM first analyze and describe a piece of input, then use the description to transfer aspects of the output to another input. This allows you to copy/paste styles, similar to building and using a cookie cutter. For example: "I will give you a piece of prose. Analyze the writing style and describe it in detail as you would to a copywriter. Then act as a copywriter and generate one paragraph of text in the very same style."
You don't need to invent these techniques yourself—you can find many of these techniques online in the form of "prompt templates," providing a prompt outline that can be adapted to your specific needs.
Beyond prompt templates, there are also tool-specific techniques. For example, ChatGPT Pro has the option to "regenerate" previous output, creating a new branch of dialogue. Instead of restarting the dialogue, you can switch between the multiple branches. This effectively allows you to travel in a multiverse of possible dialogues within the same chat history. Anthropic's LLM Claude2, on the other hand, has a huge context window which is ideal for summarizing long texts without breaking a sweat.
If you experiment with these techniques, you'll quickly be able to flexibly combine them. This will make you a much more effective and efficient user of any AI chat tool.
Try it yourself: In your next prompt, use one of the techniques above, and slightly adapt it to your needs. See what happens.
Don't Just Follow Recipes
Cooking can mean different things for different people. For many, it's following a recipe from a book or website (and maybe sprinkling some of their own secret ingredient into it). For a few, it's researching the perfect combination of flavors and consistency based on food chemistry. For others, it might be reheating yesterday's slice of pizza.
Just as in cooking, there are many approaches to prompt engineering as well. You can copy/paste a good prompt from a ChatGPT cheat sheet—there are lots of them out there, many with very effective prompts. You could experiment with variations of prompts, A/B test their effectiveness to create the perfect prompt template for your use case. Or maybe you'll just continue the last conversation you had with your LLM and ask your questions in a conversational tone.
The best book I've read about cooking is Michael Ruhlman's "Ratio". It separates 37 recipes into two parts: The ratio of its fundamental ingredients, and all the rest that you could put into it. The ratio of muffin batter is 1 part eggs, 1 part fat, 2 parts liquid, and 2 parts flour. Note that it says fat—not butter, and liquid, not milk. It also doesn't mention sugar, lemon peel, baking soda, grams or cups or tablespoons. Because the only thing that matters are these four components in the right ratio. Nothing keeps you from adding additional ingredients, of course, or experimenting with variations of flour, fat, eggs, and liquid. With this, you can do 6 strawberry muffins, or 80 savory muffins with bacon, quail eggs, rice flour, and coconut oil, or any of the millions of other muffin variations.
"Ratio" has taught me that knowing some simple, easy-to-remember fundamentals will open up a whole world of experimentation and creativity. It gave me security in cooking—something I never had while following recipes from a book ("OMG I forgot the 'splash of brandy' in my Beef Stroganoff—is it ruined now?").
Just as yesterday's pizza is a perfectly fine meal in a pinch, prompting from a recipe is completely ok if you're just starting off or have little time to craft a prompt. Still, there are many other ways of approaching a dialogue with an LLM. Finding out the equivalent of Ruhlman's "ratios" in Prompt Engineering will not only make you a more effective LLM user, but also lead to a more joyful experience in working with those tools. Check out my recent article "Mastering Prompt Engineering" to learn more about what approach I'm using in my daily work.
Try it yourself: In your next chat session, think about your usual approach and consciously follow a different one than usual, such as searching for a similar prompt online, or testing slightly different variants of the same prompt and notice the difference in output. For example, giving a straightforward command vs. asking politely for help.
Cooking is a Social Act
The love for food is as much a cross-cultural unifier as it is a provider of unique cultural identity. Eating is a social: It brings people together in a celebration of sharing and communion. Cooking, by extension, is social too: People exchange recipes, share experiences, and learn from each other.
Obviously, cooking is a far more encompassing and fundamentally human activity than any work with LLMs can ever be. Still, I hope we can see from the playful exchange of cooks, bakers, and food enthusiasts that any learning activity based on experimentation doesn't have to be something we do alone: It's a joyous and curious experience meant to be openly shared.
To conclude, I encourage you to learn about the fundamentals of both cooking and prompt engineering and share what you've learned with others. For example:
Just as it's interesting to understand what happens to an egg when it's heated, or what happens to flour when you mix it with water, it will be insightful to understand how an LLM works under the hood, how it is trained and tuned. Search on YouTube for "How ChatGPT works in simple terms" (or any model of your choice), and learn what goes on in that neural network.
The same way you learn how to make dough for bread or how to best chop an onion, learn about effective Prompt Patterns. For example, check out Jules White's paper "A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPT", which explains a couple of "cooking ratios" for good prompts.
Experiment with new ingredients in unusual combinations, as well as with inputs for Chatbots. Don't give up if you don't get the desired result right away. Instead, ask yourself what your recipe needs.
Keep sharing your experiences with others. Whether it's a cooking fail or a prompt that didn't work as expected, talk about it. Others can learn from your mistakes, and you can learn from theirs.
Finally, enjoy the process. Whether you're creating a new dish or a new prompt, take pleasure in the act of creation and the learning that comes with it.
By applying these principles, you can become a better cook and a better prompt engineer. Both require a balance of knowledge, technique, and creativity. And remember, in both fields, there is always room for innovation and personal flair.
Happy cooking and prompting!





