How to build an AI prompt engineering spreadsheet. Walk through step-by-step going from a blank sheet to an AI powered prompt engineering cheat sheet of a spreadsheet. More tutorials, courses, tools and templates at Better Sheets: https://bettersheets.co
How to Engineer the Best Prompt Ever
(00:00) I've asked chat, g p t how to engineer the best prompt ever. Define your goal, identify your audience, be clear, be specific, provide context, corporate skills. This doesn't really tell me anything about prompt engineering. I want to write my own best prompt ever. I wanna engineer this prompt and I want to keep engineering it until it is the best.
(00:20) I've gone through this lecture of prompt engineering. I've read through so many slides in this video we're gonna create the ChatG PT cheat sheet spreadsheet, the ultimate, uh, chat sheet pt, prompt engineer sheet. It is a blank sheet right now. Let's get started. Uh, and we don't like this, uh, This style.
(00:42) So we're gonna change our style. We're gonna use sheet styles, a free Google sheet add-on. We just want to change it to papyrus so we don't have this, uh, you know, terrible, uh, aerial font and we don't want the background color to be . White. So how do we start? Where do we start? Well, first off, we need AI in our sheet.
(01:00) We don't want to be copied and pasting something into Che pt. We wanna go right to the source and we wanna get our prompts answered right away. Uh, that's gonna save us a lot of time, so I'll show you. I got a video already. If you are a better Sheets member, you get. That video for free, I upgraded it.
(01:15) The API access via OpenAI in App Script. I've written it for you. Uh, if you're a Better Sheets member, you can get it down below if you're watching this on better sheets. If you're not watching this on Better Sheets, just go check out Better sheets.co. Get a membership and you'll go to the upgrade.
(01:30) All right, behi members, if you are watching this video and you want to create this chat sheet, PT cheat sheet spreadsheet yourself, and you wanna connect it to ai, make sure you watch the video upgrade Google Sheet's, open AI prompt to G P T four. In that video, I go through the app script here and the full app script you can use right away.
(01:48) But in this video, we're not gonna deal with this script at all, except for the fact we're gonna add a ton of text to it. We are. What the point of this video is, is we really want to take. Sort of different parts of a prompt, put it all together and we're gonna spend a lot more time in the sheet, but we are going to absolutely interact with this function a lot.
(02:08) Um, but I'm gonna rename it to just ai. So I just have to type in AI in a function in sheets and we'll get a response back. Uh, we do need, uh, we'll go, uh, API key. So we'll go to tiny sheets, create a one by one sheet, and we'll just call this API key and we'll put our API key here.
(02:27) And just so you can see, uh, if we wanna write any kind of prompt here or write three ideas for a cheat sheet spreadsheet for G P T four, we can write sort of any prompt we want go equals AI and reference that cell c3. And let's see, uh, it's using G PT 3.5 turbo, so it should be a little bit quicker than GP PT four, but we can change that and we probably will later for this cheat sheet.
(02:52) But we wanna see how long does this take? Usually only takes. Up to 30 seconds, and if it does take more than 30 seconds, it's gonna time out. So our cheat sheet here, ultimately we want to be building prompts, but I want to connect. There we go. Common models. I don't know what this means for, uh, best practices for fine tuning.
(03:10) Oh yeah, that actually is the answer. Two, right. Three ideas for a cheating spreadsheet. Um, So you can see here we have connected our prompt to ai, but we wanna build this prompt up. We have some, uh, ideas about what makes a good prompt. We want to include very concise, very specific information. We want to say what role we wanna give it a role to like, Who are, who is the AI and what are they doing? We want to ex uh, include examples.
(03:42) We want to include all this stuff, and we might not be able to write it all out at once, and we might not want to write it in like a Google Doc or in a text edit. That's just one document. We might want to fiddle around with different pieces and even. Create a little dropdown menu, uh, in case we want to select any of those options.
(04:01) Say, uh, we have a style or a tone. We want a little dropdown menu that says pick this tone, and then it automatically says right in the tone of punchy or right in the tone of silly or funny or right in the tone of a certain person. We wanna have all these options at our fingertips here in a sheet to a prompt.
(04:17) So we don't need all of this stuff. We are really just gonna use a few. Pieces of this. Um, but we definitely want to add dropdowns here. So we're gonna be able to write tone, maybe style of like, maybe, uh, punchy style. Uh, we're gonna have punchy, concise, we'll have persuasive, might not need to capitalize these punchy, concise, uh, persuasive tone.
(04:53) We might come back to this. I'm not sure what to do here yet. Yet We will figure this out. All right, so what do we want to do? Let's do this one thing first. Let's start writing our prompt in A one and get our response in B one. So we'll put a prompt here and we'll get a response here.
(05:15) So we'll do equals AI a one. Now, anything we put in here, uh, we will have the response to. So I don't necessarily want that, so I'm gonna do, I don't want it to happen if there's nothing there. So I'm gonna add an if is blank first to commas, and that way, now if I write here, it'll show up the response, but not until I actually write it.
(05:41) All right? So how are we gonna build this? What do we want to do? We wanna have some dropdowns like tone and style and we'll just do right click dropdown. We know the dropdown range. I think dropdowns, we just did it a colon a I think that's gonna be it. That is tone, and I think that's the only tone there.
(06:05) Great. And now when I cancel that, just wanna, oh, my face is, is covering the done. And now in this one, do the same thing, dropdown, but from A range. We'll do dropdowns B, colon B, that tho they are there. We can even say style here and tone here. If we want, we actually just want dust style, so write a tweet.
(06:36) Let's say we're writing a tweet a hmm. I don't want to write it here cuz it's gonna come up with this B one. So let's write, let's take all these down a notch. Whoops. Let's center this. Make it a little easier to read. And then what I wanna do is I wanna do write a, I'm gonna use a code here, two uh, square brackets.
(07:08) I'm gonna write tone and two square brackets. Write a tweet. So it's gonna be a persuasive tee, a punchy, uh oh, A style. We want style there not to, okay. Maybe we want to switch these. Maybe we do want. The style to be there. Style In the style of Charles Bukowski, we'll just write different Shakespeare.
(07:30) That's not how you spell Shakespeare. Tony Morrison. We'll do some different styles there. And now we, we wanna write a concise tweet, a persuasive tweet. In the style of, and then two brackets, and we're gonna use this as like a code style about, and now where do we want to write the about, uh, write two about there.
(07:56) So this is gonna be our text, but where's that about? Let's do about, oh, we need to select this. B Column B done. Oh, it's the wrong one. So we can say Charles Bukowski about Google Sheets. Effective for collaboration, efficiency, effectiveness, effectiveness for collab collaboration. Now all of this stuff, this tone, this style, this about, we have it written here, but we have it encoded.
(08:36) So in a one we're gonna write equals substitute text to search is gonna be a two. We're gonna search for that. Uh, first one is gonna be tone and we're gonna replace it with whatever is in the tone. So it'll be a four. Now we wanna wrap all of this again with another substitute and we're gonna substitute Tube square brackets, style B four.
(09:02) I think it's gonna be. Then we're gonna wrap it again last time. Substitute. Text to search for is gonna be whatever the answer is there. Search for in quotes, the about all capitalized. Uh, we're gonna replace it with whatever's in c4 and that should be it. I think our error, we're gonna get an error bec, or not an error, but tone here needs to be changed, so we're gonna say persuasive.
(09:33) And now, whatever we have in here, let's see what this looks like. This is the text we want, right? We have written sort of a format. Write a blank tweet in the style of blank about blank. Uh, we have a persuasive style, Charles, not persuasive tone in the style of Charles Bikowski, uh, about Google Sheet effectiveness for collaboration.
(09:54) And see, let's see if we get this, uh, in 30 seconds or less. There. Yeah, we go. Collaborations key, right? Eh, that's okay. Let's see if we can do better. And it just says in the style of each other. Let's see if we can say Shakespeare is better and probably not about Google Sheets. Probably like saving money.
(10:15) It's probably better about saving. Yeah. What does Shakespeare have to say about, um, saving money? Prudence, befits. The, oh, we can also add, you know, Dr. Uh, Ben Franklin here. We can add, uh, silly here. Save the coin. I don't know if you can see that. Save th coin, uh, prudence befits. The saving gold doth not diminished one's worth, but rather make the able to attain This cheat sheet spreadsheets going great, right? Ooh, well, what else can we do? We wanna have a space where we can include examples.
(10:54) That's one thing that I've realized in. Prompt engineering can add a lot of specificity to the prompt to get really good results and good. What I mean good is mean, correct, like correct to what you need. The most useful results are going to come about by having this nice prompt plus examples, but examples we might not have.
(11:21) A lot or we might have a few. We don't need a lot. We don't. Sometimes we might have zero. So what I think I'm gonna do is write prompt here in response here and we can always move these things around if we do need to. But for right now, I'm actually gonna even this up. So we have three even things.
(11:41) We have prompt and response. And in order to include the example, I think I wanna have a checkbox. I'm, can I insert a checkbox here instead of a dropdown? And basically if this checkbox is checked, I think we'll include this res, this example. Okay. So around here we need to, um, Oh, we don't need to change that.
(12:11) We need to change this. Write a tone, uh, blank tone. Tweet in the style of about blank blank. Uh, if we'll write, let's do this equals concatenate. Did I write spell concatenate correctly? There it is. Concatenate This. And we want if, um, a six colon. Oh, the, the good thing is that if it's, um, a checkbox, it is literally just true or false.
(12:43) But first off, we want, we want to have some text here and say, here are some examples, or here is an example. So we sort of need a count if count. Uh, count if a five to a no, a six. Sorry. A six to a eight. So there's three up to three examples here. Yeah, we don't really need that many. If that is above zero, then if it's true, right, we'll have the text.
(13:15) Uh, here are examples and then we'll carry on with the examples. We're gonna say, uh, here are examples. We're gonna use the ampersand. Oh. But then we want to say, if there's one, do this. If there's two, do this. If there's three, do this. So maybe if is not the best use right now.
(13:36) So I'm thinking if it was sort of just a yes or no, if it's what include this here or not, that would be great. But include one and have here as an example, if it's two or three, here are examples. I have sort of a different version based on the results. So I'm gonna use Switch here. I think if switch expression is count, if range is gonna be the same, a six colon, a eight, uh, the Arian is true.
(14:10) So we're gonna count all the trues. Now that expression is going to either be 0, 1, 2, or three. That are the, that that are the only possibilities. That is the set of the only possibilities. In the case that it is zero, we wanna do nothing. We're just gonna add another comma. But in the case that it's one, we are gonna write this Here is an example.
(14:37) Colon, or not colon. Oh my God. In the case that it is two, we're gonna write here. Uh, I might want to add a space. Yeah. Here are examples. Same for three. This might be a little over here, but I think it works in this case cuz last two. Two are the same. Okay. We want to concatenate that this text, here's an, here is an example, here are examples.
(15:08) Either or, or nothing. Right. There might be nothing there, which is fine. And in the case now, in the case of what to include, I think we do, if we're concatenating this together, if, uh, a six. So now this is only gonna be if, uh, either true or false. That is the only possibilities. Uh, checkbox is just a visual representation of true or false.
(15:35) We're gonna write comma. And in the case of true, it is true, we want to concat. Um, we don't want to concatenate everything. Actually, we just want, uh, we're gonna write the text prompt. We're gonna write prompt. With a colon emper sand b6. Uh, we want then emper sand co, uh, space response and C six.
(16:09) So in the case that the A six is marked true, we're gonna include whatever the prompt and the response is here as an example in the prompt. That's cool. Right? Um, and we're gonna do this again and each time for just the three things here. We're gonna concatenate these all together. So if there are two of these, we're gonna concatenate two of them.
(16:34) We don't care which two they are, it'll show up that we'll then do an if for each one. So we'll do a seven here, B seven and C seven. And then we're gonna change this six to an eight A eight B eight. And C eight. So that's cool right now. Hit enter. We have a bunch of falses. Okay. What? Oh, because um, we didn't add the false possibility here.
(17:01) I think we just have to add a comma at the end. I think it's literally going to be just adding a comma. Yeah. There we go. We're just gonna add a comma to say if it's false. Just don't do anything. Just don't include anything at all. So now we can choose a prompt. So if we're writing a persuasive tweet in the style of Shakespeare about saving money, we might not have any examples, but maybe we do.
(17:28) Maybe we have. Um, I'm gonna actually use this prompt, uh, Shakespeare, and I'm gonna put that prompt there. I'm going to not include it yet. I'm gonna change this to Brent Franklin. Let's see what we now, it automatically changes up here, Ben Franklin, and it automatically is gonna go to AI and get an great, this is a great, and actually what I can do is improve this, right? We're gonna go into this example.
(17:56) We're gonna take out these hashtags. We don't need these. Um, I'm gonna take out these hashtags as well. I'm gonna take out the quotes. I don't really want the quotes too badly. You might want the quotes. But I don't. And this one as well. Let's get one more example, um, from Wait.
(18:19) Don't want Charles Bukowski. Let's see what Naval says. Or would say that AI thinks it's Naval says this is, you could actually use real quotes. Um, yeah, let's use this, but let's delete these. I'm not asking it for hashtags, it's a, it's adding hashtags. But I, what I think is going to happen is we delete the hashtags in the examples.
(18:41) Um, this could probably be a lot shorter. I don't think Naval ever wrote this much. It's about, it's about creating financial freedom. Yeah, let's just very short. Okay. What I think is gonna happen is without these examples, We've gotten some pretty gnarly tweets. We've gotten these tweets that are, have, uh, things we don't want.
(19:04) They have quotes. They're two. Uh, they're, it's a lot of words. Um, we might want to change the, uh, we, we have Len here. Let's see how many characters it is. Right? We might want to sh make it much, much shorter what we can, how we can do that. And a couple ways, right? In pumped engineering that I've seen people doing that doesn't necessarily work out well is that they will just increase the size of the.
(19:29) Text of the prompt, they'll say, uh, write it in under 50 char, under a hundred characters, or under a 200 characters. They'll say, they'll add these, these explanations, which is okay, but I don't think they're getting the results that they really could be getting. What we really need to do is include these examples, make these examples, 100% pure good.
(19:53) And I think we're gonna end up with much better responses. Uh, I'm gonna change this to now. Include the example, and now it says, here's an example. Prompt Shakespeare response. Probably the good. Oh, still getting, uh, hashtag, let's try two more. We're just gonna put all these prompts in here.
(20:15) Oh, actually we gave it an naval prompt. So let's switch it to like, uh, Tony Morrison, I think, I don't know if this is gonna work at all. So it, it didn't really work. So I gave it these examples. I gave it the prompt, I gave it the responses. I have not asked it to add these hashtags, so I'm wondering where it's getting them from.
(20:36) Let's just double check that we, we have much shorter examples, so, Might be better to actually explain this. That is 100% on me. Then, uh, write a, oh, I think we wrote persuasive. Let's just change this to concise. Let's see if that does it. Waiting and still we have hashtags. What is the, we don't need hashtags.
(20:59) Write a tweet without hashtags. Let's just do that. Let's see, uh, if that kills us. Stupid hashtags. Oh, I'm so excited. If No, we still get one. Oh my God. Ah. You know, one thing I just realized, we might want to include a hard, uh, line between this prompt and the response. Uh, also you might notice that the prompt in response, the prompt is the person writing it, and the response is the, something we've already come up with.
(21:33) Maybe we might want to write our own here, uh, to really conceive of the style, or we might not use, want to use the style as the prompt. We may want to use the topic. So that's really up to you. Which, what do you want to try? But I do realize I wanted to put that, um, oh, and I see there's also not a space.
(21:55) Here is an example. Here are examples at a space there. Uh, there should be a space after prompt and before, no, before prompt should be much more. Oh, sorry. After response. Let's put a space there. I don't know why, but sometimes in these prompt and responses examples, it has been finicky about, uh, structure.
(22:20) Like these need to be said. It. I've noticed that. Are we still getting a hashtag? But it is. Let's try Stephen King. I don't know if these styles are gonna be. Weird or not, you're watching this and you're like, oh, I could do this better. If you could do this better. Go ahead. The, I am not a prompt engineer expert.
(22:40) I am a Google Sheets expert. We should be doing, where are we working with Google Sheets here. Hey, this actually is pretty good, again, with the stupid hashtags, but, um, why I wanted to sort of do this video was so you could see the process of. Using these Google Sheet, uh, formulas, we and dropdowns and check boxes, we can really build a really cool cheat sheet to have prompts, responses.
(23:06) We can save them here and use them to build better prompts. We can write as much as we want and include sort of a madlib style inputs, uh, that we can play with. Uh, we can change this tone to silly. What's a silly Stephen King? Um, Now the issue is right when we select silly, these prompts are not silly.
(23:30) So, oh, and it even gave us Egger Allen Poe for some reason. Okay, we are, you know what, I'm gonna do one change. I realize. Oh, the temperature is one. That is probably something we want to change. And this model, let's do this. Let's do a little bit of change. We don't need a line here. Ah, we'll keep the line.
(23:54) I wanna do a couple more things to show you how much we can have at our fingertips. So I'm gonna write tokens here and I'm gonna write a model, and in this model I'm gonna use G P T four, but actually just so there's no, uh, I am going to end up using G P T four, but for right at this moment, let's use, um, Uh, GPT 3.5 turbo.
(24:19) But all I wanna do is go into app script and I'm going to say, here's my app, here's how I get my app. Key spreadsheet dot get active spreadsheet. How I wanna get my model is gonna be the same, so I'm gonna write variable model here. I'm gonna add another line. Variable model equals, um, we're not on the API key, we are on the sheet one, capital S sheet one.
(24:44) What range is our model in is B 11, so we just change the A one to B 11. We also have tokens, variable tokens. That's going to be B 10 right here, B 10. All right. Now, oh, we have to change actually. This tokens. So now we've edited our off script a little bit to make it easier to change this tokens.
(25:10) We are getting some errors, uh, return 400 code. We could not parse the js o n request. What is going on? Hmm, let's just try it again. I don't know if we will try something else. Ah, Okay, so I was just flipping this model and this, uh, tokens value. So it was saying there is no model that is equal to the name 200.
(25:35) Yeah. Because, uh, that's supposed to be two tokens. So if we change the tokens here, uh, we can now change tokens is the B 10, which is actually tokens here, and it should give us a different response each time we edit this. Um, let's edit. This to concise. Now every time we change something, it's going to give us a different penny saved as a penny earned as why, as Franklin said, it is giving us a very wrong person here.
(26:10) So let's fix this, uh, prompt and see what we can do. I think it's, these examples might, maybe the examples are coming in the wrong place. Maybe we need to flip this around and say, uh, Con, uh, write all of this, uh, and write. We're gonna say, write a tweet, and then at the end, we're gonna concatenate this with what we had before.
(26:36) So we're just gonna flip it all around, um, and see if at the end, if we say in the style of Stephen King, about Stephen Money. There we go. Uh, this looks much better. That's what was going on. Those examples were coming in afterwards. Now we're really engineering. Where is this stuff going? What order is it going in? It's changing the response greatly.
(26:55) It is, we're now not, we're now not, uh, confusing the AI as to what we want. At the very end, we have some examples, and then at the very end, here's what we want. Um, if we have the examples, let's, uh, Say silly, and instead of we're gonna do bikowski, we'll see what that turns out to be.
(27:19) I'm a little scared. I don't know about you. This getting bit scary each time we do this. It's getting closer. I don't see money often. That is true. A hundred percent true. That is, uh, that is Charles Bikowski. He's not, he was not a saver. He's a drinker. But now we can do this. We can actually change this to G P T four, and I'm wondering if it's gonna change it greatly.
(27:44) I don't think so. I don't think the difference between 3.5 and um, four with that. Great. But let's see. We could make this a dropdown if we wanted to, but unfortunately, it's not going to automatically change this output because it's in the app script. Uh, This did not work out for Tony Morrison.
(28:04) Sorry. Maybe Naval. Oh, leaving. See Neal's right here. But let's maybe change it at a different topic. Um, writing online. I don't know what, uh, Naval has to say about that, but We have a naval thing for saving money. Yeah. This might not work out well because these examples are about writing online.
(28:26) Let's see. And I hope you can see this might take a little bit longer. Dearest Earthlings. Oh my God, this is way wrong. I think it's because we have very different examples here, but as you can see, we've sort of set up this, um, This prompt here in a one and we can keep adding to it. We can concatenate more and more.
(28:48) We can append more and more things. We can choose different styles, different tones. We can add stuff as we wish. If we want to. We're using so many interesting function switch if, um, Check boxes. Dropdowns. We're right, we're, we have a topic here, a couple words, but we're adding a bunch more stuff.
(29:08) Adding these examples didn't really make much difference, and I think that might be 3.5. I was use, I used to do examples with G P T three and it was like, great, um, it, it really like honed down that, uh, that stuff, but this is getting a little wild. Oh, um, maybe it's because my temperature is one.
(29:29) We could change this. To, let's change this prompt and we're gonna do temp and we're gonna write here temp, and we're gonna change something else about this right here in this ai. We're gonna add, um, where should we put it In B nine. There we go. And so we'll write down here, temp percher.
(29:55) I'm gonna move these over to the right and I'm gonna put 0.3 here. We are gonna have a different, oh, we need to save this temp, temp here. Now by doing that, we definitely do, uh, change this anytime we change this temperature. Same could be said about the tokens, and I'll change that in a hot second.
(30:18) So instead of, or in addition to prompt and temp, let's do tokens. And instead of doing tokens here, we can edit that out. Add in B 10. Let's go ahead and just do B 11 for the model as well. Oh, let's go here and go model. We can even edit that out or comment that out. So now in our function, we're adding the prompt, the temperature of the tokens of the model.
(30:51) And now we can change this and it, once we change this text, it'll change the input up in B one automatically in, so we can just add more tokens. Let's do like 1000. I don't think it's gonna change much cuz we're writing a tweet, right? That's gonna be very short temperature. We can go down to like 0.2.
(31:10) I'll, I'll show you when we get this back. I'm gonna write this. I want this to be faster. So much faster. So we should have G P T 3.5. Yeah, we're not getting much difference, right? Because we're writing a little bit short. If we wrote a lot, maybe we want to write, um, multiple tweets.
(31:28) Maybe we wanna write three tweets, write a three concise tweets, and we would need definitely more tokens for this. So I think this will actually take some of those tokens now. There we go. We got three tweets now in one go, we can do 2000 tokens and write five tweets. Six tweets. Seven tweets, seven tweets in that same style.
(32:00) Isn't that cool? All right. So as you can see in this cheat sheet, we can. Fill in this dropdown, this style, these tones, these styles. We can add more and more and more, select them and see what we come out with. We can really engineer, add more stuff to this, uh, this AI prompt. Put all of our energy into getting all these different inputs, put it in, get some examples, put those in, um, and really get hone in on a.
(32:26) Much better, much more useful response from chat. G P t Chat, not chat, G P t and g P T four G, PT 3.5, whatever model we wanna choose here. Um, hope you like this kind of style. I have other videos. If you're a better sheets member and you're watching all the way through, there's many more videos in, uh, adventures.
(32:47) An AI course. If you're not a member, you can get that on Udemy as well. But if you're not a member, just go become a member at uh, better sheets.co you can see all the AI, uh, adventures here in Google sheets and on YouTube right here. And watch the latest video from better sheets right here. If you haven't watched any other videos on Better Sheets you are in for a treat.