================================================================= TITLE: Prompt engineering DATE: 2024-10-04 (October 04, 2024 at 12:13 PM) DURATION: 02:37:22 (9442 seconds) WORDS: 26,124 words SPEECH ID: 26XPVAWW23C5P6Q6 ================================================================= --- AI SUMMARY --- prompt engineering, generative AI, writing persona, in-context learning, instruction balance, example importance, prompt refinement, output format, trigger usage, evaluation metrics, automated search, code generation, performance testing, template usage, intern analogy --- FULL TRANSCRIPT --- [04:00:00] 0: I love it. It picked up on what I was trying to capture in that example with a very, very little information. And then if I follow up and I say, you know, in the conversation, Jill colon, it knows to put in examples, it'll provide way more information than we could ever get into instructions. Sometimes it's just going to be easier to put it into instructions. And part of what we're doing in prompt engineering is striking that balance of what needs to go where. And we also know these are two different levers that we can pull when we're trying to control the output of the generative AI and help us do some really hard task like writing in a particular voice and style that we want. Now, I want you to, you know, just to kind of drive home why examples are so important. I want you to imagine that you've got a new intern, and this intern has never read or read William Faulkner before, or never read some other author, and you decide you know what I'm going to write. Them a step by step set of instructions of how to write like William Faulkner or write like some other author that has a particular, very particular style. It's going to be hard. It's going to be super hard to do. In fact, that list of instructions is probably gigantic, and I'm not sure if we can write a precise enough set of instructions that would teach somebody to write in another person's style. And that's part of the reason why so many people fail at using generative AI to write things that you know sound the way they want, is because they're focused just on instructions. No what I'm going to do if I want to have that intern learn to write in the style of William Faulkner or some other writer, I'm going to go and tell the intern go and read from that author, read their writing and learn from it. And that's what in context learning is, is it's learning from real world examples of what we want. Now this is writing, and it's very information stylistic has all kinds of things rolled up into one. We're going to look later at how we use this same concept to solve all kinds of really important problems. But writing is a great, great starting point to look at this, because writing is so difficult to do well, and it really helps to drive home the point that if we just focus on instructions, which is what so many people do in prompting, in fact, they get stuck on one type of instruction answer this question. That's the instruction that most people never go beyond in prompt engineering, to go beyond that, we have to start understanding different ways of building prompts and instructions are never going to be sufficient for many, many types of problems, particularly writing, which you're not going to write, the list of instructions that tell somebody who's never read William Faulkner, how to write like William Faulkner. You're not going to be able to do it. You might get them to be able to go and read and learn from William Faulkner and write stuff that looks more like William Faulkner, but you're not going to be able to do it through a set of instructions. But there are certain things where it's going to be a whole heck of a lot easier to explain it to the person with an instruction than to go and try to have them figure it out from the examples. So this is an important thing to note. We can modify instructions. We can modify examples. Both of those things are going to help us in producing, writing, but also in prompting, hearing in general, and all the things that we will see later. I [994:18:40] 0: in to create a mobile risk. Now that we've seen the different components of a prompt that we can use to help manipulate the writing and the output, we can start putting these together into a pattern that we can use to then help us build a voice for how we want to write and when we're using generative AI. And so we can begin using this to build a pattern free prompt that we can then fill in and use to build up our own voice that allows us to control the generative AI and what it says, how it says it, how it formats it, and all of this other stuff. So I want to give you a look at what this pattern is, and it's called the writing persona pattern. So I'm going to start off with a task that's a hard task in writing, right? I have this paper that I wrote, and I want to write a new section to it. Let's imagine that I've come up with a new pattern. So the original paper did not have the audience persona pattern, and so I want to write the audience persona pattern section of this paper. Now, every pattern that was in this paper had a very specific format, tone, sort of way that the patterns were discussed, and I want it to write in that style. Now, if I just go in and I sort of naively prompt, you know, chatgpt, for example, and I say, write a section of it on a new pattern called the audience persona, it writes something that's not at all right. It's not even remotely close to the style of writing in the paper. It doesn't have the right format. It doesn't have the right ideas. Go if you look at it, for example, it says the concept of the audience persona is an evolution and understanding and engaging with your target demographic, unlike traditional buyer personas, which often focus on the end customers, demographics, psychographics and behavior patterns, it's totally missed. It. This is about generative AI. It's fundamentally missed what this is about, because this is a terrible prompt. It doesn't even remotely capture what is needed to try to write a new section of this paper. So let's use a pattern to fix this. We're going to use the writing persona pattern. And the idea behind this is it's a pattern for crafting a prompt that will allow you to write in a particular style with a particular format, with particular ideas. So here's the basic format of this pattern. You're going to have a series of instructions on what or how to write, and then you're going to have examples of the writing that you want to look at and learn from a stylistic perspective. Now this actually format can work for all kinds of other things too, but we're going to start with looking at in the context of writing. So we will say, here's some instructions. Then we'll say, Here are examples of how I want you to write in terms of style. And then we have some type of separator, and this is important. And then we have the samples of the writing. Now, why do we have the separators here? Well, we might have writing that itself has instructions in it, and we want to try to tell the large language model. What you're looking at here is examples of how to write. It's not a set of instructions to follow. So for example, you can imagine, if you had like recipes or a a sample of writing that had step by instruction, step instructions on how to write a good recipe, it might suddenly look at those step by and step instructions of how to write a good recipe and then start trying to write a recipe for you. And that's not what you want. What you want it to do is you want it to understand that this is samples of the writing and this is not a bunch of instructions. So we typically want to have some separators, like these dashes or a bunch of equal signs or something in text to clearly visually separate that this is examples to look at samples of what you want to learn from not a bunch of instructions critical point. So this is the basic format and pattern of our problem. Now, we could have the instructions at the top, we could have them at the bottom. You may want to experiment with that different research says that one place would be better than the other. I don't I think the jury's still out on this one or where it should go, but you'll have to kind of experiment with that. The key thing is, you have instructions on what to write and sort of high level rules how, and then you have samples of the writing. So I'm going to build my prompt. I'm going to say this is an example of my writing. And basically I have gone into my paper and I have just copied and pasted almost the entire introduction out of that paper in to the prompt and then separated it, and I've basically given it all of this information from my paper. It's a lot of information about how I write stylistically, and a lot of the ideas behind my writing in this paper. And then I have the instructions, which are write a section on a new pattern called the audience persona. So you notice this is a totally different type of prompt from what I started with, where I just had some instructions. The moment we begin adding examples, we're going to get much, much bigger prompts. And that is a fantastic thing. And if you're using a tool that does not allow you to go and put in a lot of information in your prompt, you probably want to think about switching tools, because the moment that you are limited in what information you can put into the prompt, if you're trying to put a lot of information in there and it says, hey, you've exceeded the character limit your it's also telling you, Hey, I've limited your prompt engineering power here. I've limited your ability to write in your own voice. I've limited you in all kinds of these ways. So how much you can put into this prompt is really, really important. So we've got a long prompt here and now. What do we get? [2547:01:20] 0: The audience persona pattern is designed to tailor the responses of large language models to align with the characteristics, preferences and expectations of a specific audience. This pattern ensures that the generated content is not only relevant and accurate, but also engaging and understandable for the intended readers. By integrating the audience persona into prompt engineering, llms can deliver more impactful and contextually appropriate outputs, enhancing user fat, affection and effectiveness in communication pattern description, and then it talks about it. And here's the sort of more complete. And then it goes in and it starts saying, context problem. And these were were, were basically sections that were described, basically subsections that were described for the patterns. Now what's interesting is I didn't actually give it one of the subsections that I wanted to write, but it still did a pretty good job based on the context, you can see how we have gone from garbage output to dramatically better output that I look at this and I'm like, that's a reasonable starting point for me to build off of as a draft. I think it did a good job. And now I could go back and I could iterate in the conversation. I could say, here's some additional things I want you to add into that description. I could iteratively refine it and begin building up that language within that style that I want. But the other thing that's really important is this gigantic prompt that I've created now becomes a writing persona that I can capture and I can tap into when I want to go and I want to write about prompt patterns, which is something that I write about, I can go and I can take that prompt where I've given a lot of information on my writing and other instructions, I can build that up and put that into my library of prompts, and I can use it to go and write. Now some people say, like, you know, generative AI, you don't want it to write for you. Well, it's not writing for me. It's writing in my style. I have taken control of it. I had to write a lot and understand my own writing in order to build this prompt, I had to understand my voice and what I want to be said and the ideas to craft this prompt. I'm just going through and doing the I'm going through the process in a different way. Now, how much of this do I do? I do some of it, but it actually takes a lot of work to build one of these prompts, and that's why I say you to use it as a pattern, because if you put the work into doing this, it's something that you want to have as a reusable way to get a starting point of a draft. And that's the other thing that's really important is like, no matter how much information I typically go in and put it into this, I'm typically going to get a prompt that generates a good draft. But the key is, is that the draft will be so much closer than if I go in and I naively prompt with just a bunch of instructions. So this is the starting point for beginning to build writing is we have to give it a lot of information on context and style, and using the writing persona helps us to do that, because it's building up a persona of me and my style of writing and the structure and things. But it's not always going to work, and it's not going to give you perfect text. Most of the time, I find I get a draft that I then go and refine and edit, and I'm always going to read every single word in that, and I'm going to make sure that I believe in it, that it is my opinion that it accurately reflects my style, and I am going to take responsibility and ownership for it. So although I want to teach you this, to go and help you write better through generative AI, I don't think you want to use it to replace your writing. I think you want to use it as an aid to your writing as a tool. I don't want you to stop thinking about what you're writing because you're using generative a I want you to think more about it. You want to get a draft and then think, Okay, now, how do I make this even better? What ideas are not captured that I should have there? It's that starting point of getting me over the hump into the writing, but really giving me lots of time to think about, what do I want to say? What's missing now in this draft, where I go and I generate three different versions of this draft, and I look at them all, and I say, you know, what are the ideas that are captured? Well, what are the stylistic things that are captured well or not well? And I begin iterating on my writing. It's a tool to help me think more about what I'm writing, not less. So make sure you use this pattern in that way. I think this is really important. [3825:36:00] 0: The examples that we select to go into our writing persona are really, really important, but they also mean that our personas are probably going to be limited in a particular way that I want to talk to you about. So the examples are what it's going to learn from, and it's really, really important that our examples show how to solve the right problem. Now, what do I mean by this? Well, if you develop a writing persona and you do something like I did, where I took a bunch one of my papers and I copied a bunch of the text out of it, and then I create this writing persona with it. I'm showing it how to solve the problem of writing like me for an academic paper. I'm not showing it how to write like me for social media. I'm not showing it how to write like me to answer an email from my wife or to send out an email to my colleagues. That is the example that I'm giving. It is highly, highly specific to a particular problem that I'm trying to solve by writing, which is writing an academic paper. And the moment that you take that example out of context, if I try to take that example and use it to write an email back in response to my wife, I'm going to get the wrong tone of voice, I'm going to get the wrong type of information, the wrong format, structure, all that, these types of things. So when you're building a writing persona, what you're not trying to do is say, mimic me forever for all situations with this sample of my writing, because it's highly unlikely you're going to be able to get there. So what you want to think about is you're building personas that have the right set of examples. But also, fundamentally, we want to think about when we're using examples and prompts, we have got to get the right examples if we give it the wrong examples, like an academic paper, and then we say, respond to my wife based on that academic paper, I'm probably not going to get the right email out. That's probably going to have the wrong tone or to wrong content, a bunch of things that just aren't quite right. So once we select examples and put them in, we're going to have locked in that prompt to a particular sort of problem space, a particular type of writing. Later, we'll see we've locked the LLM into solving a particular type of problem in a particular way, in a particular context. So the examples are really, really important that we select and put in a prompt, and if we have the wrong examples, we're not going to do the thing that we want to do, because the LLM is not going to have enough context. Now, just to drive this home, I'm going to take that original prompt, that writing persona that I've built from my academic paper, and the introduction to it. I'm going to take that long prompt, but now I'm going to take it and then I'm going to say, write an email to my colleagues announcing my new prompt engineering course. So I've given it a context that kind of is right, like it's about prompt engineering and it's, you know, [4589:03:59] 1: yes, I did. I saw your book. Is it close? [4604:47:59] 1: I thought the picture with the No, [4626:55:59] 1: it does. Oh, that was okay, too. That was a bad picture, too. [4639:49:20] 0: I am thrilled to announce [4652:05:19] 0: nothing in that. You know, original paper is I am thrilled to announce nothing. Why did this happen? It happened because we didn't give it examples of the right type of writing, and it's reverting to something that's closer to email writing than it's good, because it's looking like really an email so it's trying to write. [4752:58:40] 2: I'm taking that thing right now. I wish we like I'll do this another time, like, eight hours long, so you can come in [4784:26:40] 0: later, give it samples. You can be watching it with me, and my prompting, not samples. I'm pulling in examples that are the wrong thing. Now the other thing that might have happened is it might have written a very academic email that sounded like a research paper as opposed to an email. But you can see the challenge is, is that the examples really, really need to match the task that you're trying to get it performed. If the task is to write an academic paper, then, you know, give it samples of your writing from an academic paper. But if you're now going to take that and try to write an email with it, your examples are no longer so it's in context learning doesn't have the right information to learn from at the same time, if your examples aren't having enough information on the right formatting of the right strategy for solving the problem, of the right ideas you need to be in the answer or the response. All of these things all have to carefully crafted the selection of examples that we put into the problem really, really important. You can just be this is really important for in context learning. It matters with our writing example. When we go and we expand in context learning to solve other problems, actually, same thing applies. Our examples are not writing voices. If they are not carefully selected the problem that we're trying to solve, we're going to run into problems just [5153:35:59] 2: like we did. That's crazy, how it can even do that. So this is what it is. This is just a sample, but this is like, and then you can just chat with all the stuff that you have in here, instead of having to go and look for it, and it can just do it for you and get consistent. Yeah, I mean, it's, it's, they're all, it's not always going to be accurate, but you food. [5280:26:39] 2: I'm just reading this right here. I'm sorry I didn't hear what you said. [5309:30:40] 2: That's good. I was going to get one of those. [5327:54:39] 2: Was it called from [5339:22:39] 2: the cheesecake, guys, and get a cheesecake. I mean a cheesecake, but a cheesesteak. [5382:39:59] 2: I was going to [5400:31:59] 2: but I'm going to eat. I'm going to go after what you did. I [5527:38:40] 2: I develop a writing persona prompt for your self to use in specific context. Period, the context could be email responses for work. Comma, technical white papers, comma, marketing copy for websites. Comma, sales outreach emails. Comma, etc, build a prompt that includes a robust sample of writing that You want the lmm to base its output on you. [6011:49:20] 2: Engaging In persuasive Marketing Company for [6289:25:19] 2: right and engaging and persuasive marketing copy For a Startup I [6666:40:00] 0: it when we're just trying to solve one simple problem right now, often going through and iterating in a conversation and giving refinement and iteratively, sort of solving the problem in conversation is the best way. But sometimes we want to build prompts that are reusable, like these writing personas, and we're really going to spend time thinking about, how do we improve that prompt, and what is the process for building that prompt? Now, one of the things that I've heard a lot about is people say, Well, I just don't know what process to follow or how to start. Like some people just seem to be able to figure this stuff out. I don't really know how to go and build a prompt that's reusable, that I can try out a lot. Now we've seen with the writing persona how we can do this sort of a structure that we can use to go and build things. Now there's other patterns we can use, but I want to give you a sort of basic process that can be really powerful and can be applied to a lot of different contexts to build really robust prompts that are pretty strong and can do what you want. Now, it doesn't work in all contexts, but it's one process that I find really helpful and that I use myself. And I started realizing that I was doing the same thing over and over, and so I gave it a name, and this is something that I teach people now, and this is called preference driven refinement of prompts. And I want to take you through this process. Basically, what we're going to do is we are going to leverage the LLM to help us build the examples for our prompt, for our prompt that we can use to show it how to solve the problem. Now, sometimes I don't have a lot of text that's solving the problem in the way that I want, or that doesn't sound like I want, or I don't have examples that I can show it of, you know, whatever problem I want solved, and so I might have to go and create those myself by hand. But a lot of times, when I'm using generative AI, I don't want to do everything by hand. So let me show you the process, and I'll come back to these steps in a minute, and we'll explain them, and they'll make a lot more sense. So I'm going to go back and I'm going to solve this problem of I'm writing an email to my colleagues to announce my new prompt engineering course. I don't, you know, have a bunch of sample emails sitting around that I can collect that have the right tone that I want to use. So what I'm going to do is I'm going to start off by asking it write an email to my colleagues announcing my new prompt engineering course. Now I'm going to use the naive prompt, and I'm going to get it to generate some output, and it goes through and it generates an email that's got a lot of problems, like the one that I keep harping on, which is it says I'm thrilled to announce and I'm never going to say that in an email. Now, how do I start improving my prompt? Other than just going and trying to add instructions and copy and paste, you know, examples, maybe, of my writing, which I don't have. In this case, what I'm going to do is I'm going to look at what it produced in its output, and I'm going to identify what I like about it and what I don't like about it. So I don't like, I'm thrilled to announce, not ever going to say that I do like this other section that it produced in another time. So what I did is I only generated that one time, but it generated multiple times just with that one problem, to get some different outputs from it. And I'm going to take sections of its output and I'm going to copy and paste them, and I'm going to bring them back into the prompt like this. I'm going to say examples of what I don't like, and then I'm going to separate those off, and I'm going to give it some examples of what I don't like, examples of what I like, and then I'm going to give it examples of what I like. And so I'm injecting my preferences into the prompt. And the way that I'm doing this is I'm having it generate some output, a lot of it I don't like, some of it I do like. And what I'm trying to do is I'm trying to give it feedback by selecting from what it created that I liked and bringing it into the prompt and what it created that I don't like, and bring it in the prompt. And so I'm injecting my preferences into the prompt by taking examples of what it created and bringing them back and labeling them as either things I like or don't like. Now there's things other ways you could label this, and we'll see that later, but you kind of get the basic idea. I'm using it to generate output. I'm taking its output and I'm essentially giving it feedback by selecting what I like and what I don't like from its output and bringing it back into the prompt. At the same time, I will typically go and add an extra instruction or two to help sort of refine so in this case, I say write an email to my colleagues announcing my new prompt engineering course, and then I add an additional sentence, something that I didn't tell it originally, which is emphasize the importance of prompt engineering for graduate students performing research. So I am doing preference driven refinement, and two things are happening. One, I'm generating examples, and I'm taking selections of those examples that I liked and didn't like, and I'm bringing them back into the prompt. And then two, I'm adding some additional instructions, so now I have this new, bigger prompt. I go and run it again, and now I'm getting output that's starting to look better. It says I'm pleased to inform you about the launch running course, so it's ditched. I'm thrilled, and it's got some more sort of structure and things that I like in here. And I'm going to go through this process again, where I'm going to find excerpts from its output that I like, and excerpts from its output that I don't like, and I'm going to copy and paste those back into the prompt as yet additional examples of what I like and what I don't like. Now you can use this to express and give examples of things other than what I like and don't like, but we're still kind of thinking about it in this context of writing, that you can begin to see how you can generalize this idea for other problems with prompt engineering. So I go back and I said, Now I have a bigger list of things I like, bigger list of things I don't like. And I add one additional instruction, which is, use simple and direct language without too many adjectives, like exciting, good, et cetera. So I have through this simple process of get it to generate some output, take things I like and don't like, put them back into the prompt. I am starting to build up this robust prompt that's rich with examples, but also is incrementally building on the instructions. And now when it goes and it generates that email, I get something that is actually not too bad. Now I've got a draft that's much closer to something that I would be willing to use, something that doesn't take a ton of editing for me to take from this form into something I could reuse. And now I've got a reusable prompt where I can go and start taking this prompt and when I need to draft some announcement email. It may not work for other emails, because an announcement email is probably different from an email responding to a particular colleague, but now if I, like me to craft an email announcement and send it to colleagues, that's probably a prompt that I could use as a starting point. So I want to go back and review these steps, these simple steps. Step one, build just a simple, normal prompt doesn't have to be super sophisticated. Input, it into the large language model and get some output out. Step two, go and find sections in that output that you like or don't like and copy and paste them, you're going to want those as examples to help guide it. Those are your preferences. [8654:29:20] 0: Now you don't have to do examples of what you don't like, but showing it what you like critically important. From my experience, you're going to take those examples of what you like and optionally what you don't like, and you're going to put them back into the prompt as examples. So you're basically modifying your prompt to incorporate what it produced that you liked and what it produced that you didn't like as examples of what to do or what not to do. And then you might add an instruction or two to the prompt, and then you're going to generate more output. And at each step, you can generate multiple times with the same prompt. And in fact, that's a good practice to get a lot of different examples that you can draw from for your preferences. And then you're going to take those examples, you're going to put them back in is what you like or what you don't like. You're going to add an instruction or two, and you're going to repeat the process. Then you keep repeating this process until you get output that you like. What I find is this can be an extremely effective process for going from a prompt that isn't at all producing what you want to one that is producing fantastic output that you can then reuse. And I want to just take you back as a quick review of what this final prompt looked like. We have some instructions that we've built up, and they're not complex instructions. They don't have a ton of information in there, but they have some simple rules. We have a bunch of examples of what we don't like and a lot of examples of what we do like, and then we're telling it what to write. And what we're getting is a is a prompt that's now becoming reusable through a consistent process that we can apply over and over. You have something you want to build a prompt for that's reusable. Start off with your instructions. Have it generate some output. Go find examples of what it did well or what it didn't do well. If you need to generate multiple times to that same prompt to get those examples, that's fine, but find those examples of what it did well and what it didn't do well. Copy and paste them and bring them back into the prompt and tell them, This is what you did. Well, this is what you didn't do. Well, you're basically giving it feedback through a kind of interesting little process. Then go back and generate, again, multiple examples, find what you like and what you don't like, bring it back into the prompt, and then you add some additional instructions and just repeat this process. And what you'll see is it quickly hones in on prompts that you can reuse, that get you to where you want to be. This simple process of what do I like, what do I don't like? How do I get it to generate more of what I like and less of what I don't like, but it's not something where you're just going to go and say, Do it once, you're going to have to really think and inject your own thought into how do I build this prompt? And the way that you're injecting your thought into it is by selecting what you do and don't like. You are becoming the judge, but then critically, you're taking your feedback, giving it back to it in the prompt. And this is the step that most people miss, because they go and give it a prompt, get output. They don't like it, they try again by modifying the prompt, but they never gave it feedback on what it did well or what it did not do well, and they missed out on the power of in context learning because They didn't give it examples. [9688:53:20] 0: Week. One of the things that's really important, [9822:02:40] 0: one of the things that's really important to me when I begin using generative AI is I want to use it in a way that makes me think more about the problems I'm solving and not less, that enriches my understanding of what I'm doing, rather than replaces my understanding like I don't know about you, but I don't want to replace my brain. I don't want to use this exoskeleton for my mind to get things done and then have my mind atrophied. So what is this simple technique that we can use to make sure that we end up at a better product, not just something that we get done faster? Because so often we go into these tools, we try to generate that email and get there faster, and we don't actually end up with a better product like that's really what we want to do at the end of the day, is we want to end up with a better solution, you know, a deeper understanding of the concept you have written a, you know, a more thoughtful, empathetic email. That's what we really want to do. We don't want to just go and, say, generated faster. And that's what so much of we see out there is, is like, copy and paste this prompt and get it generated for you. Be Done. Be Done. Don't even think about the prompt. And I don't know about you, but that's not where I want to go. I don't want my, you know, my critical thinking and my creativity to atrophy because I'm just going and generate a bunch of stuff and not paying attention. So what is the simple thing that we can do to change everything? It is the most basic, easy, prompt engineering technique ever, and it's to exploit generation. So what does this mean? Well, I want to give you just a quick, you know, glimpse at what this looks like. So let's go in and let's do the quick and easy thing, you know, write an email for me announcing my new course on advanced prompt engineering on Coursera. So I go and I write this, how long does it take for it to generate the answer? Well, this isn't the answer, and that's the starting point. Is we recognize the generative AI is not giving us the answer, it's giving us a perspective. And what does that mean? Well, it's going in generating this, this answer, but that answer is, may or may not be correct, and that's the problem. Is we think of it as an answer rather than a perspective, and we can go and generate many different perspectives on the way to solve this problem. So if I go back and I just take this original prompt and move to a new conversation and I run it again, I'm going to get a totally different email. Think about how fast that was done. It was done really, really fast. In fact, it's done so fast, there's almost no excuse for me not to exploit that generative capability and to go and explore multiple options. That is the basic thing that we can do is we can use the fact that it can generate things so fast, not to generate one and try to be done, but to generate many, many different options for different kinds of things that we might want, and then to go and select from the universe of options and use it to generate in order to arrive at a better answer. The goal is to go and look at many different options and choose the best The goal is not to generate the fastest option. In fact, this is very small amount of extra time. If you look at how fast it took me to go from one to two, I probably already doubled the quality of what I can get out because I can look at two separate things, and on average, I'm probably going to be much better. So if I take them and I merge them together, or I start, you know, you know, analyzing what I like about one or the other, and I start saying, Well, I start saying, Well, I like that part of that one and this part of this one. Maybe I can merge them together. Then suddenly I've engaged my brain, because the moment we have more than one of something, it also forces us to think about, what do we like about one thing? Why would we choose one over the other? And the moment we have choice, we have to go and start thinking about why we're doing something, how we're going to select it engages our esthetics, even if we don't actively think of why we go and we look at them. And all of those parts of our brain that, you know, help us to decide what we like and don't like, to decide what's our voice or not our voice, all of these things kick in and we start thinking again. And this is the basic thing that we're going to go and explore is all the ways that we can use this simple, simple technique of exploiting the generative capability to get more than one of something, and get more than one of something very quickly, and then use that to be able to compare many different options and to start thinking about why we're going to select one option over the other. And not if you want to talk about return on investment, this is biggest return on investment we can get. It's not that we go and we generate an email faster and we get some incremental like 11 minutes that people quote. I don't want 11 minutes. I want to do something that blows people's mind, because it's so good. I can get 11 minutes other ways. I can write faster, I can do all kinds of things for 11 minutes, that's a useless measure. What I want to do is create something new that something he hadn't thought of. I want to generate the best of something that nobody's ever seen. I don't care if I get there faster or not. I care about the quality of what I'm doing, and the way to get to the quality is to spend more time thinking about, and that's what we're going to explore. How do we get, [11226:08:00] 0: not a faster outcome, by exploiting articulate this, but [11257:20:00] 3: it's got us both off kilter. There's a certain unsettling awareness that we can't shape like looking at a reflection that's simply so [11291:12:00] 0: let's go back to that ROI question. What is our return on investment of generative AI? Which industries are going to be affected? Well, I'm going to give you something that I think will help convince you that every industry is going to be affected, and that the ROI on generative AI can be tremendous with a very, very simple technique. Now this is, I think, a prompt engineering is about, how do we solve problems and reinvent what we do with generative AI, I don't think about it just as how we go and arrange words and exploit little tricks in the pattern. Certainly, the patterns are powerful. The reasons the power patterns are powerful is because they give us new ways of thinking about solving the problem. So let's jump into the idea of problem solving, where we are exploiting generation. So this is one of the fundamental, most important things that we can do in prompt engineering to really have an impact, and that is we go and use it to help explore many different ways of solving a problem. So whenever we go into generative AI, or whenever we have a problem to solve, we need to simply remember the pattern that I can go and ask for options. Let's use the Ask for options pattern. And the ask for options pattern is we never ask for one of something. We ask for more than one of something. Every single prompt where we need to produce something, we start by producing more than one of it. So in this example, I go and I say, give me five ways to solve any prompt that I give you, or, sorry, give me five ways to solve any problem that I give Next, ask me for the first problem. So I'm asking, Can you end up doing a little bit of flipped interaction here to get it to ask me for the problem solved? It says, Sure. And now I go and I say, I need to set up a registration system for a small webinar. I want to be able to send follow up emails to everyone that use the form data that is submitted to generate unique prompts for a large language model for the person based on their area and expertise. And this is a little bit under specified, and I realize now reading it back is not the clearest thing, but here's the problem that I'm solving. Now I then go and insert this, and now I'm getting ideas generated how I could solve a problem. Method, one, use Google Forms and Google Sheets. Okay, now I've got an option, I've got a series of steps, and then I've got the pros and cons. And this is important, because when we start thinking about, you know, that we want to go and try to solve a problem, and we're going to generate multiple different, you know, possible solutions, we also want to start thinking about how we're going to compare and contrast them, the pros and cons. And this is really where the kicking in of the thinking happens. You know, when we start getting multiple options, we start thinking that we also want to get different perspectives on what the pros and cons might be of different solutions, especially if there's solutions in there that we don't know. So what we're asking for is give us multiple solutions, but also compare and contrast them. And now we're seeing method one, Google Form and Google Sheets. Method two, use an event management system like Eventbrite, and then we've got pros and cons. Method three, using a custom web application, pros and cons. Cons requires development skills or hiring a developer. Method four, using a CRM system like HubSpot. Method five, using a no code platform like airtable and Zapier. That's actually really interesting to me. That might be one that I might want to go and try and do something really custom and unique, but I wouldn't necessarily have thought of that if I just jumped into the problem. And this is where the real ROI, the simplest ROI you can get to in generative AI, is to start using it to support your decision making by simply going out and seeking multiple perspectives on how to solve a problem. Now let's think about that if you go and arrive at a fundamentally different approach to a problem that solves it better. What is the value to this? Well, it's a function of the value the importance of the problem. It's not of it's not some 11 minutes thing. It's about how well you, I mean, to how important that problem was, and the difference in the solution that you arrived at because of it now is this easy to measure? Does this fit into this standard types of things that we go and assess? No, it's really hard to measure, but it's something simple where you can have tremendous impact on what you do, and the impact could be transformative, because if you apply it to the right decisions, and you arrive at a much better decision, or at the very least, you help guard yourself against not having explored a particular option. That's tremendous return on investment. That is the simplest thing that you can do is start looking at how to solve a problem different ways. Let's take another example. So I'm camping with my family in the woods, we have tinfoil, a skillet, and no other cooking tools other than fire. Give me three ways to bake a cake, and compare and contrast the difficulty of getting the cake to turn out. Assume I have a store bought cake, so I'm telling it the problem. I'm giving it assumptions, and I'm telling it how many solutions that I want. It comes back, tenfoil oven, prepare the cake better, according to storebought instructions, take a large piece of tinfoil, create a dome, like structure entrance tall enough to cover the cake, pour the batter into a foil like skillet. It goes on and on. Now I need to take is just one second to just fully appreciate the insanity of this, like if I had like 100 PhDs, all the supercomputing power in the world, and you asked me to build a system two years ago that I could take an arbitrary problem and it would give me a potential solution to it with steps and difficulty. Forget it not possible. I cannot do this as a computer science professor. In fact, no tech company can maybe outside of OpenAI or tropic or one of these companies that was building these models, but I don't, not even sure they were there yet, and now you have access to this right here at any time. I do not know why you would not tap into this to at least get perspectives on how to solve the problem. You don't have to accept its solution. And in fact, you're going to look at all these solutions, and you're going to carefully vet them, but it's going to open your mind to possibilities, and that is huge. What is the next possibility that skillet, bacon, prepare the cake batter, grease the skillet, pour the batter in the skillet, Cover the skillet with a tight fitting piece of tinfoil, place it on the hot coals, goes through it. Next method three, Dutch oven substitute describes how to do this with tinfoil. And we've got all these different options. And then it comes back, and it gives us a comparison, heat control, outcome, ease of use. And this is super valuable information, because now I'm thinking through what are the different ways I'm doing it, but I'm also getting a framework now to start thinking about, how do I compare contrast I'm learning in the process, because I already have been seeing issues surface that I need to be aware of, like heat control. If I put this in a skillet and I put it on coals, I might burn the bottom of it. I might have difficulty. And it's pointing that out, you know, method two, high, you know, requires constant monitoring and adjustment for heat control. And then it has outcomes, and it lists the outcomes. Method three, it says has the best outcome. Now, do I agree with that? I don't know. I have to think about it and evaluate it, but now I'm starting to have a framework to explore many different options to improve my thinking about the problem solving in general, and to go and, you know, widen my perspective on what I'm about to do. It's, it's required me to think more about the problem and not less, because I'm going to exploring more avenues to solve it. I'm exploring how I might, you know, compare them and contrast them. I have to think through all this, and it's enriching my thinking. Does this gets me get me to an answer faster? It might get me to an answer faster. It might help me solve the problem faster, particularly if I have no idea how to solve it. Is it faster than asking for one? Maybe not only marginally slower, because this thing generates a possible answer, possible perspective so incredibly fast, and there is absolutely no excuse not to go and exploit that capability to generate more than one of something, particularly more than one perspective on how to solve a problem. So the next time you have a problem, I want you to go and employ the simplest possible prompt engineering technique that you can use, which is to give me options pattern. Give me five of something in comparing contrast. Give me three of this in comparing contrasts. That is the simplest thing you can do to dramatically improve what you're doing with prompt engineering and to get a huge return on your investment if you're not already doing this already, guys, [13639:12:00] 0: over the past few years, I have purchased three water events currently. Let's compare some good let's compare and some contrast, some approaches that we could use to get different options. Now, there's many different ways that we could go about thinking of generating the different solutions that we're going to evaluate, or the options for whatever it is that we're going to be looking at. And let's just talk briefly about some of the things you want to might want to consider when doing that. So let's go into chat GPT, and let's just start really simple. I'm going to just put in a prompt from before, which is, please generate an email for me announcing [13840:10:40] 0: my new Coursera [13852:58:40] 0: course on prompt engineering, and I copy that. Now I could go in and I could generate like this. This is sort of the default way that many people use generative AI. And I could generate an option, and then I could copy and paste that option, hold onto it and have it. And then I could go back and simply edit here. In fact, I don't have to do much at all. I could just add, for example, like a space, and I've actually changed things a little bit, and then I could go and regenerate again. This is one really simple technique to go and generate different options. Is just go and do slight little tweaks or resubmit the prompt. Another thing we could do is we could just go start a new conversation, put exactly the same prompt in. And I don't know why it's wanting to do that, but I could say, please write an announcement for my new course on Coursera, related to prompt engineering. Now I could have used exactly the same prompt if I remembered exactly what I wrote, but this is kind of showing another thing that we can do. We can do. We can switch a conversation. We can also edit and switch the prompt. But the key is, is that we want to go and generate a diverse set of perspectives and options. Now one way is one conversation, go and edit the prompt over and over and get different generations of it. So the key is, is that when we do it in separate conversations, or when we go and edit the message over and over, we're getting totally independent responses. To some degree, that is that it doesn't see what else it's said. There's no other option it has. It can't see any of the other options, so it can't take them into account. Now, if I want to go, and I do want it to take them account. I can go and I can say, Give me three different emails to announce my new Coursera course on prompt engineering. Now I'm getting three different generations all at once from one prompt. The downside of this, or the upside, depending on how you look at it, is that it sees all of them. It sees the one it generated before. If it's heading down some particular trajectory, if there's something that's just not quite right, it's not going to, you know, potentially make them, you know, as unique or interesting as we might want. So sometimes going in different conversations could give us better results, because we can go and try it out in lots of conversations, make sure we're getting sort of independence in the ideas. Sometimes we might even want to go into completely different, large language model tools. We might want to take it into chatgpt, anthropic, Gemini, whatever the tools are that available to you. Try that on, a lot of different ones. Collect a whole bunch of different solutions and evaluate them all. Sometimes we might want to go and just make it sort of easier. And often this is what I do, is just go and say, Give me three different options, or five different options, compare and contrast them. Another thing that we can do is we can go and say, Give me three very different emails to announce before some prompt engineering, or even better is we say something like This. Consider [14722:08:00] 0: fundamentally [14733:20:00] 0: different approaches to announcing a Coursera I worse on prompt engineering via email. Now use each of those approaches to write announcements, and so what I'm telling it is I'm kind of giving it information, not only on generate different ideas for me, but I might also want it to go and think about the different approaches that could be used, so really, to sort of abstract up an additional level and say, what is it that we could vary? And in this case, if we have different very, you know, different approaches like informal and professional, personal and enthusiastic, brief and direct. There's lots of different approaches. And now it's thinking about, how do I vary at the approach level, as opposed to down in the words of the individual emails? And so starting to think about, what is the dimension that we want it to generate options for? It's like, where do we want it to go in and like, at what level of abstraction do we want it to be thinking about when it's varying what it's doing? Do we want it to just be at the word level? Do we want it to have a different approach? Do we want some different marketing framework to be employed? Like, do we have five different marketing frameworks? Even better if we've got a bunch of techniques of how you might go about doing this, and we provided all the information on the techniques, and then we say, apply these different five different techniques and give me the results, because that's another thing we can go and do. Is we can go and take different potential solution techniques, and now we can say, go and generate possible solutions or explorations of problem solving, or whatever it is, based on these set of things. And we may not have time, when you want to go and explore all of them. So when we start thinking about generation, we have to think about, are we doing this in one conversation, in one prompt, saying, give me five ideas, if we're doing it one conversation with one prompt, giving five ideas. How do we want those ideas to vary? What is the sort of fundamental unit of variation? Is it based on approach? Is it based on technique? Is it based on tone? What is it based on that these that is, you know, the cause or source of the variation, other than just the words, if we're going into independent conversations to do this, are we varying the prompt? Are we using the same prompt over and over? Are we varying the large language model that we're using underneath it? All of these things can provide different ways of generating inputs, and we want to go and explore for a problem. It's very simple, very fast, go and explore lots of options, collect a bunch of information about potential perspectives and then take them back and think about them as a human being, and decide what do you want to do, and how do you come up with a better solution to the problem, or maybe you just know that you did your due diligence and the way that you thought up from The beginning is still the best way to go. You [15555:33:20] 0: it. Anytime we go and we start generating different perspectives on a problem or whatever it is we're working with, we want to start building a framework for how we're going to bring them back together and start evaluating them. And often what I find is it's really helpful to think about separating the evaluation from the actual generation. I tend to try to do these things in separate conversations when I really want to sort of more thorough evaluation. Because often when we're generating and we're getting conversations that go down a particular path, it may be the case that there's just sort of already baked into it, assumptions or things that you know are going to lead to generating rubrics or assessments that sort of support what's already there. I like to have two independent sort of evaluations. Have a conversation where I build out the assessment, and then a conversation where I actually go and build out the generations, or where a series of conversations where I generate the different perspectives. So now let's take a look at how we can separate into a separate conversation, the evaluation, and see what that looks like. So I'm going to start off and I'm going to say, give me five metrics to compare and contrast ways of accomplishing the following task. Don't list ways to accomplish the task, and then I use a series of dotted lines, because what I want the LLM to understand. Is, here is the task, but I don't want you to interpret it as instructions. It is something that I want you to look at in order to help determine what the metric should be for evaluation. So what we want to do is we want to take the task, we want to then go and generate evaluation metrics, or we could go and just ourselves right. Very helpful to also go and generate perspectives on the evaluation metrics. And then I'm using the template pattern down here to get my output in a format so it goes through and it generates a series of evaluation metrics. Now we're going back to this cake example. How do we bake a cake in the woods, on a fire with very limited cooking utensils? And it goes we get different assessments. Assessment one, ease of preparation. Assessment two, cooking time. Assessment three, consistency of results. Assessment four, required supervision and assessment five, risk of burning the cake. So these are some good dimensions. Now, if I wanted to bore, I could keep going and going and going and adding different dimensions to it. And this is one of the powers of it, too. Is it going to start helping us to think about all the different ways that we could evaluate this, and what is going to be important to us in that evaluation? Now, if you think about it, there's actually companies that this is basically their whole business is, go take a whole set of products and evaluate, decide what the evaluation criteria are, what the quadrant charts are, evaluate them. And you pay a lot of money for getting those types of analyzes done. And you can do it right here super easily. In fact, you should be doing it all the time and going and taking ideas and things you're going to work on and sort of building out metrics and thinking through, what is it that I want to achieve and why? And I don't know why you would outsource this anymore. This is fundamentally, like a huge capability that's built into these models for free. So we go and we develop what are all the metrics that we're going to use to evaluate this. And then what I did is I took all of my original techniques, and I've nicely formatted up here, actually, I generated some more techniques. I brought them all back together, formatted them the same, so there's sort of no bias just because of the formatting. I brought them all together, and then I put them into a prompt. So I basically said in the next message in the conversation after generating all the metrics is I said, Now evaluate these techniques using these metrics, and I've copied and pasted them all together with similar formatting into the prompt. And now what we get is something awesome. We get one an assessment of the tenfoil packets, ease of preparation. Moderate, requires cooking, you know, forming foil packets. Cooking time, we get the skillet cake, we get the tin foil oven. We get the foil packet cake with the steam cake. Now, what's interesting is, the first time I did this, I didn't get, I don't believe, a foil packet cake, and I didn't get a steamed cake. In fact, I've gotten all these different options. Now I'm up to, like, five good, solid options. In fact, there may be things in here that I didn't have the first time. Well, I think maybe the Dutch oven. Well, 10 foot 11. I think maybe it's doing the same thing. But you can see I'm starting to get all these different possible solutions for this. Now. I've got all kinds of different metrics that I could use to evaluate them. I've got different potential perspectives on those metrics with respect to the different possible solutions, and now I have this rich set of information that I can go and think about, what am I going to do? Now, even better, take this and tell it to put it into a table for you. Put it into an evaluation matrix, put it into a quadrant chart. In fact, if you're producing lots of quadrant charts, evaluation matrices, other types of things you should be using this to help support you, you know, make sure that you haven't missed something or in some critical dimension that you haven't, you know, missed some possible solution or competitor or product or approach or whatever it is, and taken it and brought it into your evaluation. Super powerful technique, go and generate lots of options for evaluation, and then, if you're generating lots of solutions or products, or whatever it is, you know ideas, go and take those and then evaluate them with Your many different options or metrics that you produced. You [17066:40:00] 0: it. If you have the right type of problem that you're trying to solve or the right type of thing that you're trying to generate, you can do something amazing with generation and exploiting generation, and that is, you can do automated search for solutions that meet certain criteria that you're looking for. Now this is probably most applicable to people that are programmers, but I want to give this video to everybody, because I think there's lots of potential for using this, or at least having knowledge that this is possible. Can help you in thinking about how your organization might go about exploiting this generative capability. Now, this is really important if we're talking about software development and generating code. There's no reason to ever generate one version of code. There's no reason to ever go into the tool and say, give me one possible way to write this code. You always want to go in because it's almost free to go and generate multiple types or multiple versions of the code. Now, if you think about how important source code is right, you're going to generate this once, and it's going to be used a gajillion times, so why not take the time to get it right? So in software, we have this nice property that when we write code with generative AI for software, we can go and do something simple, which is test it and see if it captures our tests, like our tests that tell us does it work or not. We can do this for all kinds of problems outside of software as well, where we can go and generate something and we can test it if it works or not. Think of a crossword puzzle. You can generate potential solutions to a crossword puzzle, and you can check if they are correct or not, in sort of an automated manner. Now what we want to do is we want to think about going and generating lots of solutions and then automatically testing them to determine which ones pass basic, fundamental criteria that we want for correctness. And whenever we have a problem that has that sort of characteristic, that is, we can generate a possible solution, and then we can check it to determine if it's correct. Now, where this is going to be really valuable to us is in places where it's hard to generate the solutions, where it's complex to try to generate a solution, but it's easy to check if a solution is right or not. Those are the places that we will really benefit from this technique. Now, what happens when we have this is we can go and automate the process of generating solutions and checking if they're correct or not, and then the ones that are correct, we can then go and further use some objective criteria to decide, is it a better or worse solution? Now, there's many different ways that we can come up with the criteria for deciding which one's better or worse. I'm going to give you a simple example in software. So we have the the generative AI go and write code, we then test and see, is that code correct or not? Is it functionally correct? Does it do what we expect it to do? And then what we can do is we can go and test that code and see how fast it runs and is, and we can use that as a benchmark. We can go in and say, the quality of this code is related to how fast it runs and whether or not it passes all the tests. And then if we have multiple different versions of the code that all pass the test, we can go and rank them automatically by based on how fast they are when we run them and when we do a performance test on them, or some series of performance test. And so suddenly, when we have that, we can then go and we can turn generative AI loose, and we can basically automatically begin searching over and over, prompt for a solution. Test it, you know, score it, rank it, do it again. And if we want to get, you know, 1000 solutions and take the best one, suddenly we're way ahead of the game, right? Because we can go and let this thing run all night. We can let it run 10,000 solutions if we want, and select the very best one for us. And if we have a really important problem, a really important piece of code that we're trying to produce, this can give us a really, really valuable outcome. You know how you come go about doing this? You probably have to be a programmer at this point, or you could probably go and describe this problem to chatgpt and get it to generate some Python code for you, or some other code that you could use to actually go and automate this process yourself. That's beyond the scope of this class, but I want you to know that it's possible, and I want you to start thinking about opportunities to go and automate the search using some objective criteria. Another way you can do it is just try to get if the problems the right type of problem go and, you know, generate a lot of solutions, have a human evaluate them, but generate a lot of a lot of solutions. You know, get a big group of people together, because often it's really simple to, you know, take a whole bunch of solutions and quickly dismiss or rank them. You know, even if you have 200 solutions, you have a group of people, you could probably go through them really quickly. And so you can help, you know, produce good results that way. You [18400:00:00] 0: it. Solutions, you know, get a big group of 200 solutions. You have a group of people, you could probably go through them really quickly, and so You can help, you know, produce good results that Way. [20335:44:00] 0: We've seen the ways that we could build prompts that help us write more in our style to keep control over that language. And now I want to do is I want to take a step back. I want to kind of reflect on what we've learned and use it to give you a sense of the core components of a prompt and a mental model of prompts that will help you to think about what do I need to change in my prompt to achieve my outcome or goal? Now we saw one way of doing this, which is preference driven refinement. Now we're going to look more generally. Where do we need to go and look into our prompts? And we're not getting something right now, there's five components to a prompt that I'm going to talk about, and I think these will really help you out in sort of thinking about, you know, what do I need to do to fix this problem? Why is it going wrong? And where do I need to start? And the model I use is, I want you to think about going and talking to an intern, right? You've just gotten this new intern that's been brought into the office, and now you have to instruct this intern on how to accomplish a task, task. So one of the very first things that you're going to do with this intern is you're going to give them some instructions. And so what we're going to do when we start thinking about prompts is we're going to start breaking them apart. So I've taken a prompt on writing on a new topic, in this case, the audience persona, and let's imagine it got the audience persona wrong the first time that it didn't actually get it right, and it wasn't exactly what it thought it was. And now I have to instruct it here's what it really is. So I've taken a prop where I've gone and fixed all this and I've broken it apart in these five components, and we're going to look at them each one at a time. So here's the five components of the prop, the instructions, the information, the pattern, slash examples, the output format and the trigger. And now we're going to talk through how we use these to teach that intern to get the right answer. So first, let's think about instructions. So you have this new intern, you've been, you know, given this intern, you're so excited. What is the first thing you do? You start telling them what to do. You give them instructions on what you want. And so this is the most common thing that people are going to prompt, is they focus really just on the instructions. I'm going to tell you what to do without thinking more, sort of broadly about all the things and all the activities that we do to teach somebody how to accomplish a task. Well, particularly a task that's dealing with text, because most of these large language model tasks are really about going and doing something and producing some text reflecting the outcome. So you can think of this as you're going to telling your out your intern to do something, but the intern is always going to bring you back a document, a report, an email, a text message, something like that. And so that's part of the mental model is knowing. What we're trying to do is get the intern to do the work, but we're also trying to get that work reflected in text. That's the only way that our intern can communicate with us general. Now there's other ways, but we're focused on text, so the first thing we're going to do is instructions. I'm not going to spend a ton of time on those, but that's the starting places. We're going to tell them what to do. And in this case, I'm just saying write two paragraphs about these facts in my stuff. Now, notice I'm not telling it what the facts are about yet. The second thing that we're going to do with the intern is we're going to give them the information they need to do the job. We are not going to rely on their knowledge. They're a fresh intern. They may not have knowledge of our processes. They may not yet have access to all of our internal documents, they may not know all of the important pieces of the puzzle that need to be brought into the answer that they give. And this is a problem that many people go and have, is they just rely on the interns knowledge which it may be out there on the internet, the inner the intern may, you know, be able to remember some web page that the intern saw, but at the end of the day, we don't really want them guessing, and that's what the intern likes to do, right? Is the intern loves to guess. Right? It's like being a given a test. This intern really wants to do a good job. The intern does not necessarily want to come back and ask questions, although we can tell the intern that's the Flipped inner reaction pattern. That's the power of telling the intern ask me questions, is we can instruct it if you don't know, ask just like we would do with any other intern. But this intern is sort of biased from the beginning to try to guess and do a good job. So the second thing we're going to give the intern in that we're giving the large language model and a prompt is information that it needs to perform the task. We don't want it to guess. You can't necessarily go and look things up on its own. Now, that's can be, you know, overcome with tools and agents, but we're not there yet, so we're going to give it the information that needs to perform the task and the prompt. Now, what's the next thing that we typically do when we're teaching and we're instructing an intern is we'll probably go and give them examples patterns to follow. Here's how it's been done before go and look at this and learn from here are examples of other reports that we've written where we've done this analysis. Go and learn from them. So the patterns and examples and the prompts are something that we give to the intern to go and learn from rather than providing all of the different instructions on step by step how to do it, then we can rely on the fact that this is huge, and this is something that, for example, [21777:57:20] 0: like we did with our writing, where we showed examples, [21793:30:40] 0: and learn from those samples, you've learned to build up rules in its head of how to write or write like the samples that we gave it. And so learning is a core part of this, and learning from examples is a really important thing that we need to think about in fact, it's one of the most underutilized prompt by most people that can have the most impact. You can quickly go from a prompt that just is not working very consistently or very well to one that works like all the time. And so examples are super important, because teaching through examples is really powerful. The next one that is underappreciated is the output format. Now, what is this? This is like when you can your intern a template for what you want. You hand them a document with placeholders, and you tell the intern, this is the format that I want it in. Here are the placeholders that I want you to fill in. Go and follow this recipe. It's like a It's providing structure. It helps the intern in so many ways, because the intern can look at this document and say, This is exactly the information I need. This is exactly have to have to format it, and it can take away some of the mental load. But thinking about, what is it supposed to look like now, we could try to get to this same place by going in the beginning and say, here's all the instructions on what sections I want and how many and how they should be formatted, and we could try to represent that all as instructions. But often what's helpful is to give the intern a template for what we want. Hand that template off and then take control over the format of the output. But the template also can provide structure to help guide the thinking or what information the intern is going to go and produce. And then the last one is an interesting one that I don't see used that often. It's not one that you have to know, but in many cases, it can be really powerful, especially when you want to eliminate some ambiguity about what is it you're going to do first. So I call this a traitor. You might think of this as the place to start. And what we want to remember is that large language models are trying to predict the next word in a sentence. So you know, if you've ever seen one of my prior courses, you've seen me talk about Mary Had a Little Lamb, and we say Mary Had A and they tried to get the large language model to predict little the next word in the sentence, right? It's being trained to follow patterns, right? And we want to exploit that and take advantage of it to try to get the intern headed in the right direction by giving them the first step. And often, the way that we can give them the first step is we can write. Start writing. Think about certain writing. The first bit of the output we're giving the intern, we're going to say, we're going to start right here, and we're going to start writing out the overview first. So in this example, what I'm doing is I'm saying the first section we're going to write is overview, and then we're stopping the interns like, Okay, I'll go and finish it. You started it. I'll finish it. And that's what this is. It's a trigger to try to send the large language model off down a particular path to go and start finishing the writing. So what we're doing is we're explaining it's, it's it's the thing that it likes to go and follow patterns to try to get it to go and do something. And once we start getting it headed off in the right direction, if we can get it to do the first step, it'll probably do the second step. If we can get it to write the overview, then I'll probably see that after the overview, it needs to write the two paragraphs. And so the idea behind this is to try to, you know, kick it off in a direction by giving it a part of what we want as the output. Now it's really powerful when we showed it a bunch of examples with very strong patterns, and what we use as our trigger is a partial example. We give it part of the of the pattern that it saw before, and that really tunes it into, okay, I need to complete the pattern you just showed me, as opposed to go and complete a pattern that may have seen somewhere else and what it learned in the past. So when you're thinking about props, I want you to think about these five components and think about an intern like, if the intern's getting the answer wrong, is it because it doesn't have the right information, or is it because the format of what it's got is wrong? Well, if the format's wrong, maybe what I need to do is go and provide it a template. If it's, you know, writing something but it's in the wrong style, or the analysis type is wrong, or it's not thinking through the problem right. Maybe I need to give it more examples to learn from, or maybe there's some simple instruction that I forgot to give it that I can just tell the intern that will fix everything, like go and write in all caps. And so what we want to think about is when we're going to building, you know these prompts is, which one of these parts of the prompt do we want to go and work with and Adjust in order to get a better outcome in [23123:33:20] 0: this part of the module. Now we're going to one specific component of a prompt and really look at the power, and that's the power of examples. Now, we've known for a long time that we can use machine learning, and we can train models to go and do tasks, and everybody assumes that in order to tap into machine learning, you have to go and train your own model. And that used to be true, because what machine learning did was it created models that tended to be very brittle and narrow. You would create a model and then you couldn't really reuse it, because the moment you change some little bit of the formatting of the data or some slight aspect of the task, suddenly the machine learning model would break down. So you train a model, and then you would try to go use it. You'd realize it doesn't really work that well. You try to go collect more data, you try to cleanse your data further, do all this work. And so it took a huge amount of work, because you had to go and really cleanse your data. You had to really spend a lot of time on getting your data just right now we're going to still see that we have to care about our data, but not at the same degree that we did before. Second piece of it was you had to spend a lot of time training a model in order to go and perform some tasks, and the model tended to be specific to the task you were going to work on. In fact, your whole system had to be built around that model to perform and do that task that you wanted to do. So it took a ton of work. You said, Okay, I want to predict course titles for my next course. Man, is that tough, right? You've got to go and train a model that has all this information on course titles that are relevant to what you're doing, and then build an entire software system around it in order to get you know predictions of course titles out of it, really hard, really expensive. That's why you have teams of data scientists and AI experts at companies, because for you as an average user, you couldn't do that. You had to go get them to build it for you, and then they handed it off and you got to use it because there was no reusable way to do that, right? You had to start from scratch every time they had to build a custom one for you. Now what's happened with generative AI is it is a model that is incredibly reusable. It is totally sort of like this generic platform for doing all kinds of incredible machine learning tasks. And so we can go and tap into what it is already learned, and then we can use that model to do all these tasks without having to retrain it for our tasks with our data, necessarily. Now, what's amazing is we can retrain it now in a prompt, and we're going to look at this in this module of how we go and teach it new tricks. But anybody can teach it new tricks without having to resort to fine tuning the model, where we're actually changing the weights. Now people use fine tune in all kinds of ways. I'm starting to see it used more and more loosely, basically to mean in context learning with a prompt. But in general, if you hear somebody saying they're going to train a new model, they're going to go and fine tune the model weights, there's a good chance you don't actually need to do that. You just need to use in context learning in a big prompt in order to teach the dumb model new tricks. And what's going to be amazing is you're going to see that you are capable of doing all these tests. You don't have to go and train a custom model to perform something that would have required a custom model before. In fact, you just go and take whatever it is, large language model. Now you want to go use the frontier models. Right? These are the big models that are out there, the most advanced models from the key players like anthropic and OpenAI and meta, you want to go use those big, top tier models to do this, because those are the ones that are most flexible and most able to adapt to new tasks. But you don't have to do anything complex to use them. You just simply go and prompt them. Now you can go and use them as they were trained, and they're immensely capable, but you can also go and teach them totally new things. And the way you teach them new things is with examples in the prompt, we go and we drill in on that part of the prompt that is, examples, and we use those examples to teach it to do new things that previously would have required training a custom model from scratch, so we use it again, give it examples. And the beautiful thing because the examples don't even have to be that carefully formatted, and that was so much work, we had to really think about carefully picking apart the data and cleansing it and getting in the perfect format. And we don't have to do that now, because these models can pay attention to the data and figure out important pieces they need. Now, if we give it the wrong data and we teach it the wrong thing, of course, it's still going to be a problem, but we don't have to worry as much as about all these little details about formatting and other stuff. So what we're going to do is we're first we're going to look at how we can reuse the existing AI capabilities in these models, existing things that it's learned to do on classic tasks, like classification, prediction, clustering, then what we're going to do is we're going to learn how we can train the model in a prompt, and realize that you really are training it when you're doing machine learning through in context, learning in a prompt. And this is state of the art. It is incredibly sophisticated, incredibly powerful. You're not giving up much to do this. In many cases, you're actually going to get a beat out state of the art. If you've gone and spent a vast fortune to train your own model. And there's many examples of this. For example, Bloomberg went and trained their own custom model on their own. Think it cost ten million and out of the box, GPP four was better at those same tasks. So you could go and do really, really well with what's just there. You just have to know how to tap into these things, and you have to recognize that you are a data scientist and AI person now that can tap into those capabilities. And now is probably the time to go and learn about how the ways you evaluate the outputs, which is going to be beyond the context of this class, or how you use these different building blocks. But I'm going to get you started showing you how to tap into these models as a reusable model that can be used across a variety of different task types, and then how you can teach it new tasks, how you can teach it from your data and all through prompt engineering. [24759:38:40] 0: One of the amazing things about generative AI is we can actually use prompt engineering to tap into machine learning and to do all kinds of AI tasks that only specialized skills allowed you to do before you had to be a data scientist or some AI expert to go and do a lot of the things that we're going about to do with generative AI, simple props. Now this is something that people don't recognize, is that they have some of the most advanced AI and machine learning at their fingertips now, and you don't have to go and do a bunch of crazy stuff to access it. And in fact, all you need is prompts and copy and paste, and you can do wildly powerful things. In fact, many of the things that I'm going to show you that you can do with generative AI in terms of AI and machine learning would not have been possible. Wouldn't matter how sophisticated the data scientist to work AI expert you were before this stuff came out a year or two ago, nobody on the planet could do what you're going to do as well as you can do it now with anthropic Claude or one of the other models, and I'm going to show all of this with anthropic Claude. Now, the first task that we're going to look at is a common machine learning task for a common AI task that's called classification. So what is classification? Well, classification is basically putting labels or categories on things. So you can imagine, you have a bunch of objects on a table, and you want to label them as either being a fruit or a vegetable, and so you're going to go and look at each object, and you're going to apply the label that is classification. Or you can think of it as applying a category, putting things into categories. This is a vegetable. This is a fruit that is classification. And it is a foundational thing you do in all kinds of systems that use machine learning and AI. And you can do it super easily, and it's incredibly useful. So I'm going to give you an example of how you can use classification to do something powerful and useful to you. Now I'm going to give it an example of social media, and I'm going to go through a whole example of social media that if you've got forum data where people are submitting survey responses, where you have marketing data, or you have some type of comments about your product, or you have emails, where you have chat communications, all kinds of things where you want to take text and pretext and you want to begin applying labels to it, or it could be Excel data, all kinds of rich data. I'm going to show you how to do classification with props. So let's start off. I posted on social media the other day on LinkedIn, I created this post, and I've been looking at the analytics. I think it's really interesting to look at the analytics and trying to think about, how does that tell me who's paying attention to my content? Who cares about the classes that I'm creating and helping to think about what types of classes do I need to create that I haven't created already, and who should I focus on when I'm giving examples in the classes? So I created this post, and then I went and looked at all the comments that had been created from it. Now, how do we get from LinkedIn and the page that I'm looking at? In order to, you know, get data out of that, in order to machine learning, right? Everybody thinks, oh, I need to go and, like, get access to the API, and I need to, like, cleanse that data. And I have to do all these careful steps. And it's going to take so much work to do that. No, all it takes now is copy and paste. Absolutely mind blowing. So what did I do? I went and copied. I selected all of those comments, I just highlighted them all in the page, and I hit copy with all the weird formatting from the page and the HTML and everything else. And I'm going to take that raw text, which you see here. It's much, much longer than this. I mean, this was huge amount of text. And I think it was, like, the text from like, 60 plus comments. And this is what it looks like. You notice something about it? It's not formatted well. It's got like, 2d meaning, like, two days ago, and like, like reply to two replies on comment, all this weird stuff. It's got the actual comments. I've actually got the actual job titles and names of people and things like that, but you see something interesting. I haven't carefully formatted this or reshaped it in any way in order to do this task, all I've done is grab the raw text and this capability of generative AI is fundamentally underestimated. The importance of it and the power of it. And then I take that and I'm going to go into anthropic Claude. And at the top of my prompt, I copied and pasted that comment information in. Now Claude, the way it shows it, is kind of nice. What it does is it says a file attached. Now actually, that file is the data that I pasted in, the text that I pasted in, and now it allows me to focus on my prompt. But if you were in another tool like chatgpt, and you had copied this past at this end, you would see it like up above the prompt. It's just raw text. In this case, it's showing it like an attachment. And then I say, please help me classify the comments in the response to my post. I want to classify the response into the categories, agree, disagree, neutral and other. So those are my classes. I wanted to label every single comment with one of those labels. And this would be extraordinarily difficult to do with machine learning. Prior to this, you would take you a lot of work to go and build that system to do it, and you'd have to clean up the data and do a bunch of stuff in order to get this to work. Well, particularly as powerfully as we're going to see it work. And then I tell it produce the output as a CSV, meaning Comma Separated Values like you could import into excel in the following format, job title, comma, five word, summary, comma, response, category. So I'm actually doing some other tasks as well in here, like summarization, but you'll notice I'm taking the data and I'm applying classification to it, and I'm also reshaping it at the same time into a new output using the template pattern. And this is a really powerful pattern to know, is taking control over the format of the output and then putting that data into that format. So this is my prompt, and now what do we see? It goes through and it takes all of the raw comment data and it reshapes it into comma separate values. We've got rows of data, one row per comment, and then for each comment, we've got the title, the job title of the person that posted it, the summary, the five word summary of their post and or their comment, and then the class label, which is where the classification is happening, which is agree or disagree. And well, in this case, everybody that commented on it agreed with what I was saying. And I read through this, and I think it's actually pretty accurate now. It makes sense, right? Posting on LinkedIn, and the people that are following me are probably going to respond if they agree. So a lot of people are agreeing with me here. I went further into this. I could have probably found a section where there's some neutral or some other labels here, but most of these labels are basically agreed, and it's doing classification. To do that before would be extraordinarily difficult. But all I want to do, if you remember, and we go back and we look, is I took the raw data in this format right here. That's crazy, right there is no data sanitization, no cleansing, no special reformatting, no nothing to get the machine learning to happen, and that itself is a dramatic improvement that one unlocks the machine learning capabilities to average people, because you don't have to go and do all this crazy programmatic stuff. Copy and paste is your entry point into a lot of these tasks. And then I put together the prompt, and the key in the prompt is, I tell it, I want you to classify. And now, rather than going and training a custom model or doing some crazy thing, I'm just telling it perform this task. It's already trained and knows how to do classification. And it's learning my labels right here that I'm providing and can actually go and apply them. Now we'll find ways that we can improve this and make it even better, especially when it doesn't know or understand these labels later, and then we get really good classification, like absolute top tier classification of these text based responses. Have you think of all the things, like comments on my product, reviews of my product articles, sentiment on stocks? I did a bunch of surveys of my users, or I held a workshop, and I want to see what people's feedback was, and I want to call want to classify it. That's a really, really powerful capability that now we can tap into simply by going in and saying, classify this, and then giving the labels and note what we don't have to do anymore. We don't have to do some complicated, crazy data, whatever process to produce all the labels, and then we don't have to go and train some custom model on this thing. It just intrinsically can go and do it at absolutely state of the art, pace and accuracy. So if you look at what Claude did here. This is phenomenal, and all you have to do is tap into this is some prompt engineering. [27285:20:00] 0: Now we're going to look at another common task that we've typically associated only with people that have been able to do machine learning or AI, and that's clustering. How do we take our data and try to group it together into groups that have similar properties to them? So for example, you can imagine items on a table, and we look at them and we say, well, what are natural groupings? So we might want to think about moving things as similar color to get and going and identifying the color as a common attribute. And then we can use it to, let's say group, three groups we might look and we may say the type of objects. So in some cases we have vegetables, in some cases we have fruits. And so we're going to group based on that, or cluster based on that. And so clustering is a fundamental activity, and can be really useful when you think about it as like segmenting the market, or segmenting our customers, trying to group them based on attributes, grouping the responses or the comments that people make about our product into common categories we're looking at. In this case, I'm going to continue this example of looking at the comments on my social media posts, I want to understand what are the commonalities? What are the common groups or types of people that are commenting on the post? And can then we go and even go further and build a hierarchy to understand the commonality between them and to help us look at so I'm going to give you a simple example of how I did this. I followed up in that original conversation, and I said, Please create a taxonomy of the job roles that people are people that responded, I'll put the taxonomy as an ASCII tree. So I'm asking Claude go and essentially cluster them together to see me go even further and turn it into a taxonomy, and see a hierarchical representation of the categories, and then where all the items fit in this hierarchy. And that's a really, really complex task, something that's very difficult to do, especially you're taking just really raw data, like we are here. And in this conversation, we're going to not only cluster it, but we're going to build it into an entire taxonomy. I'm also using the template pattern again to go and say, output the taxonomy as an ASCII tree. So I'm taking control over the output format. And so here's what I get. Basically, it goes through and it dissects that data and all of the job roles of the people that are posting and commenting on my post. And now I can look at that and see common clusters. For example, I see that there's a bunch of people that have job roles related to AI and data, and it's identified that commonality between these job roles, and it's basically pulled that up into a sort of common category. But then it's also saying but there's a bigger cluster that we can see technology and AI, and beneath technology and AI, we have folks that are in AI and data. We have folks that are in software and development, and then we have folks that are in IT management. And we get sort of the different job roles and groupings. But I can also see there's a big cluster here related to executive leadership. So there's CEOs, co founders, managing directors, and now I can say that that's an interesting demographic or set of job roles that I might want to pay attention to in my comment, in my content and my roadmap for creating courses. So by going through this, I'm doing really powerful machine learning on the comments for the post, and I didn't have to do anything complicated. Now you can think about this. Let's imagine survey responses. We simply don't categorize people before we go in and give a presentation. So maybe when they register, we ask them about their level of experience or something, and then they tell us about their level of experience. Now it's easy if we have them classify themselves, but what if we go in and we tell them, how are you using generative AI today? Tell us all about it, and they go and describe it. Now we want to group people based on their use cases and the ways they're using using it. That would be really hard to do before. Now we can simply go and say, well, take that field and all the survey responses, and here's how we want you to think about clustering. And it goes off and it clusters. It it might come back and say, Well, we have people who are using it in this way, people who are using it in this way, people who are using it in that way. We might want to go look at sales and we want to say, what's common about what we were doing from a marketing perspective. Can we identify clusters of commonality in terms of these sales or marketing or other things, insights that we can use to go and be more effective in our communication, our marketing, our teaching, whatever it is. Now, before this was pretty tricky to do, you had to really have a lot of experience to do it. And all we've done here is we've gone and said, basically, cluster these things together, and we've gone even further of giving even more hierarchy in terms of a taxonomy around it to explain what is common in this data. Identifying commonality in data is a really, really powerful thing. [28618:24:00] 0: Let's continue our journey hope, looking at this LinkedIn post and trying to analyze it with machine learning, without actually training any models or going and writing any code or doing any data cleansing, we're just prompt engineering. So we're going to really go a little bit further into this data and do something useful with it, and that's prediction. And prediction is the thing that people most commonly associate with AI is it's going to go and predict something for me, and it's actually really good at doing this. We're going to go and do some prediction with this data about who's commenting on the post, and what can that tell us about where we might want to go, or where I might want to go as a creator of classes and content, around what types of content, maybe we can predict that, and you can predict course titles. Maybe we can predict audiences. Let's go and sort of do some of that analysis and see what we can find out. You can imagine this can be really useful to you. All kinds of things you might want to predict. You might even want to go and take a personal list of restaurants and throw your reviews in, what we thought about those restaurants, and then when new ones come out, dump in information about the restaurant and predict if you'll like it or not, predict if your family members will like it, do all kinds of interesting things. Their prediction with machine learning or AI is super simple for anybody to do simply through prompts. So here's my attempt to get in Claude to go into use of prediction. So I'm following up again. I've got one more conversation going on analyzing this LinkedIn post in the comments. So I say based on these responses, categories, industry job titles, etc, industries and job roles not represented in the data might respond well to this content. Give me five detailed industry job, role and content categories. So I'm asking to predict, like, get what you see based on that, predict who else might care about this content? Who else might care about my classes that I should be thinking about when I'm designing new content? Also might be who is looking at my products and commenting on them. And then, based on that, who else might I want to go and think about selling my products to. But you can see that prediction such a powerful thing. So based on this, it says, okay, based on the responses and the diverse range of industries and job roles represented, I can predict several other industries and job roles that might respond well to this content, healthcare, technology and innovation. And in fact, you know, I have a close partnership with our School of Nursing there. So the biggest innovators on campus with generative AI. So this one makes a lot of sense. What gets interesting is when it starts focusing in on job roles, and suddenly we have medical device developers. That's interesting. I hadn't thought about that. Health Informatics specialists. I can 100% see that see that's a really important area, and in fact, I collaborate often with nursing informatics, and I've seen the value of informatics and use it as a tool to improve our ability to do informatics, machine learning, to try to understand their data, but also because we can use this as an interface to those systems to go and extract it more easily, reformat it more easily. It's a really powerful thing. But then it gets really interesting. Telemedicine coordinators thought about that. I didn't even know that was a job role is predicting that that's a job role that would be interested in this. And I can absolutely imagine that you have all kinds of things for the scheduling, communication, processing of forms that are coming in and data that seems like a really good role, potentially charting. And then it goes to suggest content focuses like applying prompt engineering to medical research. And in fact, that's a great area to think about, is, how do I take a large volume of medical papers or journal papers, and then use prompt. Engineering is a big filter to help me find out important insights or things that I need to know based on my specialty. So very quickly, I went from comments in a LinkedIn post to now predicting what are things I might want to think about in terms of new industries I might target, or job roles that I might target, and how might I go about targeting really high quality sort of predictions? I can't emphasize enough how hard this would have been to do just a year and a half ago, in fact, unless you were an absolute, tremendous AI expert with a team and a ton of data on this, there's no way to be able to generate a prediction of things like that, of that quality, and you can go in and do this with as simple as copying and pasting from a LinkedIn post. Then I went thought about, well, let's also go back and analyze the industries and the job titles that are present in data, and maybe what I can think about in terms of caring about my audience and thinking more about what might their needs be. And so I went and I said, Okay, based on the responses, give me the equivalent output, but based on who did respond. And it says, okay, here are five detailed job role content categories that showed strong engagement with course. It said industry marketing and business consultants, job roles, digital marketing strategies. Well, that makes a lot of sense. Business consultants, that also makes a ton of sense. You know, product managers get another one. That's a great idea, and then it gives content focus applying prompt engineering to enhance marketing strategies. Well, that's funny, because that's exactly what I'm kind of doing right here for myself, is applying prompt engineering, but using its AI capabilities to make predictions about who I should market to and how. So that's a great idea. And in fact, that's a really high quality prediction that it's doing there. It's also got other ones in here that I could go and look at and investigate. Then I thought about, well, I'm going to take one of the areas that it's talked about, and I'm going to dive a little deeper into it. And so what I did is I gave it all the list of my courses. So I added some new data into the conversation, which is the list of my courses. And I said, these are the titles of my current Coursera courses. Based on the responses, helped me predict five possible courses that I should consider creating based on what will likely engage this audience in what I'm already known for. And then I use the template pattern again to say a way to output it with a second level, kind of heading for the course title. And then the rationale for why I should create that course. Then it goes in and predicts, AI driven software architecture and design, and in fact, that's an area that I'm really interested in actually building a course, and that was something that was already on my roadmap. So that reinforces to me, that's probably a good idea, and I've learned that also. I've got some supporting data for that, based on who is accommodating on my LinkedIn post. So I've just fed back into my own pipeline. I've supported one of the ideas I have, prompt engineering for code generation and debugging. That's yet another area that I am interested in, developing content and I had in my pipeline. I've done some papers on this topic, and so that's data from these LinkedIn posts, comments reinforcing what's in my pipeline that's helping support AI ethics and governance for tech leaders. That's not something I thought, and that's probably a good idea. I should probably think through that. What is, what does a good course look like for that? And that's all coming from, you know, real machine learning being done on the data from this LinkedIn post. Now notice what I did. It wasn't this huge data cleansing process. It wasn't some, you know, super complicated technical thing where you had to learn how to train all these things, have all these ins and outs of the different objective functions and all this stuff that you might need to know to do this effectively. No, it's just go and prompt, and you can do this too, which is what's really fascinating. You think about all the ways that using it to analyze data to help you personally, there's so many areas just from just individual life, things like what restaurants might I should pay attention to, or what's happening in the news that might interest me. Or what did all these journals related to my discipline? Should I know about this new and exciting? Or, you know, people just did this survey related to some, you know, course I gave, or some workshop I was at, what did they tell me? What kind of learned from that feedback? So many things of immense value now they can be accessed really simply through prompt engineering. I [30844:26:40] 0: it. Let's look at another common task, and we think of being done with AI that's one that's drawn a lot of attention. Use it all the time in E commerce, probably when you go and try to buy things, and then other products get recommended to it based on the other things we've browsed or looked at or bought, or some other information about us, and this is such an important concept as the idea that we recommend something else based on something and so let's take a look at how we can use POP Dean to achieve recommendation. So I'm going to go back and I'm going to look at those comments in that post again. What I'm going to tell Claude to do is I'm gonna say, Look at who talked about my course in their job role. Now find other people that did not talk about those courses that might benefit due to their similar job role. Focus on the most clear cut examples. And it comes back and it says, responding digital marketing strategies. Strategist is similar to another role that might benefit, which is content marketing manager. So go look at the content marketing manager, manager that commented and they might be a good person to respond to with some of the courses that are similar to the digital marketing strategy. So if you know what the digital marketing strategist took, you should recommend those same things to the Content Marketing Manager, because they may be applicable or the principal consultant or the data engineer. The data engineer is similar to the business intelligence analyst. So why don't you recommend things from that role, that that role took, to the other role? So that's a really useful thing. Now I have a recommendation, and all I did was going on. Let's look at another example of how we might do that, look at who talked about my course in their job role. What course did they talk about? Now, create a recommendation mapping of courses to similar job roles. So this is a more specific one. So what I wanted to do is I wanted to go and look at in the comments when people talked about a specific course that I taught, what was their job role? Now, what other job roles of people that commented, could we recommend that course to? And so it goes through and it breaks it down and it says, Okay, well, your course prompt engineering for chatgpt recommended for let's recommend it to content marketing managers, brands for energies specialists. That seems like a great idea. And the reason it says is because originally there was a digital marketing strategist that was the one that said that they liked that course. So that would probably be a good course to also recommend to these other people for your open ai gpts course. The original person that commented on that was a principal consultant and learning so we can also recommend that to a corporate training specialist or instructional designer or e learning developer, because those are similar roles. So it's helping us actually go and recommend what other roles might be interested in that course. But you can imagine, if you're doing products, it would be, what other products might that person be interested in, or what other training might they be interested in, or what other you name it, you fill in what you want to recommend. But you can do this really simply by giving the information and starting to prompt for recommendations. So this is a really powerful concept, trying to know what to recommend to someone else can be done really easily with prompting, especially when they have really interesting data, like we do here, and particularly when we have interesting data, like these comments for this pose, that may not be something that we could actually work with very easily with traditional mid machine learning, but we can work with it really easily here and get great recommendations out. [31881:41:20] 0: Now, so far, we've really just tapped into model existing training. We haven't really taught it anything new. We've given it new information, and we've had it do different AI related tasks on that information, but it hasn't really been trained with anything new now we've given it new instructions, but we haven't given it new training data per se, and we can essentially do that within context learning. Now we used in context learning, and we've done it to do things like improve our writing and make it sound more like us, because it can learn from the patterns in written material that we give it, but it can also learn from patterns in data and examples that we give it of task performing. And so let's look at how this plays out in using it in a machine learning context. So anytime we have data, and I'll particularly want you to think about data that looks like a table. You have data that's in Excel or CSV or some other table format. This is prime data, prime information to go and use for any context learning, because you have all these key ingredients that you need to go and teach it. And so we're going to take an example, and we're going to start with a separate example, but it's a it's a simple example, but it's a tricky example, because there's no obvious sort of, like, what is it that I'm supposed to do? Like, if you took existing machine learning things, it'd be sort of tricky to get them to do this task particularly well. So here's the task, because we have this list of all of these catalog items. But what we want to do is we want to take these flowery descriptions, like duck shaped ladle, and we want to boil it down to just ladle, which, if you look at the column over there, that's just a simple description, and we have, like, Japanese tea set with cherry blossom motif. We want to boil that down to tea set. Now the last row, we don't have it boiled down here, it says metallic sculpture of a dancing couple, and we want it to go and learn what to do and fill that in for us. So what we're going to do is we're going to try to figure out, how do we teach it, and how do we craft a prompt that essentially trains it to perform this task, because that's what our prompt is going to be doing. Our prompt is essentially going to be training the model through in context, learning to be able to accomplish this task, which is this stripping down of the data and filling in that column, that missing column. When you think about that like, let's say I had, you know, a table of data, and there was a column that I wanted to fill in or predict. How would I go about doing that? And this is what you're going to do. Now, typically, the way we want to do this is we want to take that data and we want to reshape it a little bit. And the way we typically want to reshape it is we want to create a set of examples that show the correct input and then the correct output. There's many different formats you can use for this, but I'm going to start with a really simple one, which is, I'm going to show it the correct it the correct input, like what the row would be, and then the correct output, which was what that last column should be. So I start off with the first row in the data, and it's this, q1, 06582670, duct shaped ladle. And that is my example input, and I've given it the instructions that it should go and complete the pattern. Now this is what my input is formatted as, and that's essentially every row it's I'm going to go show it everything except the last column that's going to be the input, and then the output is going to be the last column that I'm trying to predict. So I want you to think about this in terms of imagining there's a last column you're trying to predict the value for, the value for, and it could be classification, it could be recommendation, it could be prediction, it could be whatever that task is. But I want you to get this mental model of its table where the thing you're looking for is that last missing column that we want to fill in. Now when we format it, what we do is we say the data that's in the columns that we know is going to be this input like this. We show an input colon in the NAT column, and it could be tabular, separated data, space separated data, comma separated data, however you want to do it. But what's generally important is that it's all in one row with no line breaks. So you need to try to get rid of the line breaks. If you can, then we show it the last column, but we say output, colon last column. And the idea behind this is we're teaching it. If you see this input, this is the output that we're expecting. So this is how we're reshaping that table into a prompt. Now, once we've done that, then what we're going to do is we're going to go and try to get it to fill in a missing label, right? In [33160:32:00] 0: this case, this large porcelain teapot. And so I've showed it all the columns that I have, and now I'm trying to get predict the missing column by saying output colon. We're basically telling it, hey, I need to know what the output is for this. Basically, I need to know what the missing column is. And then when I go and do that, what it says is T model, which is the correct answer. Now you notice I did tell it how to perform the task. I didn't say go and look at this and try to remove all the flowery language and boil it down to one object, but just showed it examples. Essentially, what we've done is we've trained the model in a prompt to perform this time, [33369:20:00] 0: the task force on [33385:52:00] 0: the new input and the correct column is now you can take any type of data. Can't always figure out what the answer is, because there may not be enough information, but you see the kind of the structure I want you to have in your head is, anytime I see a table, if there is a column that I want to be able to predict or fill in in some way, then I can think about how to reshape that table as a prompt where I take my prior information and I put it in in this format, and then I use this last column As something I'm going to predict, and I do output colon and I try to get it now you can have different prefixes. Prefix can matter. It cannot matter. It's a little bit of something you have to think about depending on what you're trying to get it to do. But input output tends to work pretty well. So now let's take a longer example and see how we might do this and start scaling it up on more data. So I built my prompt, and it doesn't fit on the one screen anymore, but I built my prompt and it basically has all of the examples of the task correctly performed. Here's the input, here's the correct output, and that's basically showing each row where I have the correct value for the column. And now what I want to do is fill in a whole bunch of rows I want to fill in the column for a whole bunch of rows that I don't have that column for. And so what I do is I is I've built my existing prompt, and now I can save that thing. I can use it over and over with that, essentially training data. And now what I'm going to do is, I'm going to say, create the output for each of the following inputs. Now it probably would have been better if I'd gone ahead and prefixed each of these with input, but I got a little lazy, and Claude is really smart, so it was able to figure it out. And what we get now is it goes through and it processes each and every row, and it performs the task that it has learned. So now it's essentially doing batch processing of that task on that input data that I gave it, and notice I never gave it instructions about how to do this. Just learned it. And this is the power of in context learning, as we can go into when you start thinking of all the tables you work with on a daily basis, and this simple idea that maybe I can translate that table into a prompt that then it can use to help me predict some missing column, or some column I'd like to automate. Going in, you can start to see where this gets really powerful. So I'm going to take some more complex data. So this is a data set that I got off Kaggle, which is, we can do a download of the data sets, and it's a whole bunch of online courses, and it has enrollment, it has rating, it has some other information about it, but it also has a category. What we're going to do is classification. We're going to have it learn to classify these different classes into their category. What is the category? Is that a technology class, a marketing, a finance, an Office tools class, and it's going to learn how to classify courses. So what I'm going to do is I'm going to take the very last course in this data set, and I'm going to remove one of the columns. I'm going to remove the Category column. The category for this data set, for this column, for this course, was technology. So I've taken this last row, and I'm going to strip out the category technology, and then I'm gonna see if quad can predict it. So I go and I create a prompt. Now, in this case, I am getting even lazier. Now this is not the best thing to do, but I'm getting really lazy. And I kind of want to show you that sometimes you can get lucky and just be really lazy, and you can directly take your tabular data and move it into a prompt and get some amazing results. And that's what I got here. So I took a whole segment of those courses. I took, I think all the ones you see here. So it looks like we've got about 33 courses that I gave it the correct answer for. And then there's some dots, because, again, my prompt doesn't fit, but I wanted to show you the last row, and then in the last row down here, what you see for course 33 is that I've actually gone and removed the category, so I've left that column blank, and the instructions I've given it are predict the missing category for the course. Now there's probably way better ways to format this prompt to make sure it works really well. But even if we just go and start copying and pasting tabular data in, like Excel type data, you can get some really powerful results sometimes. So I'm asking it to classify the Course Based solely in the course identifier, which is course 33 the fact that it's taught on LinkedIn learning the price of the course, the average, I guess it's the rating for the course and the number of people enrolled. That's it. No title of the course. Nothing else can it solely based on those data points predict what category the course is. And I'll tell you what I cannot. There's no way I can easily predict this, and I don't know if you can spot it and immediately tell Probably not, because that's pretty small that table that I showed you, but it goes through and it says to predict the missing category for course 33 I'll analyze the patterns in the given data and consider factors like course duration, enrollment, Completion, rate, platform, price and rating. Here's my thought process based on these factors, the most likely categories are number one, technology, which is the correct answer? Number two, programming and number three, data science. Among these, technology seems to be the best fit considering the duration, platform and rating. It's a broad category that could explain the moderate enrollment numbers while and it went on with its explanation. But what's amazing is it nailed the classification tasks. It is a technology course. And if we go back up and we look originally, yep, it's technology. It got it right. And if we look at the data that was working off, I mean, it's really generic stuff, and it absolutely killed it. Now we've got from that to this really rich. Now, what's also amazing about this is it's explaining its answer, which is really powerful, because now as a human being, I can follow up and I can say, does that make sense? Now what's interesting is, even with its answer, it would be and even all of this explanation is really hard for me to work backwards and say, does that actually make sense? Because I'm just flabbergasted that it can get this from that little data. Now, if I went and analyzed the courses and did a lot of statistical analysis, maybe it would make sense to me, but think of how much work that would take. And I just fed this in, and I got an excellent answer, an excellent classification of it. I essentially trained it in a prompt. Now, if I wanted to go back and I want to classify and try to categorize other courses, all I have to do is save this prompt and change the last row I'd fill in the row that at the end with a new row that is missing in the category, and then I'd ask it to predict it, and then I would go in and fill in another new row, or I'd fill in a series of courses and ask it to predict each of them. And so you can work with it. And suddenly we're going from just having it perform tasks that it already knows how to do, and suddenly we're getting it and we're actually training it on totally new data and getting it to predict things and classify things based on data that it was never trained on before. We're essentially training it with our prompt, through in context learning and examples, and that's wildly powerful. You it. [35424:10:40] 0: So when you're trying to build up a prompt to teach and train the large language model to do something new, how many examples do you need? Well, there's no solid answer to this. It really depends on the task and how complex it is and how information rich your examples are, and how hard it is to tell the difference, you know, and there's so many different aspects to it. If you're trying to predict stock market prices, there's probably not enough examples for you to do this. If you're trying to, you know, tell the difference between fruits and vegetables, it's probably not too hard. In fact, it already probably knows that. So you'd probably wouldn't need many or any at all. So where do we fall in this? What I would encourage you to do is use lots of examples. And when I say lots of examples, I mean think big, like, if you have the data, why not use it? And I'll tell you why you might not want to use it in a second. So here's an example where I was going to do the prediction, and I copied and pasted the 1000 rows of actual online courses in that data for this task of predicting the course category. Now I didn't have any trouble doing that. 1000 rows actually fits in quite nicely. Now if I went to 6000 rows, it may not fit. And I was working with anthropic Claude, which was has one of the largest context windows, which is how much information you can get it, give it to it at one time. And part of the reason the context window can matter here is because it's the bigger the context window, the more information we can give it. So if we're working on a really hard problem where we need a lot of information to teach it how to do the the the problem well, and how to solve it well. Well, we're going to want a big context window. Now, the downside of that is, the more context window we use, we get charged for using that context window in many cases. So if you're paying, you know, for a monthly subscription, you may be able to get away with this, but you may also hit limits. If you're paying for tokens, then this could be expensive. So if you create a really big prompt, that's really great, it may end up being really expensive for you to run that task. So you have this trade off between how much information you want to give it at one time, the accuracy you'll get out. So the more examples you give it, you're probably going to get better accuracy, but at the same time, you're going to probably pay more for more examples in that prompt. So you may not want to put too many in there. There is the possibility, if you put a ton of examples in there, if they aren't good examples, it can actually hurt it. And so you want to be careful, right? It's just like always. Even though it's easy to get started with this, it doesn't mean it's always easy to do in reality, for any given task, lots of tasks you can do really well, but some are going to be really hard. This categorization of classes is probably really hard to do. To do it well, so you're going to have to figure out what examples go in there, how many of them, and you're going to have to balance that across cost, speed and other things. So here are some rough heuristics. You probably, you know, want a bunch of examples. Now, what is a bunch? It could be 10 or 20. Can often be a really good number to make a prompt work really well. So when it's really just about getting the prompt to figure out what you want it to do without, like, having to put a ton of instructions in there. When we talked about this trade off between instructions and examples, if really what you're fighting with is you're trying to more concisely explain what you want through examples, then probably a small number of examples is going to be sufficient with a few instructions. If you are truly trying to do a task that's really hard to do, think this course labeling where we're going to try to figure out which course or which category this course falls into. And I, as a human being, cannot look at it and do this easily. You're going to need a lot of examples, probably to get this to work. If it's even possible, there may not be enough information to actually do this reliably. So the harder the task is for a human, you can probably think the more examples we're going to have to have. Now, if it's something where you can show somebody a small number of examples, and you've really fully contained all the information you need and all the basically all of the intrinsic rules that they're going to need to know, probably the LLM is going to be able to do it pretty well. So if you think about like when we were trying to get it to understand the two women who were having the conversation, and we wanted to figure out to write in all caps, we just needed to add a few more examples, and then it got it, and it started writing in all caps for one of the people that was in the conversation. So you have to think carefully about this. But in general, you can create giant prompts with 1000 examples, and that should not be off the table. That should be something you can think about doing the same time. You want to make sure there's quality to your data. So if you have 1000s of examples and they're all garbage, it's not going to work most of the time, you probably just need a few examples added to your prompt to get really good results out so the examples are like this secret tool that you can use to often get much better performance out of prompts, particularly when it's not about really doing some really sophisticated, complex task. It's just about getting your prompt to work and work more reliably. Now, what if you are doing a simple task and you want some examples to go into the prompt, and you don't know how to get them? Well, the simplest thing to do is to simply go and start trying to generate them, and that's what I'm giving you an example of here. As I went and I said, I need you to help me create a classification data set for fruits and vegetables. Super easy task. It probably doesn't need any examples to do this well, but maybe I want to have this format. And I'm saying the format should be input, insert fruit, vegetable name. And basically what I'm saying is, like, it should have said, insert fruit or vegetable name. It's it's helping me out here. And then I say output, colon, insert fruit, pipe, vegetable. And that's a way of saying either fruit or vegetable. I could also say insert either fruit or vegetable. And then when I put that prompted, it says, input, Apple, output, fruit, input, carrot, output, vegetable. And now I've got this data set. Now the second thing I would do after I generated this is I would go and look at each example as a human being, I would verify that they're correct. If any of them aren't correct, I would not use them, and I can generate over and over, and then I can copy and paste them up into my prompt when it starts doing the things I want. Now, if you see the parallel between this and preference driven refinement, it's because there's a total parallel, and I'm tapping into the same thing with preference driven refinement I'm having it generate. I'm looking at what it gets right. I'm taking what it gets right, I'm moving it into the prompt, and then I'm using that to modify the prompt so that it does more of that right thing. It learns from what it did right because I introduce it as an example, and that's the same thing we're doing here, is we're just generating examples that we're selecting from them, moving them back into the prompt. So that same way that we did preference driven refinement to refine our writing, we can do it for prompts in general, where we're going to add examples to them to help them work better. And what we do is we simply go and generate like we do here. We take the ones where it got it right, we copy and paste them, we move them up into the prompt, and then that'll help it do more of the right thing. Now this is all predicated on that you can get it to generate examples that are correct, and if you can get it to generate examples that are correct, and you have the expertise to evaluate them and determine that they're correct, then you can take this approach where you sort of manually generate, take what's right, move it up into the prompt, manually generate, again, take what's right. And probably in two or three iterations of this, you will have enough examples that you can dramatically improve the quality of your prompt. And there's actually tools that do this automatically for you. They'll either take a data set that you give them and they'll automatically improve your prompt by adding examples to it, or they will take a data set that you give them and they will automatically improve your prompt by adding examples from that data set. But data set, but also synthetic examples that Get created that also match up with This. I [38919:22:40] 2: What does this even mean? Like [38939:38:40] 2: a really? Dive deep into this and understand What I'm even doing right now. I [39872:37:20] 0: The template pattern is something that I created and talked about in my very first course. But over the last year, when I've really been doing a lot of prompt engineering and prompting the template pattern, I realized is something I really wish I'd taken more time to explain, because it's one of the most powerful things that I use on a daily basis. In fact, it's something that when I go into demos, I always try to use the template pattern, because it's something that usually looks like a Jedi mind trick to people like they see it and they go, Oh my gosh, what did he just do? And so I want to just really take some time to dive into this, a little bit more. And it's a very rich topic. There's so much you can do with this concept of the template pattern, or templating, however you want to think about it, but I really, really want to spend some time to just show you the power of this, all the different ways to use it, but also the intricacies of how to think about using it. Now I'm going to dive into an example to get you started. And one of the most basic things when we have to start thinking about the template is the concept of a placeholder. Now what is a placeholder? A placeholder is a point in our text where there is something that we want filled in. You can think about it like if you created a template for some intern to go and write a report, you would leave placeholders, and you would say, This is what I want you to fill in here. So go and put that in. And you would you would try to provide good placeholders wherever there was something that needed to be built in at the same time, the key thing that the plateful soldiers give you is they tell you what is in the template that should not be changed. Meaning, if it's not in a placeholder, I don't really want you to change it. So that's an important concept. The moment we start introducing placeholders, we also are introducing the idea that certain things that I'm giving you just aren't meant to be changed, and I don't have to tell you that for you to know that you can infer it, because of the fact that I've got placeholders. If you go look at a contract, a legal contract, and it has a placeholder for your name, your it's indicating you fill in your name, but you don't get to change anything else. And we can kind of do the same thing with the LLM, as we can tell it. Hey, here's placeholders, but don't touch other things. Now, can we guarantee that it won't touch anything else? No, but it really, really can be a helpful thing. So look at the look at this prompt. Vanderbilt University was founded in and I have a placeholder, insert year by insert founder. You can do placeholders all kinds of different ways I find less than what you want it to insert greater than is a really effective way to do this. And I also tend to put insert language into there to just completely disambiguate that this is a place where you're going to insert something. It's telling the LLM here are your instructions for what to do right here, insert this. So I find that this works really well across all the different llms, but just simple idea of less than insert something greater than well. Why does this work well? It works well because he's probably trained on a lot of programming language and probably trained on a lot of templates and other things that programmers do, and we use stuff like this to indicate where we want to fill something in. Now you can do brackets, braces, parentheses, all kinds of other stuff. I encourage you go and try the less than, greater than with the insert in there. It works really well. But at the end of the day, you experiment and find out what works well for you. But that's what I'm going to use and sort of standardize on throughout the rest of this. So this is my prompt. Vanderbilt University was founded in insert year by insert founder. Now notice I didn't tell it go and write and tell me. I didn't ask it a question. I just gave it text with placeholders, and it comes back. Vanderbilt University was founded in 1973 in fact, Cornelius Vanderbilt. Now notice I didn't have to give it instructions. It knew what to do. It knew that this is a template. I need to fill it in. And here are the placeholders, and that becomes now a powerful capability that we can use to go and start directing the output of the large language model to go the direction that we want. Now let's start looking at how we can use place alerts even more richly. Now, if you can imagine you're going to filling out a legal contract, it might say, Insert physical address, or insert owner's name or insert child's name, or it might say, Insert birthday. Going to give you the format for it. And so one of the things that we can do in our placeholders, and we can provide ribs about what we want to insert it, but also the format that we wanted to insert it. So if you look at this prompt, what I've got is Vanderbilt University was founded in insert year in mm, dash, dd, dash yy format, meaning a two digit month. Dash, a two digit day of the month. Dash, four digit year. So something like, you know, January 1 would be 01, dash, 01, Dash. And if we're going to do 2021 it would be 2021, and so it's basically spelling out exactly how to format the date, rather than to leave it up to the large language model. And then I put after that format. So I'm just specifying, hey, it's not just the date. I want it in this format. And so sometimes you'll have to play around with what you put into those instructions. And then I say, by insert founder initials only. And notice now I'm telling it. I don't want the full name, I just want the initials. We go put this in. We get Vanderbilt. University was founded in 03, 1718, 73 by CV Cornelius Vanderbilt. And so we've taken control of the llms output, and we've actually taken control of it without explicitly telling it what to do through what we think of as instructions in the same way that if somebody hands you a piece of paper and it has fill in name here, you know what to do, they don't have to tell you. You're supposed to fill in your name. You're going to look at the piece of paper, you're going to read it, you're going to be like, I need to fill in my name here, and you'll fill it in. And the large language model knows that too, and we want to take advantage of it. Now let's do something more sophisticated. Let's start thinking about how to put longer chunks of content together using this capability. So now what I've got is what I had before Vanderbilt University was founded in insert year, and I've got the format by insert founder initials only, and now I'm adding its schools are. And I have a placeholder for insert list of schools as bullets. And so I'm telling it. Here's what I want you to do. I want you to put some content in here and go fill it in. And when I do that now, it comes back and it fills in the different schools at Vanderbilt. And that's a really powerful, useful thing that I can start building upon, is it's not just about giving it to give me something. It's about giving it to give me something in the format that I actually want. So I don't then have to go spend a bunch of time like copying and pasting out of its format into the format that I actually want to put it into. But now I can just get it into the right format on the first pass, which is an incredibly useful thing to do, like if you want to take really badly formatted information, like those comments that I took out of LinkedIn, and get them into a structured format, like comma separated values, or, let's say you have your resume in one format, and you need to move your resume into a new format.