Leveraging AI

52 | The Prompt Playbook: Proven Strategies for Crafting Killer AI Prompts that Achieve Results

• Isar Meitis • Season 1 • Episode 52

Does Prompt Engineering Hold the Keys to AI Success? 

I say YES! 🎯 

Get ready to take your AI skills to the next level! In this jam-packed first solo episode of Leveraging AI, host Isar Meitis shares the art and science behind crafting prompts that produce exceptional AI results.

Topics we discussed: 

  • Why prompt engineering is critical for quality AI outputs
  • Detailed breakdown of the key components of an effective prompt
  • Practical examples that showcase dramatic differences based on prompt quality
  • How to give your AI model exactly what it needs to excel
  • Best practices for prompt engineering from OpenAI themselves

An episode you don't want to miss especially  for anyone looking to maximize their AI toolkit in 2024 and beyond! 

About Leveraging AI

If you’ve enjoyed or benefited from some of the insights of this episode, leave us a five-star review on your favorite podcast platform, and let us know what you learned, found helpful, or liked most about this show!

Isar Meitis:

Hello, and welcome to Leveraging AI, the podcast that shares practical, ethical ways to leverage AI to improve efficiency, grow your business and advance your career. This is Isar Meitis, your host, and in today's episode, we are going to dive into prompting, or if you want prompt engineering, and we are going to do this based on my personal experience and best practices that I've developed, combined with the recently released best practices defined by open AI themselves, the company behind ChatGPT, and their recommendations on how to get the best results out of their models, which will most likely work for other models as well. Since prompting is our way to interact with large language models and basically provide them instructions to fulfill our needs, knowing how to do that well makes a very big difference in the results you are going to get. I personally believe that over time, these models will learn to identify our needs better. And so prompt engineering per se will become less critical. But as of right now, it makes a very, very big difference how you prompt the different models, whether it's to generate text, video, images, et cetera, you will get very different results if you know what you're doing, whether if you do not. And my goal in this episode today is to make sure that you know how to do this, at least for the text outputs, which are probably the core of what you need for your day to day in your business. So let's begin exploring the difference between just a common prompt and a good prompt. A regular prompt will just give general short instructions to the AI model, basically telling it what you want it to do, but without providing enough information or granular clarification to exactly the outcome that you need. So if you want to build a proper prompt, it needs to be broken down into several different components. The very first component is what is called a system message. It's basically defining the general idea of what you're about to do for the large language model. So in this particular example that I'm going to read to you right now, the system message is Imagine you are a marketing consultant working with a mid size e commerce company. And you can obviously go a lot deeper than that and define more details about the company and more details about the specific experience in areas of expertise of the marketing consultant. But even just this gives the large language model a much better understanding of what it actually needs to do. And the reason that is necessary is because large language models we're trained on basically the internet. So they know a lot of stuff and they will give you general and generic answers unless you tell them to focus on something specific. And that's one of the ways to give them specific information. As I mentioned, you can give a lot more information than in my example. The second component is instructions. And this is where you need to define very clear instructions to the large language model. In our example, the instruction section goes, your goal is to develop a marketing strategy that utilizes AI to increase sales and customer engagement. You will be presenting your strategy to the company CEO and executive team. So by providing this instruction, now the model understands. A- what it needs to do and B- who is the target audience so it can prepare the level of depth and also the level of language, et cetera, to the relevant audience. You can do the same thing in any kind of prompting that you do, whether you're writing proposals, you're writing posts, you're analyzing information and so on. You need to provide specific guidance and detailed guidance. And we'll get a lot more into that in the second part of this episode. The third component that you want is to give the model examples. And again, more about that later. But in my particular prompt example right now, I will add to my prompt the following as an example, your answer should include, but not limited to items such as how to use a I. In defining strategic goals, identifying ICP, cultivating strategic goals and KPIs to measuring success. So what you can see here is that I didn't just tell it to give me a marketing plan, but I'm actually giving it a lot more detailed example on how to do that. And as I mentioned, we'll dive a lot deeper into what examples can be and how to use them later on in this episode, once we start diving a little deeper. The next component of the prompt needs to explain what is the format you want the output in. So if you think about a large language model, the output could be a subject line for an email. It could be a newsletter. It could be a full proposal. It could be the topics for your next keynote presentation. It could be a summary of the discussion that you had on a conference call, et cetera. So it will require different formats. In my example, for my marketing plan, I'm defining the following. The format of the outline should be broken into sections and numbered in multi 11 numbering, e. g. 1. 1. 1. 1. 1. 1. 2. 2. 1. 2. 2, etc. Prior to the outline, there should be an executive summary for up to three paragraphs, there should be one line of space between each section and the next. So you can see I'm giving a very detailed explanation to the large language model, what format I want the outcome in and how exactly it should be structured. There's two benefits to that. The first benefit is that it's going to give you exactly what you need. So you're not going to get 20 paragraphs if you need a tweet and vice versa. But the other thing that it does, it saves you the additional editing step, because you could theoretically take whatever outcome you get out of it, copy it into Word or Google Docs and then edit the document. But why spend that time if you can explain to it exactly what you needed to do and don't have to go through that step. Another thing that I use regularly is ask it to use proper markdown and then it will give you actual headings and subheadings, et cetera, that when you copy to any editing software, we'll already know how the markdown is set and headings will be headings in the different levels, subjects, lines, etc. All is going to be formatted accordingly. So if you need additional formatting, you're not starting from zero, but you're starting good starting point. If I give it very long instructions, in the end, I remind it what are the key things that it needs to do and maybe the target audience in this particular case, I chose, remember this is presented to the CEO. It needs to be well researched, highly convincing and short and to the point. This helps summarize the whole point. So if I compare what could have been a simple prompt, a simple prompt could have been your goal is to develop a marketing strategy that utilizes AI to increase sales and customer engagement. My prompt is imagine you are a marketing consultant working for a midsize e commerce company. Your goal is to develop a marketing strategy that utilizes AI to increase sales and customer engagement. You will be presenting your strategy to the company's CEO and executive team. As an example, your answer should include, but not limited to, items such as how to use AI in defining strategic goals, identifying ICP, outlining strategic goals, and KPIs to measure success. The format of the outline should be broken into sections. And numbered in multi level numbering, e. g. 1, 1. 1, 2, 2. 1, et cetera. Prior to the outline, there should be an executive summary for up to three paragraphs, there should be one line of space between each section and the next. Remember, this is presented to the CEO. So it needs to be well researched, highly convincing and short and to the point. So you see there's a very big difference between the short and simple and the long and detailed prompt. Now the last thing that I will add here before we start diving deeper into several different components and aspects of this is that if you have Several different steps of the process, or if you want to have more control on the final outcome, you want to break this down into shorter tasks. As an example, in this particular case, instead of asking For the full marketing strategy, I could have asked for the initial top line bullet points of what the marketing strategy will include, and then I could go back and forth with the large language model, finesse it, fine tune it, and only then go to, now let's write section one, or what might be the next level down of bullet points before I write the details and so on. So you can break down tasks into its subtasks, and then A, have more control of the final outcome, and B, have more control over the process, Because it will allow you to change steps before getting to the final outcome. Something very important if you do that, to remember and to keep in mind, is that if you're running everything in a single chat, if you just ask it to write something new, so let's say it gave you the breakdown of the marketing plan that you requested and you don't like it and you want to change things, you can ask it to change it, but it will still remember the first variation that it created in order to avoid the fact that it will remember the first variation. You can go back and edit your initial prompt. And by doing this, and you do this by clicking on the little pencil button next to the chat on ChatGPT, and when you edit the prompt and rerun it, it will not remember what he did in the first time, Meaning when you're in step 20, if you do not do this, if you do not rerun your prompts, it will remember all the mistakes that it made and it will take them into account, even though you thought it, it's not what you were looking for. So to avoid that, you want to edit prompts that did not give you the right answer in the different steps of the process. So this is a very high level overview of how a prompt should be built versus how a simple prompt and not a very good prompt should be built. Now that I've shared with you the general idea of prompting and best practices that I've developed over time, I want to share with you the best practices or prompt engineering for ChatGPT specifically, that were shared by OpenAI, by that will most likely work on every other large language model. They have six items and I'm going to give you all six of them and then we're going to dive into deeper level that they have provided for each and every one of the six and see examples for those. The six recommendations that they have is write clear instructions, be specific in detailing needs, desires, length, etc. Set scope for accurate, relevant responses. Number two is provide reference text, which if you know how to use it properly, and I will share with you later how to do that, you can eliminate or significantly reduce hallucinations and false answers that you might receive. Number three is split complex tasks, which is something I already shared with you, but we'll go into further detail about that as well. Number four is give model time to think. This one is a very interesting concept, and the idea behind it is to force the model to analyze step by step what it needs to do versus just coming up with an answer. And we'll dive into that as well. Number five is use external tools, which are plugins and integrations and other components within chat GPT, or that you can add and connect to it through different APIs. And number six is to test changes systematically, which means to continuously evaluate the variations in the model and different scenarios to ensure the high performance is consistent as the model changes over time. Now let's dive deeper into some of those six components and provide specific examples on what these may look like. Under the topic of write clear instructions, OpenAI references six different things. The first one is included details in your query to get more relevant answers. We talked about this. If you will provide more specific guidance, you will get a better outcome. The second is ask the model to adopt a persona. We talked about this as well. Tell it what role it's holding, and you can also tell it how to provide answers. As an example, you can ask it to provide a witty or funny example after each segment of the text that it's working on, and it will do that. So it will give it a slightly more fun and outgoing personality than just the raw model as is. The third recommendation they have is to use delimiters to clearly identify distinct parts of the input. And the way You do this is you literally tell ChatGPT, I'm going to use triple quotations to give you this reference information. I'm going to use double dashes in order to provide you this and that information and so on. And this way, ChatGPT knows exactly what is each segment where things end and start, and it will be clearer in its understanding of the information you're providing it and hence will provide you better answers. The fourth recommendation that they're giving is to specify the steps required to complete the task. So if it's a really complex task, you can break this down into several different steps, as I mentioned before, and I will give you examples in a minute. The fifth component is to provide examples. So if you have a successful version of what you're trying to achieve, whether it's a formatting of a proposal in the way you like it, a post that did very well on social media or several of them, subject lines for emails that have worked well with your audience and got a good open rate data analysis, formatting that your leadership team likes to receive from your finance department, et cetera. So give it examples of what good looks like, and it will mimic that as well. And the last thing is to specify the desired length of the output. As I mentioned earlier, To me, I think it's the desired length and formatting of the output. Both are going to save you time and give you more what you need. So Now with those points in mind, let's look at specific examples that will clearly demonstrate the difference in prompting and hence the difference in outcome that we are going to get. Let's say you have some reference document that you want to use as an information for your prompt. Let's say you're writing a proposal based on an RFP. You want to use the RFP itself or snippets from the RFP when you are using ChatGPT to write your proposal. As an example for us right now, I'm going to use the reference material as a transcription of one of my previous podcast episodes but as I mentioned, this could be any reference material that you want to use in a business context, whether it's an RFP for a proposal, whether it's financial information for an analysis you're doing, whether it's Previous successful blog posts when you're writing a new one, et cetera, whatever it is that you want to use as reference material you can use within ChatGPT. But here is a very basic prompt. The very basic prompt says, write show notes for a podcast episode based on the following podcast transcription. And then I just pasted my podcast transcription, or you can upload it as an attachment. It doesn't matter. It will achieve the same goal. And the outcome that I've received from ChatGPT is more note taking versus good AI show notes. The way it looks is it says podcast episode show notes as a headline episode title. AI mastery for 2024, the essential checklist for businesses, host Isar Meitis episode overview in this insightful final episode of 2023 and so on and so forth. And then it gives a very long bullet point explanation of everything that was talked about. And it's about a page and a half or two pages long of bullet points of everything I discussed in a nice summary. So it's a good summary of the episode, but it's pretty bad. Show notes, because the goal of show notes is to be short to the point and exciting. So how do you get a better outcome? You get a better outcome by better prompting. So here's an example for the prompt I'm using regularly to write show notes for my episodes. But again, you can take this as an example and use it in your context of writing proposal based on RFP or writing a report based on documentation that you have, etc, etc. Any business content that you have that needs to be translated into something else. So here we go. Act as an expert copywriter and use the transcription provided as data. In parentheses, delimited by triple quotes, close parentheses, write the show notes for the podcast episode that will make the episode irresistible. Make the show notes witty, but professional. Don't hallucinate. Start with a provocative question that would get people interested. For the second paragraph, give a short overview of the topic, then provide a section Topics we discussed followed by bullet points using relevant emojis for each topic covering the main topics covered by the podcast episode. The final section should be a short bio of the guest and suggestion to connect with them on LinkedIn. Separate the different sections and use short sentences so it's easy to read. Here is an example of great show notes from an episode that received many downloads. And then I've just pasted an example of show notes of an episode that did very well, which I'm not going to read to you. The outcome is dramatically different. First of all, it's a lot more engaging and exciting. B, it's structured in a way that's a lot easier to follow and C, it looks much cleaner. So people actually read it and hopefully will get excited to listen to the episode. So Here is what ChatGPT gave me based on this input. Are you ready to revolutionize your business with AI in 2024? And there's an emoji of a rocket. Welcome to a game changing episode of Leveraging AI, where we dive into the future of AI in business. Host Isar Meitis is joined by visionary AI consultant revealing the must know strategies for 2024. If you're looking to stay ahead in the fast evolving world of AI, this episode is your roadmap. Topics we've discussed is and then there's a space separate header in bold. And then there's a list of several different topics that we discussed with relevant emojis for each and every one of them, short sentence for each and every one, and then at the end it says about our guest in another bulleted header. Our guest is an AI consultant renowned for transforming businesses through AI with experiences in consulting, etc, etc. And it ends with this is a must listen for anyone eager to harness AI for business growth in 2024. Don't miss out these cutting edge insights. So as you can see, there's a huge difference between that and the very dry And much longer shopping list that is not very visually appealing or interesting that I received with a very short prompt. So investing in the much more detailed prompt gave me an extremely different outcome. Now, the cool thing about this is this may sound like a lot of work. You have to rewrite all these instructions. Time and time again, the reality is I don't. And the reason I don't, I use a prompt library. Once I get to a prompt that is actually helpful and give me this level of outcome, I save it and I reuse it again and again and again. So for me to reuse this prompt, I use a Chrome extension called Magical, which is just a text expander. So this entire very long prompt is actually shortened into a few characters when I type it. This whole prompt comes out and all I have to do is then paste the transcription of my episode and I get these amazing show notes that you see on my podcast every single week. I don't know if you're surprised or not, but I don't write the show notes. It's actually written by AI. So now think about every process in your business that gets a text input that requires some kind of an output and think about how can you apply the concepts that we just discussed? in order to get this consistent outcome in a way that is aligned with your brand guidelines and the structure and the format that you want the outcome to be. After I receive the show notes, I go to step two. And as I mentioned, I break this into several different prompts. So I have more control on what's the outcome. So if I didn't like the show notes or I missed a few things, I can ask it to relook at it and add the missing components. And that's something that would happen, especially with long documents. Sometimes, ChatGPT will not go through the whole thing and will give you just some of it. So you need to pay attention and actually ask it to go back and look what it's missed and not repeat things that it found the first time, but to add the missing components. In this case, it didn't, but sometimes it would. But then I go to my second prompt that says, Now act as an expert marketer with a special focus on podcast promotion and copywriting. So now I'm giving it a different hat to wear to focus it even further on what I need it to do. You just received an entire transcription of a podcast episode. Your task is to provide the best five names you have for this episode. The name needs to give the readers a general idea of what this episode is about. But more importantly, it needs to make it irresistible so people who see the episode name will feel they must listen to it the audience is business people and specifically people in leadership positions. The episode names that drove the most amount of downloads so far were very practical in nature, such as Automate your success, a comprehensive roadmap from basic automation to AI genius. Number two, mastering generative AI, a comprehensive guide from basic concepts to business transformation. And number three, from newbie to ninja, essential AI know how for every business person and the bright future ahead. Please provide the five best names for this episode based on the information I provided and the podcast transcription. So as you can see, again, I give it very clear instructions of what I'm looking for, what the name should achieve. What role is it taking? I give it examples of what success look like. And I then ask for the information and it gave me very good names. So the names you see off the episodes that come out on this podcast every single week are either direct copy and paste from the outcome of this exact prompt, or in some cases, me taking those as inspiration or combining a few of them together into something I feel is more appealing and yet describes what's going to be in the episode. But I always start with those five examples. So how can that be applied for anything else in your business? This could be applied to reports in finance and how to well define the results that you're finding. This could be applied for summarization of meetings that you had, whether internal or external. This could be applied for information that you received as an RFP and you need to write a proposal. This could be applied for so many aspects of business that you can use these guidelines in order to get better and faster outcomes in your business. Another important component of this is to clearly define to ChatGPT or other large language models that you want the response to be specifically out of the information that you have provided. And to do that, you need to clarify that in the instructions in a very clear way. And also to define what to do when it does not find the information you're seeking within the attached information. So in this example, I've done something a little different. I've taken the same transcription from my episode. And again, this could be any kind of document, including legal document that you want to ask about, et cetera. In this case, what I've done is I've given ChatGPT two different options, option number one is I asked the question without giving it any reference information and without explaining what to do with that reference information. Option number two, I gave it reference information, but also gave it very specific instructions on how to use that reference information. I recently released an episode that listed seven things a business must do in order to maximize the efficiency of AI implementation in 2024. So the question I asked ChatGPT was based on the Leveraging AI podcast episode 49, what is the first thing the company should do in order to successfully implement AI in 2024 and what could be some of the tactics to achieve that? Now, I did not give it any reference information, but again, this could have been any question that you're asking ChatGPT and it will give you an answer, even if the answer has nothing to do with what you asked for, it will give it to you in a very convincing way. So it wrote me a very long article on the first step for a company looking for successfully implement AI in 2024 is to establish blah, blah, blah, blah, blah. And then it gave me bullet points on how to do that. But it has nothing to do with what I actually asked it, which is what is the episode from leveraging AI tells you to do. In the second example, I've actually attached the transcription of the episode, but I also give it a much more detailed prompt. So here's the prompt I gave it in the second time. You will be provided a document delimited by triple quotes and a question. Your task is to answer the question using only the provided document and to cite the passage or passages of the document used to answer the question. If the document does not contain the information needed to answer this question, simply write insufficient information. If the answer to the question is provided, it must be annotated with a citation. Use the following format to cite relevant passages, And the formatting is defined on how should ChatGPT do that. And then I've pasted the document. The outcome this time was very short and to the point. So again, the generic question without providing reference information was long and completely made up, but very convincing. And the answer now is, Based on the Leveraging AI podcast episode 49, the first thing the company should do in order to successfully implement AI in 2024 is continuous education. The tactics to achieve this Includes following the right people and sources for AI related information, such as podcasts, social media influencers on platforms like LinkedIn, Facebook, TikTok, Instagram, or YouTube, and subscribing to various newsletters and industry news updates. Additionally, taking AI courses offered by various organizations, including the Multiplai brand, is recommended to stay informed and updated et cetera, et cetera. And then it gave actual citations of components within the podcast that list the things that he just summarized. So this is an incredibly good and accurate answer. Of what I asked based on the information that I provided going back to how can this be applied in business? This can be applied in business when reviewing legal documents, reviewing agreements, reviewing proposals, RFPs and anything else that you need to do. It can also be used very effectively if you want business advice based on specific books or people that you follow. So you can tell it to only use information from a specific book by a specific guru that you're following or a specific chapter out of that book. Or you can ask it to evaluate your strategy or your suggestion based on the information in that chapter to see if you're actually following the instructions. And it will do that as long as you tell it to do exactly that. By the way, just to test it. I then asked it a question on something I did not cover in the podcast, and it answered with. insufficient information, which is exactly what I asked it to say if it did not know the answer. When I asked the same exact question in the previous chat, it gave me again a very long and a very convincing and completely made up answer to a question it did not know the answer for. So if you want to get very accurate information, Tell it that it can only reference the documents, tell it to tell you that it does not have the information available to answer it if it doesn't have it and tell it to use citation so you can verify the information is actually coming from the reference document. We also discussed the concept of breaking down long and complex instructions into steps and actually open AI themselves have a very good example and I want to share that with you. They're giving a very good example of how to use chat GPT to analyze and response to customer service queries and the way they have done this. They're using a several step approach, but the first step is using it to just classify the responses. So the first prompt they're using is you will be provided with customer service queries. Classify each query into a primary category and a secondary category. Provide your output in JSON format with the keys primary and secondary. Primary categories, billing, technical support, account management, or general inquiry. And then they break down each and every one of those categories to subcategories. So I'll give you just one of the examples, billing, secondary categories, unsubscribe or upgrade, add a payment method, explanation for charge, dispute a charge. And in a similar way, they broke down each and every one of the other ones, and then they run the query. And then the second step of the instruction can be based on the category that ChatGPT itself has put for each and every one of the queries, which will make the process significantly more efficient. The next concept that I want to cover is giving the model time to think that sounds a little weird, right? It's what do you mean give it time to think it's a machine let it do its work and it should give you an answer But it's not the way it works. It actually thinks more like a human So if you ask it a question, it will try to spit out the answer But if you ask it to think about it and evaluate it, it may come out with a better answer Or in this particular case, the right answer. And the example that they're giving is they ask it to evaluate a student's solution to a problem. The prompt that they use, the wrong prompt that they use is determine if the student solution is correct or not. And then they told it what the problem was, I'm building a solar power installation, and I need help working out the financials. The land cost X, the solar panels cost Y, and so on and so forth. And then they provided ChatGPT the solution that the student provided to the problem. the response from ChatGPT is that the student's solution is correct, when the reality is the student's solution is incorrect. Now, take this to a business environment, you could have taken several different resources information and Calculate something for a proposal or your financial reports or something else, and you want to check your work with ChatGPT and you will get the wrong information. So what they're suggesting to do is to use a different prompt that actually asks ChatGPT to run the process itself. And the prompt goes something like this. First, work out your own solution to the problem. Then compare your solution to the student's solution and evaluate if the student's solution is correct or not. Don't decide if the student's solution is correct until you have solved the problem yourself. And in this particular case, it actually gives its own solution to the problem. So it goes step by step by evaluating the different inputs and information that it has, and it gets to an outcome. And then it sees that the student solution is incorrect because it got to a different outcome. Another way to approach this is to ask ChatGPT to use what's called chain of thought. And literally you just say, use chain of thought in your answer and we'll do something very similar. It will explain step by step what it's actually doing behind the scenes, which will give you a more accurate outcome. In some cases, you'll get the right outcome, even if you don't do this, but if you do this, you are increasing the chances of getting a better outcome and it becomes more and more important as you're doing more and more complex things with more and more steps in it. I want to summarize everything we talked about in this episode. You can write short and simple prompts and you will get answers from ChatGPT every single time. It will never tell you it does not know the answer. The problem is it sometimes does not know the answer, or it will give you a bad answer that is not in the format you wanted, or it's not relevant to the specific need that you have. In order to get the actual outcome that you need in the format you needed, in the level of detail you needed, addressing the specific audience and using the right reference material, you need To invest in writing the right prompts. And that includes all the stuff that we talked about in this episode. And in order to do this for your needs, you need to experiment. You need to try several different prompts, several different times, going back and forth until you land on the one that actually works extremely well for you, that saves you the most amount of steps and the most amount of work. It's worth that investment if it's not a one time thing, but something you're doing on regular basis, because if you are doing it on regular basis, save the prompt in a prompt library, and then you and other people in your organization, in your department can use that prompt to replicate the work again and again, and again in seconds and get the same outcome with very little work. And that's where. A huge part of AI magic comes into play. I hope you found this very tactical episode helpful. My suggestion is, listen to it again. I will put the link to OpenAI's. Best practices article in the show notes so you can find that as well, but you can also read the transcription of this episode that is available on your podcasting platform and on my website. So you can follow that way as well. If you want to look at the visual references of everything that I was mentioning, you can go and watch this episode on YouTube to refresh your memory and to actually see how the prompts and the outcomes look like. That's it for this week. Have an incredible week. Have a successful 2024. Use AI experiment with it, try different things and share it. Once you find great ways to do this, because if you find stuff that's helpful and share it with other people, they will share their successes with you, saving you time as well, or in simple words, sharing is caring and until next time have an amazing week.

People on this episode