================================================================= TITLE: Prompt engineering 2 DATE: 2024-10-11 (October 11, 2024 at 10:31 AM) DURATION: 02:50:41 (10241 seconds) WORDS: 27,343 words SPEECH ID: 26XPVAWW6NHOEZTJ ================================================================= --- AI SUMMARY --- markdown formatting, large language models, emphasis usage, unordered lists, ordered lists, image links, table creation, task lists, footnotes, retrieval augmented generation, embedding process, chunking issues, prompt engineering, in-context learning, preference-driven refinement --- FULL TRANSCRIPT --- [00:00] 0: It to really take control over the format that it's going to give us stuff and with the template pattern, we want to understand markdown. And what is markdown? Well, let's think about what you do in a word processing right? You will go in and you will write a document, and you will highlight certain sections, and you'll say, this is going to be a first level heading, and then you'll go highlight something else. You'll say, this is a second level heading. You'll highlight certain words and you'll make them bold, or you'll highlight certain things, and you'll say, this is a list of bullets. But the way we do that is normally by going and highlighting things and then clicking in the GUI. And we don't have a GUI here. There's no How do we specify this? How do we make that happen? Well, large language models know how to speak text, and so what we want to do is we want to work with the large language model so that they can spit out text that when you take that text and you put it into the right tool, it will have the formatting that we want. Now it turns out that most of these large language model tools, these chat interfaces like Claude or chatgpt, they already know a formatting language that's textual called markdown, and markdown then is what we can take advantage of in order to control exactly the formatting that we get out. So let's take a look at what Markdown is. Now, probably whatever large language model you're working with, you can go to the interface and you can do something like this, show me examples of the markdown that you know, and it will start telling you markdown. So the first thing we can do is we can create headers. So a header is simply has number of hashes followed by the text that we want in a header. So you can think of this as a section header and a document. This is one of the simplest the easiest things to is to start building in headers enter. Second thing we can do is something really obvious in something that we commonly do in documents, which is we highlight things and we put them in bold or italics, or bold and italics. But not a lot of people, how do you get the language model to do it? I'm using emphasis. Emphasis is the markdown term for bold and italics. And if you want to make something italics, you put it between two, essentially, stars. I don't know there's probably a better term for this, but I think of it as the star. And if you want it bold, you put it between two of these stars. And [684:05:20] 1: basically those are asterisks italicized. The word they're talking about is asterisks. And [704:53:20] 0: then if we need it bold and italics, and we just go and start adding in this formatting. And we'll see how this works in a little bit. When we actually go and build output that follows the markdown lists, we can have different types of lists that are either unordered, meaning it doesn't have numbers attached to it, it's just a bunch of bullets, or we can have ordered lists where we have numbers attached to them. And to do unordered lists, you just go and have dashes you want ordered lists, you go in and put numbers. Similarly, we can do links now, links may or may not work because these large English models are sensitive to try to render links that you could then go and click on and have bad things happen. So may or may not be able to get links to work, depending on the tool that you're working in, but this is roughly how they work. Is you specify inside of brackets what the link text is going to be, and then in a parentheses, like within parentheses right after you specify the URL that you would want it to go to. Now this won't always work. You can do images that might sometimes work. It just depends. It's all based on what they allow, and there's security reasons not to allow everything, like images and text links. So just know that that's something you may run into trouble with. Now, something that's underappreciated and underutilized that I've seen is tables. Tables can be really helpful, especially when we're representing data, all kinds of things like that. And most people deal with lists, and they don't really know how to control the output to get a table like they want. Tables are essentially these pipe operators. Now I think of it as pipe because I'm a programmer. There may be a different word, but you can think of these vertical lines. You can find it on your keyboard somewhere. Mine is on a Mac and so it's right above the return key. I hit shift in the net key above the Return key, and I get the sort of pipe. And then you specify the header. Now I'm not going to go into full detail behind this. You can go find something about markdown. You can even better yet, within your LLM ask it to teach you markdown, or fix your markdown. Or if you tell it, I want to table with these, these columns and the rows look like this. How would I do that? Markdown, and they can show you and help you get there. Horizontal rules, task lists like check boxes that you can check off and task all kinds of fun things, but I'm going to leave off on the most underutilized but amazing. Amazing one, because it's so helpful for a number of different tasks. And I'm going to show you this task and the use of footnotes, that footnotes are an amazing way of particularly when you are giving the large language model information of having it tell you what information that you gave it that it used to support its answer. And we'll come back to this one later. But this is one that's super underutilized, and when you show it to people, it looks like magic, but it also helps you. Whenever you encounter those people who are LLM haters, they're doubters. They say it hallucinates everything's garbage. You can never trust anything. The footnote is where you're going to go and absolutely blow their mind. It is a superpower to know that Markdown and to know how to use it effectively. [1600:00:00] 0: It. Now we're going to look at some sophisticated templates to put together. The idea of placeholders with taking control over the precise details of the formatting. And we're going to put these two things together. We're going to use Markdown and placeholders, and we're going to make some amazing things happen. And hopefully we'll open your mind to how you can go about really building more sophisticated outputs out of these large language models. So we're going to start off with a big prompt, and I'm going to show you this prompt to walk you through it step by step. The first thing I'm going to do for my prompt is I want it grounded in real information. So I'm going to provide it the facts. I don't want it to hallucinate. I don't want it to dream up the facts. I'm going to give it the information I want it to work with. Now you can imagine this could be all kinds of raw data. This might be raw information that you need to put into a quarterly report. This might be raw information that you have from your resume that you're trying to reformat, but you don't want it to hallucinate your qualifications. You want it to use your real qualifications. But basic idea is, in the prompt, we're going to go and give it the information to use. And this is going to be really critical later, and I'll show you how we're going to use it now. I say reference source material for footnotes. You'll see what I'm going to do with this in a second. I then have a separator to explain where the reference material starts, and I have a whole bunch of different facts, kind of fun facts, about Vanderbilt, and I have a bunch of them. My problem's pretty big. It's spanning two slides right now. So we see these two different slides, and we've got a bunch of facts about Vanderbilt. Now let's look at my template. And what I say is, we're going to create a report on exciting things about Vanderbilt. Create your report in this format. So when I start building up more complicated prompts, although I could probably just put in a template, once I start introducing information, I don't want it to be confused about, what is this information versus the template? How does it all fit together? And so what I'm saying is like, here's the information. Now I want you to create a report in this format, and this is what I'll commonly say, is create your output in this format colon, and then give it the template. And that's how I intended to use the template pattern now. Now it's a bit different how I used to use it. And if you took my first course on prompt engineering for chatgpt. It's not exactly how I presented it there, so this is how I use it now, and my sort of way of thinking about it has evolved. Now. What I said there still applies, but this, I think, is a more efficient, simpler way to use it. So I say in this format, and I have a first level heading, which is hash exciting Vanderbilt facts. So that is a headline that I'm telling it. It should show up in the report. It doesn't need to do anything. It just needs to put it in the report, Output it as is. Then I have a second level heading of fact one colon. So fact one should be there. Now we'll see that it gets smart about this. It's following patterns, and it'll know what to do. It'll know to increment the numbers on the facts. Now we could have said insert number or whatever, but sometimes numbers and things, it just knows what you meant. And then I say, Insert six to nine word, exciting summary. So I want to like, a second level heading that has some exciting fun fact about Vanderbilt, but I don't want it to be too long. So I want it to be six to nine words, and then I say described fact in detail. So this is where I'm telling it. Hey, go and really expand on that fact and explain it. And then behind it, I'm using markdown footnotes. And if you don't exactly see how this footnote works go and look at the markdown again for footnotes. You'll see it in a minute, and you'll understand it in a minute. But I would refer to that if you're getting confused in this video. Now I'm creating a markdown footnote, but I'm saying Insert Footnote to original fact. So I'm telling it I want. You to create a footnote based on the original fact that you're relying on to write this part of the report. And then I have some dots or ellipses. And what this means is ellipses are a really powerful way of telling the large language model go and fill in more of these. I don't want just one fact. I want a bunch of them. So if you have, like, one part of the pattern, and then you want it to fill in more, you can do dots do more sophisticated things too, but dots works well. And then at the bottom, I have a first level header, again, that's footnotes, because I think this is a really important thing, and it's something that I want you to start using and showing to people that say, Hey, hallucinate. You can't use it in a powerful way. It can never give you citations. It's impossible for it to give you citations. And you can say, yeah, yeah, let's, let's check that out. And then I say, Insert footnotes as quotes from source material. What is going to happen? I want to just take a look at this. Take a moment for you to stare at this, because this is just amazing, and it's so powerful and so helpful when we're thinking about large language models, taking controlled output, beginning to trust the output, exciting. Vanderbilt facts, so it's preserved our header. Fact one, a historic generosity sparked its founding. Vanderbilt University was founded in 1873 thanks to the generous $1 million donation Cornelius Vanderbilt, blah, blah, blah. And then notice what is at the end of that. Now, it may be hard to see in this video, but there is a little one there. It is a footnote, and we'll see what happens with those in a minute. We have a bunch more of Vanderbilt back footnote or facts. And note that each one of them now has a footnote attached to it that's going to be important. And then we go all the way through to fact number 10, illustrious alumni network. And since we're on the last fact, I'm just going to pull out the very last fact here in a second, and that's we've got footnotes as well. So we got to the last fact. We've now got our footnotes and notice we've got 10 footnotes as well. We've got 10 facts. [3233:36:00] 0: We've got 10 footnotes. Notice our footnotes are numbered. [3255:44:00] 0: Now let's look at that number 10, that last fact, [3274:56:00] 0: and NFL quarterback J Cutler. So it says the university boasts numerous distinguished alumnae. And the last part of that sentence is and NFL quarterback Jay Cutler 10. Footnote what is footnote number 10. Number 10 is the university boasts numerous distinguished nominee including Nobel Prize winners, blah, blah, blah, and NFL quarterback Jay Cutler. So it literally, verbatim, essentially repeated the fact, which is fine, because that was the source information I gave it, gave it and it linked, what did it output back to my original fact. So this is particularly important if you go and you number your original inputs, like your original source facts that you gave it. But the kind of key thing behind this is it's creating self consistency, because now I can go and reference. Was that a fact in the original facts that I gave it if I had already numbered them? And that's a failing in my prompting. I should have gone in the original prompt when I listed all the fun facts, and I should have numbered them. That's the thing I should have done, but I didn't. But if I had it, would make it even easier. But now I can go and I can say, OK, say in this statement, it's basically on this button note, it has the quotation from the original source material. I can check if that quotation exists in the original source material, and if I numbered it, my check would probably be even faster. Now I have to go and scan through and make sure that that is a quotation from the original source material. But what I just created was self consistency. I gave it information that I knew was true. I had to output it in a particular format. I had to create footnotes using markdown that refer back to the original prompt. And I've created self consistency, and this is a powerful way to build trust in the output you're saying, well, it summarized a bunch of information. How I know it's true? Well, you give it the information, you then ask it to put footnotes to page numbers or things like that in the bottom, and then you go and you check what it says. So if it says something there and it's a footnote, check its footnote, see if it's right. You can do this other ways. You can just have it list the page number, but it's kind of visually nice when you do it as footnotes a bunch of facts, it helps prevent intermingling of a bunch of stuff within it, and it becomes a really powerful, simple way to provide consistency checking between the output that it created and the original input that you put into it. And this is something that's so valuable. So whenever somebody comes to you and they say, well, it can never work, since sources can never do you can never trust that it's facts or right. And you can say, Yes, I can. And you can create a prompt where you give it the facts, ideally you number them, which I did not. I should have known better. But you give it the facts if you want to create a report. Or some other output in a template that you control with Markdown, with footnotes that refer back to the facts that you specified in the prompt. And now you get the output. And you say, Okay, let's look if it's facts are right, and you have footnotes. You go to the footnote, you say, is this, here's the information that it relied on. Is that information, information that we gave it originally? It is done, we now have fact checked it, and we've made the output fact checkable. We haven't made it to where we don't have to do due diligence. We still do due diligence as human beings. We are still going to check it and make sure it's accurate and right, because we're going to be responsible for it, but we now have a mechanism to do that that helps us make sure that we're getting reliable, accurate, correct outputs that we can go back and we can point to people and tell them, here's how I fact check it, which starts with number one, self mastery. Now [4268:42:40] 0: let's go and look at some more interesting things that we can do with Markdown that people don't use enough in their prompts for my opinion. So one of them we can do is we can start building with tables, and we present so much information in large language model output, why not put it in a table? Or why not always ask for it in a table, or know how to format that table? So let's go and look at a simple example of this. So I'm going to take that original prompt building this report about Vanderbilt, and I'm now going to have it insert a table of fun facts in that start of that that report. And so what I've done is I've gone and I've modified this prompt, and can look, you'll see a placeholder now that says, Insert Table of two numeric facts. So I want to talk about two aspects of what I'm doing here. So one, I'm telling it what I want. So you could go and you can tell it markdown, but you can also go and do something like this, where you tell it what you want, like insert a table and it will figure out the markdown for you. Similarly, in the past, I had a insert bullets of all the schools at Vanderbilt. I didn't have to show it the exact markdown. So you can also go and do it like this, sort of semantically explain what you want, as long as you don't need fine grain control. Now I probably could have gone and said, Insert Table of key facts with these headers or columns or whatever it is that I want, and I could have done it that way as well. So you can, kind of, you can go back and forth between explicit markdown as well as placeholders that describe semantically, like, in terms of meaning what you want, like, insert a table with these columns and then let it figure out the markdown for you. Now, the other thing I'm doing is, I'm saying, Insert Table of key numeric facts. And so basically, I'm telling it types of facts that I want. I'm essentially giving it a filter of which of the many facts that are there do I want you to put into this table. So I only want a certain type of fact to be present. And so we can use placeholders to control the formatting. We can control that formatting, either explicitly by spelling out the markdown. We can do it sort of through semantic, high level explanations of like table with these columns. And then we can also use it to control what data or information goes into that placeholder, essentially a filter for what should be put in there, in this case, numeric facts. So you can do so much with placeholders. They're really powerful. You go through and we run this now we get this table of key facts. No, it didn't perfectly do what I want, because not all these facts are numeric. Like Cornelius Vanderbilt is not a numeric fact. So it goes to show it won't necessarily perfectly do everything every time like you want, be aware of that. It just reemphasizes the fact that you need to fact check what comes out of this thing, and that you need to make sure that it's what you want, and so you read through it, take ownership of it. So I would look at this and say, That's not a numeric fact. I'd go fix it, but it's done a good job overall. Now let's say I want to take more control over this. I don't want to just have it produce a table, but I want to explicitly spell out the formatting for the table. So what I've done here is I've replaced where I said insert table, and now what I'm doing is I'm actually building out the markdown for that table. So my markdown, I've created a header in the table called Fun fact, exclamation point, and then I have a column for Wow number exclamation point, and then I have a column for tweet, and it's going to figure out, based on the meaning of the table what to fill in to tweet, which is kind of fun so. And then as a first row that I'm giving it, I say, Insert three word title. So I want roughly three word titles, insert number and then insert short tweet. And so basically it's going to fill out this table with that format. So I should get a three column table out. The last column should be tweet. It should have a number in the second column, and it should have a fun fact in the beginning. It's you. A three world title. Okay, how did we do we did okay. We didn't get exactly if you went back and we looked, I said three word title, I think it took that as an upper bound. So we did two word titles for these. And then it did mostly numeric facts. SEC is not a numeric fact, but it did okay. And then it generated tweets to go into the columns. So like, let's imagine you were brainstorming. You're thinking, oh, I need some social media posts. Here's a bunch of facts. Give me a bunch of social media posts, and you want them in this table to look at all at once as tweets, and what fact they're based on, or whatever it is, you could have formatted all out for you. So tables can be a really powerful way to get it to sort of fill in, and not only go and format it away you want, but kind of do some work for you along the way. Because if you think about it, it's basically creating a bunch of tweets, but it's also showing you the input data that it's based on. So it's just kind of doing more work than you think of. It's necessarily doing a one prompt like you might be used to going and saying, okay, create a tweet based on this, or create 10 tweets, but then you don't have necessarily have the correspondence, and it's formatted all kind of weird ways. Second thing I'm going to show you is kind of a fun one, particularly if maybe you're in project management, or maybe you're trying to plan for your trip, or you're trying to remember what to pack, or you're trying to create a recipe or anything like that. Having a checklist can be helpful. And so what we're going to do is we're going to use markdown to create a checklist. Now, in this case, we're going to give it a fun to do list of things to do at Vanderbilt when you visit, because we all know that you want to visit now because you've seen you do so many darn prompts related to Vanderbilt. So the rough format of this is going to be dashed. And then we have the finished bracelet, which includes basically a brace a space, and another brace, which is like a placeholder for a checkbox. And then I say, Insert activity on campus related to fun fact. And then I have the footnote, so again, I'm referencing back to my original facts that I gave it so I can fact check it. And then I say, dot, dot, dot, insert up to four more. And so the purpose of this is to put bounds on how many we get. Ellipses are really powerful. We can also go and sort of add notes to our ellipses so it knows. Yeah, I want more, but I maybe not want too many more, or I want at least this many those types of things, we can go and put in ellipses. And now we get our table, and then beneath it, now we get our checklist things we could go and do at Vanderbilt that are fun activities while we're there. And then we also have, of course, the footnotes that we can go and look at and see that those activities really do exist and are things that we could actually potentially do, and we can fact check again the information that we gave it, but now we also have something that's checkable. We could print this off. We could go and interactively do it. Check them off within chat, GBT, or within Claude, or whatever it is that we want to [6146:02:40] 0: do. I want to show you a concept that's really, really helpful in many different ways within large language models and prompts, but it's really particularly helpful in templates to solve a particular problem that we just saw, and that is what happens when we ask it to fit things into a template where it's trying to put something into a hole that it doesn't fit in. So you can think of you've given it a whole bunch of pegs, most of them around, but one of those pegs is square, but you gave it a template with a round hole. What does it do? How does it? How does it solve that problem? And you basically need to explicitly tell it what to do. In that case, you need to give it an escape valve. If it's if it's trying to do something that just doesn't fit and doesn't work, you want to give it an out. You want to give it an option of what to do. Now this is also really important. With instructions, you can tell it to do something, and if you tell it to do something, it's really going to try to follow your instructions and do that thing you're asking it to do, but you want to tell it what to do when it can't be done for some reason, that is when you when you have inadvertently asked it for the square peg in a round hole, what should it do? That's what you want to do, and that's what the escape valve is. So I'm going to go back to this prompt that I was working on with Vanderbilt and facts about Vanderbilt. So I've got all this reference material, and now down at the bottom, I've created a prompt, and I want to focus you down on here, where I've said, for each fact, extract the numeric value into the format. And I have a second level half header of fact, and then I have insert fact. And then below it, I say, Insert value or in slash, a meaning not applicable. Now. Why am I doing this? Well, if I just said insert value or insert numeric value, something like that, I have created a round hole, and some of my facts are square because they are not numeric. And so. What will happen? Well, it might just try to jam that numeric fact in or, sorry, it may try to jam that, that fact that is not numeric, into that, into that placeholder for the template, just because it wants to do and follow the instructions and do the best it can. And I under specify what to do when you can get that thing into the part in the in the in the template. So what we want to do is we want to tell it, you either put it in there, or you say it's not applicable, or in a now, I can come up with a better way of expressing this in the template, but I kind of want to show you just a very just direct example of this. So what happens when I do this? Now, well before it was going and it was creating my table, and it was putting things that were non numeric into a column that was really meant to be numeric because it was trying to fit all the facts in. Now another escape valve I could have told it to the table is you don't have to fit all the facts in. Only put in facts that are non that are numeric. You can ignore other things. So you want to give it escape valve about how to handle the situation when you've told it to put a square peg into a round hole. In this case, the fact location of Vanderbilt University, which is Nashville, Tennessee, it now puts in n slash a meaning not applicable because it's not a numeric fact. So by creating that escape valve, I've created a way that it can get an out when my instructions really won't work, and it's basically trying to follow my instructions to the letter. It's inferring that I want all the facts infer introduced. Now, why is it doing that? Well, it doesn't have anything that tells it not to put all the facts in. It doesn't know if it should just leave facts out, or does it need to include everything? And I think it's kind of nice. In this case, it's trying to include all the facts. That's a good thing. But the problem is it's trying to include all the facts, and not all the facts fit the template that I've given it. So by giving it an escape valve, we've given it a way out. This is true for instructions. Anytime you tell it to do something, you should tell it what to do if it can't make it work, if it can't use the facts, if it can't find something that works, you can give it an escape valve, and they can be very high level instructions, like, hey, if there's a problem with this, rather than attempting the task, just tell me what the problems are, things like that. So give it an escape valve to help take control and Make sure you get the output that you want. [7358:29:20] 1: You work. I [7461:30:40] 0: want you to think of generative AI, kind of like a new CPU. What do we do with CPUs that are in our laptops and other things? We give them information, and we give them instructions, and then we ask them to go and perform task force. Now if you think about all the components of the prompt that we talked about, information is one that we haven't spent a lot of time on so far. We talked a lot about the other components of a prompt, but information is critical, and when we start thinking about generative AI as something that we go and use to process information, then we have to think about the quality and how do we get the information into the system? And this is where retrieval, augmented generation comes in. And this is a fancy word for really, how do we get the right information into the system so that it can go and process it and help us solve problems or perform tasks? So what is retrieval augmented generation? Let's start by looking at the fundamental problem that we have to deal with when we don't give the system the information that we need. So a lot of people go and they use generative AI and large language models in particular, like their internet search as if they already have all the information you could ever need, and therefore we don't need to give them information. And this is incorrect. So let's start off by showing this. So BMX and kids, BMX racing it's a fairly niche sport, and it's something I don't think that GPT four has information on. I don't think it knows who won certain contests last year. Now it may be able to go figure it out, but I'm going to give you an example of what we're trying to solve for. So my son races BMX biking. BMX bikes. He was the Tennessee nine intermediate state champion last year. So I'm going to go in and I'm going to ask GPT four. I'm going to say who was the 2023 Tennessee nine intermediate BMX state champion. And it comes back and it says, The 2023 Tennessee nine intermediate BMX state champion was Hutch Griffith. Well, that's an. Not true. That's hallucination. And I know because my son was the one who actually won it. So my son's name is not Hutch Griffith. But I also know because I know most of the kids that are racing in the sport, because it's a fairly small sport, and so I know that I don't think there's a hutch Griffith in Tennessee. Now maybe there is, but I don't think he's not intermediate, because I would remember my son raising him. So this is hallucination at work. This is when we don't give it the information and it tries to guess on the quiz. It tries to guess the answer for us. And this is why it's critically important that we think about using jeremia Like a CPU, where we give it information and we give it instructions. So what happens when we give it the information? This is what we want to be doing. This is a prompt that is doing the right thing, which is we are giving it information and instructions together. We are giving it the information that it needs to perform the task. Now we copy and paste all the from the website of USA BMX, where they track all this stuff, we copy and paste the information about who won and how many points they had. We copy it into the prompt. We say, here's the information. And now we say, Who is the 2023, nine intermediate BMX state champion? And now it gets the answer right? James White, so you see how when we go and we use it like internet search, where we don't give it information. What we're basically hoping for is random generation of the right answer. Now this can be a really good thing, and if we're trying to brainstorm all kinds of things, it can work out for common facts that you know are really well known, but lots of things it doesn't work for. So we counteract that by giving it the information like we're doing right here, and then giving it the instructions to perform with that information. Now I want to bring us back to retrieval, augmented generation. And what is retrieval augmented generation? Well, let's look at a interaction with GPT four and see some retrieval, augmented generation at work. So I'm going to go in and I'm going to say when is the next practice at Music City BMX? And what you'll see is it says the next practice at Music City BMX are scheduled for June 20 and June 25 which, at the time that I ran this was correct from 60 8pm that is correct. Now, notice up above it, it says searched for sites. That's really important, because this is the retrieval piece taking place, and if we click on that, it expands. Now it may have changed. The UA may have changed by the time you're watching this, but you'll understand the fundamental concept. So if we click on that, it says, next, practice, scheduled, music, city, BMX, Nashville, Tennessee, June 2024 bing.com this is it retrieving search results from bing.com and if we go and we run that search on bing.com what we see is it pulls back a bunch of websites, and the text of those websites, if we go and look at the first one, has the practice schedule for Music City, BMX. So what's happened is it's gone and retrieved by running a search the relevant information for music, city, BMX, next practice. And then what it's done is it has essentially augmented the prompt with that information and then generated the answer. So just to walk you through that again, it ran a search, which was retrieval. It augmented the prompt with the information, which was what you see. Here you see, this is not my original prompt, right now, I'm simulating the augmentation because I can't see the augmentation because it's behind the scenes, but this is what it looks like, something like this, where it's gone and taken the first set of websites and the contents of those websites, and put some of that text into the prompt. And that's the augmentation part, where it's giving it the information it needs. And then the generation part is this thing that we see below where it says, The next practice through Music City BMX is scheduled from June 20 to 24th so retrieval augmented generation is how do we overcome this problem that doesn't have access to all the information it needs, and it might guess and hallucinate? Well, what we do is we go and retrieve relevant information. We then augment or stick it into the prompt, and then we actually give the prompt to the large language model in order to generate the output. And this is rag. When you hear about rag, this is what has happened. Now we're going to talk about how we do this. Yes. How do we for one let the large language model, or how do we know when it needs to go and retrieve additional information and augment? How do we do the augmentation? Does it matter? Does it not matter? Is there format that we need to do this in? And so we're going to go and look at the common approaches to retrieval and augmentation in the degeneration part is roughly the easiest of the pieces, because it's just inserting the prompt, which we already know how to do, and getting output from it. [9526:02:40] 0: Now that we have a rough idea of how retrieval, augmented generation works, let's focus in on the retrieval piece for a minute, because this is an important one, and we hear a lot about it. So if you've ever heard of the word embedding, well, you've probably heard it in the context of retrieval, augmented generation, and it's helpful to have a sense of how this works. Now, when you are a normal user, you probably don't care about embeddings themselves, but having a fundamental understanding of what's happening behind the scenes is really, really important to you, because it can be helpful in thinking about how you structure your prompts, how you structure your information, but more importantly, for knowing what can go wrong and how complex this topic is. So I want to take you through what embeddings are and how they're used in retrieval. All right, so let's get started. So let's take an example, and let's try to understand what does that mean to have an embedding. So what I did is I went into chatgpt, and I just thought I'd get its help going in talking about this topic, because I think it's kind of fun to get it to explain the concepts behind itself. So I said, Show me an example of what the embedding might look like for who is the Tennessee nine intermediate BMX state champion. So we're going to turn this into embeddings. So what does that mean? And I say explain things to a professional that doesn't necessarily have an AI background or math background. So basically, I'm using the audience persona to make this more interesting and more approachable. So what is an embedding? So let's look at chatgpt is definition, or GPT four OHS definition an embedded is a way to convert text into numerical vectors, basically a sequence of numbers. So we're going to take text on one side and we're going to get a sequence of numbers on the other side, and the sequence of numbers are going to represent the text in a format that a machine model can understand. So the idea is, these models take in text, they have to convert it into numbers that they understand. And that process, that embedding process, is that conversion process from the text sequences of numbers capture the semantic means, allowing similar text to similar embeddings. Now this is a really, really critical part for retrieval. So I want to walk through this and talk about this. The idea is we're going to take the text, we're going to convert it into vectors, which are sequences of numbers, basically a series of numbers. And we want to have the property that if we convert two chunks of text into numbers, that the numbers that it converts them into are similar, if the text is similar, if the ideas in the text are similar. So we want to go further. We want the semantics meaning the mean in the in the message in the text. We want if we have two similar concepts or ideas, we want the meaning to translate to numbers that are closer together. Now, a really simple way of thinking about this is, if we are talking about BMX nine intermediate state champions and 10 intermediate state champions, those might be really close together. So we want the numbers one and two. But if we then start talking about the governor of Tennessee, well, the governor of Tennessee is pretty far away from that. So maybe that's like 100,000 is the number. So 100,000 is pretty far away from one, but nine intermediate state champion and 10 intermediate state champion or not are one and two. So they're really close together, you see. So the idea is to convert it into numbers that have the property that they're close together. Really, really important, really complex topic of how to do this. And we're not going to go into how this actually works. We're going to talk about how it gets used, and then how this impacts you from a prompt engineering perspective. All right, what's the first step? Well, the first step is you're going to do what's called tokenization, meaning you're probably giving it a full prompt, a sentence like, who is the nine intermediate or Tennessee nine intermediate BMX state champion, and it breaks that down into tokens. Whenever you hear about models and being charged in tokens, this is what you're being charged for. Is basically, when you break it down into its constituent pieces, they're going to count the number of constituent pieces, and that's what you're going to be charged for. And. When it produces its message as output, those are also tokens, and they're going to charge you for those individual tokens. So a sentence like, who is the Tennessee nine, or me, a BMX state champion, would be broken down, and this is giving us a hypothetical of how it's broken down into tokens. So we would have all these individual words potentially. Now it turns out there's a tool. And most of these, these big models, have tools associated with them where you can go and sort of understand what is the tokenization. So in this example, I go into open AI's tool, and I say, Who is the tennis intermediate BMX state champion? And it says, Well, that's an 11 token out, basically input, and it shows me what the token identities are, these numbers. And then I can also go and look at it from the perspective of like, how does it break my sentence down? It's kind of interesting. This can be useful. When you get really advanced in prompt engineering. It can be helpful to know the tokenization of it, because often it can be helpful to know is that going to cost me more tokens or less? Because when you start thinking about prompt engineering for cost, you want to find things that work, that require less tokens, because that means tokens translate into cost. But what we can see here is some interesting things. So who is a token? Space is as a token. Not just is, but space is, is one token. But then, if you look at nine, we get Tennessee, and then we get space as a token, and then nine is a token, and then space intermediate is a token. And so the tokens aren't always what you would expect. And so sometimes it can be helpful to go and look and try to understand, but what we see is it's breaking the sentence apart into its constituent pieces that it's decided are the important parts, and then it's going to turn that into the embedding. So here's the hypothetical again, chatgpt or GPT four, oh, is basically giving us an example. I don't think that, as of my knowledge, it cannot convert something into embeddings for you in its embedding format. But it's kind of giving us an example. Maybe it can. I don't think it can, though. I don't think you can prompt it to do this. I don't think they've added that capability. And so what you would get is each of these words would be turned into an embedding, or a sequence of numbers a vector. Now we're getting short ones. The real ones are going to be big, like, in this example, is probably like 768 dimensions, meaning that's the number of numbers that are going to be in that vector. So, big, big, big sets of things. Now, again, what's what the model and what these embeddings are trying to do is get words and meanings that are similar to get either to each other closer together, and it becomes a complex topic of what this means, but that's the important concept. Is we want to make sure that who is the Tennessee nine intermediate state BMX champion and who is the Tennessee State BMX champion are probably close to each other semantically in meaning. So we want them close together in these numbers or embeddings that we're creating. Similarly, [11506:24:00] 0: who is the Tennessee nine intermediate state DMX champion and who is the governor of Tennessee? They're not really close together. So we want those things to be much farther away. So if you're looking for one and we want the numbers representing the governor of Tennessee to be farther away than who is the Tennessee State BMX champion, even though they're both talking about Tennessee. So they might be closer together than something else that's not talking about Tennessee, you know. So we want to be able to go and find things that are similar in meaning. Now that's the key. It's similar in meaning. And that's a tricky thing to do, but this is sort of intuitively what's happening. Is it trying to represent these things as numbers, where things as similar semantics or similar meaning are closer together. So we're now going to talk about retrieval with embedded what does this mean? Well, retrieval with embeddings is the idea that and I went ahead and drawn a picture with chatgpt, please refer to the picture and now you can understand rag. Are you done? I thought that picture was very straightforward and very helpful, and honestly, a lot of the descriptions of rag that I read in retrieval look like this in terms of complexity, but in reality, it's not that complex to understand well enough at a high level to be able to be effective in thinking and reasoning about it. Now, there's all kinds of details and complexity that look like this level of complexity, but we don't need to go into it in that level of detail. So let's simplify it a little bit. Now let's imagine we have a document, and we want to build a chat bot on top of that document, and when the chat when we go and ask questions, we want the chat bot to be able to find the information in that document that answers our question, if it's there. So what we would do is we'd go up. Upload the document to one of these systems, and then what we're going to do is something called chunky, which I'm going to talk about in a minute. We're going to take each of those chunks, and you can think of a chunk as like a paragraph, a text or a sentence, take each of those chunks, and we're going to convert it into an embedding so this is like the numerical representation of that text. And then we're going to store all those chunks and we're going to associate them with their embeddings. Now, why are we doing this? Well, just like Google goes and crawls a bunch of web pages and then stores those web pages so they can later search them, well, that's what we're doing. Basically, we're taking the document and we're breaking it apart into chunks of text. We're storing all those pieces of text separately, but we're really importantly is restoring and embedding for each of those chunks of text, so that later we can go and find chunks of text that are relevant to what we want to do. Now what we're going to want to do is we're going to want to augment our prompts. So we're going to want to retrieve relevant chunks of text that we've uploaded from that document and then augment our prompt with it. So what we're doing is we're uploading the document, we're breaking it apart into a bunch of chunks of text, either a paragraph or sentence or whatever, and this is configurable, and then we're going to turn those into embeddings, and we're going to store it all so that we can search it. That's the rough idea of what we're going to do. Now, what happens then, when we go in and we've done this and now we insert a prompt. It would send a prompt up to the system. Well behind the scenes, what we're going to do is we're going to take the prompt that the user submits and we're going to create an embedding for that prompt. So this is the key part. Remember I told you that we wanted things that had similar meaning to be close together. So we want to create embeddings where the meaning is close together. So we're taking the prompt with the person entered their question, sort of the semantics and meaning behind the question, and now we're going to go search for chunks of text that have similar meaning to the question. This is the key step, and how embeddings help us is we now can go and take the embedding for the prompt and you use it to search for similar chunks of text. So in this case, you might go and say, well, this chunk of text, interestingly, has similar meaning or semantics to what we see above, who when is the next practice for Music City, BMX. So we found a chunk of text that, due to the embedding being close to the other embedding, the embedding of our prompt, we say, well, this is a relevant piece of information, a relevant chunk of text, so we're going to include it and insert it into the prompt. And then what we get is we take the prop, we put the relevant information into it, and this happens all automatically. That's the key. It goes and looks through the document and uses the embedding of your prompt to find chunks of text in the document that look like they are semantically similar because they're close together when the numbers are similar. And then it takes those chunks of text and it puts them into a prompt. And so the end result is you get a prompt like this, and then this behind the scenes is what it actually submits and generates with. Now we just go back to this. What's happened is they've taken chunks of text from the document that appeared relevant and then dumped them into the prompt. And now we go and generate and in this case, we see that we get the right answer. If we do this, we've gone and augmented the prompt with the right information that it needs to generate the answer. So this is what is so critical about embeddings, is that they solved the hard problem of, how do I find chunks or text in that document to put into the prompt that will help the model answer the question, and we talked so many times about how we fight hallucination by giving the model the information, giving the CPU the data to work with. That's what we want to do with these generative AI models. But how do we find the right data? That's the problem that this is solving for how do I go and automatically find the right information to put into the model? Because what would be the alternative? Well, the alternative is the human being goes and takes all the information from the document and dumps it into the prompt. And that's expensive, that turns into a lot of tokens. Now we can solve problems that way, and often we want to do things like that, right? If we want a comprehensive answer, we might want to go dump the whole document into the prompt, pay for all those tokens. But many cases, we don't want to do that. We want to be more efficient, so we want to go find just the relevant chunks of text. Now we can have the human do that, but by the time the human does it, they've already answered their own question. So instead, what we do is we have it done automatically behind the scenes. We find the relevant pieces of information, put them into the prompt, and then run them and now we've got retrieval of. And augmentation working together to help us answer questions and help fight hallucination. [13412:48:00] 0: So we just go retrieve a bunch of information and put it into the prompt. You know, augment the prompt with all this information, and we're done, right? And unfortunately, it's not that easy. We have to think very carefully about the prompt engineering around that augmentation process, because if we get it wrong, bad things will happen. And so I'm going to give you an example of this. So I've gone and I've done a lot of manual retrieval, augmented generation where I'm going, and I'm augmenting the prompt with arbitrary information just manually through copy and paste. So let's go back to this original example, who was the 2023, Tennessee nine intermediate emX state champion. Well, we could go and we could let the tool try to answer the question and listen again, but let's see what happens when we control the retrieval. We go and choose what information goes in the prompt and augment it with that information. And let's see what happens when we put garbage information in information that is not relevant to answering the question or performing the task. So I'm going to copy just a bunch of random stuff out of my LinkedIn feed with all the formatting and everything, because we've done a bunch of examples where I've said, Look, formatting doesn't matter and it doesn't matter, but the quality of the information and what's in there does matter. And we'll see that in a second, and how we present it really matters. And now I'm going to copy and paste that into the prompt, so I'm going to replace the original information, which was who actually won, and the standings. And now what I'm going to do is I'm going to replace it with this garbage information that I just copied and pasted out of my LinkedIn page, where I'm just put a bunch of random stuff in here, and I copy and paste it into the prompt, and then I give it the instruction, who was the Tennessee nine intermediate BMX state champion? So I have done retrieval, augmented generation. I've just augmented the prompt with the wrong information. So what happens when we do this? It comes back and it says the Tennessee nine intermediate BMX state champion for 2023 was Jackson Klein. It's now hallucinated a totally new name, even though I gave it the information. And so we think, Oh, well, if we go and do retrieval event generation, we're done, right? No, it's not enough. Because if we get the wrong information in there, or the information is not good enough, or it's off topic, or it's subtly wrong in some way, then what we're doing is we're feeding in the wrong information, and we're going to end up with bad output, just like we had before. And in this case, if I get all the information wrong, there is not the information that is needed to answer the question. What it can end up doing is filling in the answer with hallucinations. So what we're seeing is, if there's a disconnect between the information and what it needs to do, it will end up hallucinating. Now, why might there be this disconnect? Well, we might have retrieved the wrong information, and there's a gazillion reasons why we could have retrieved the wrong information, but we also might have presented the information when we augmented the prompt we may have in, you know, done that presentation of the information subtly incorrect. And I'm going to give you an example of why the augmentation, the prompt engineering, the obligate augmentation, is critically important, and something that we have to think about. I'm going to go back and I'm going to recreate this prompt, potentially relevant information, but I'm going to do some important, critically important things, and I want to show you what I'm going to do. The first thing is, is I'm going to take that information, I'm giving it, and I'm going to number it. Now, what I've numbered it with is I've just basically given all that original information. There's no meaning to the numbers. It's roughly line numbers. I'm just giving statements with numbering next to it. Now, numbering is important because when we give numbers to things, then we can ask you to refer to numbers. So if I give it some information and I say, here's a numbered list of facts, I can now later say, Go and refer to the number of the fact that supports your answer. And that's what I'm going to do in a second. I then go and I give it the instructions. Who would you Tennessee nine intermediate emX state champion. And I say, output your answer in the following format. And I'm using the template pattern. And I say champion, insert name, and then I say, Insert line numbers, supporting evidence. So I'm telling it it has to refer back to the facts they gave it and the line numbers of the facts they gave it, and giving it something in the information to reference in its answer. And I'm saying you're going to give me the answer, and then you're going to tell me the line numbers that support your answer. And so this is doing something. This is creating some consistency. So we're trying to create consistency, or self consistency, meaning there's a reference and an identifier in the original prompt, in the information that we're giving it, that we want it to reference in the output. And we want to make sure it's consistent, that it's reference, that it goes back to actually exists and makes sense. Really powerful way to start improving the quality of the output and making it fact checkable. In this case, something magical happens. Because when we put that in and we say, Insert line numbers of supporting evidence, and we run it now, it says champion Aiden Coleman, which it hallucinates. But then beneath it, it says no specific supporting evidence found and provided information. So what's happened is we've told it to do something that it is unable to do because there is no supporting evidence. So although it went and hallucinated, then it has to go through and find supporting evidence for that hallucination, and it can't do it. And it's telling us that now, had it gone and put some random line numbers in there, we could go and look and see if they are but many of these foundation models are smart enough to recognize that, based on where it is, there's nothing that's supporting it that we've asked it to perform a task that is incapable of the formula, which In this case is finding supporting evidence, where this random you [15189:46:40] 0: a person [15203:54:40] 0: being the champion, and that evidence doesn't exist. So it's saying, hey, it's not there. [15227:12:00] 0: This is just a simple way of highlighting the importance of the prompt engineering in the augmentation Yes, the retrieval is critically important. Yes, finding the right information is important if we want to have a hope of answering the question. But the augmentation process, the prompt engineering that goes in there is really, really important, and we can go and control the prompt engineering of the prompt in a way that can account for what may be happening behind the scenes, so we may not be able to control the retrieval as normal users of the system, but we can control our prompt engineering and the prompt in a way that can probably help us tap into and make sure that if something is retrieved it is incorrect, that that is spotted, or if there's nothing retrieved, that's helpful, that That's spotted and that's all surfaced in our prom. [15537:52:00] 0: Retrieval seems a bit like magic. We put these special embeddings in we go and retrieve the similar text to the prompt. We just find all these chunks, put them into the prompt, and we're done, right? It seems so simple, If only that were the case. Unfortunately, we're going to see that it's not quite so simple. And this is where rag, although it's phenomenal, requires a vast amount of work and thought and some effort to get it right. Now, there's all kinds of techniques that are used to get rag right. And I'm not going to go into the depth of all the different techniques, but I want to give you just a sense of the challenges that we begin to face with rag and one of the basic ones is the chunk. What is the chunk? Is the chunk a paragraph? Is it an entire page of the document? Is it a sentence? Is it a few words? Is it a table? What the heck is a chunk? And this is a critical, painful problem to determine. Now it doesn't have to be, but it can be. Now. Why would this matter? Well, I want you to think about it. What is the meaning of this page of text? Take a moment read it and tell me what the meaning of this page of text is. Now, read one individual paragraph in this page, and does it have the same meaning? Well, let's look at an example. The whole thing is all about the computer science department at Vanderbilt and the curriculum and other requirements for undergraduate students. Now let's read an individual paragraph. The computer science major provides an excellent background for medical students and the flexibility provided by its. Mainly, many open electives allow students to prepare for medical school while also earning a degree in computer science with a normal load in four years. Interested in students should discuss their plans with the computer science advisor. Well, the meaning of that paragraph is probably very different in semantics, in distance, in representation, than the meaning of the overall document. The overall documents are really about computer science in the computer science department, the meaning of that paragraph is about computer science for medical students. And so depending on what our chunks are, our beddings are going to be different. And if we're now a medical student looking for information, we might not find this if we're chunking at the, you know, page level. On the other hand, if we are chunking at a smaller level, we may miss something, and that becomes the issue. So let's, let's take a look at what we might miss, and we chunk at a smaller level. So it might seem like, Okay, well, it's no problem. We just go and chunk at a smaller level? Well, if we go and chunk at a smaller level, I want you to take you to this bottom part, where it has course requirements. Let's imagine we go and split course requirements, and we end up splitting that into two different chunks. Now, there's different ways of like trying to make these things overlap, all kinds of stuff to try to solve this problem, but we're not going to look at those specifically in detail. But let's just look at this problem of let's assume that we've taken this last bit of the page, the curriculum requirements, and we've built that and we've now chunked it into two chunks. So this was the curriculum requirements, and we've now split it into two chunks. What's the issue that we're going to run into here? Well, one issue is if I am a computer science student, and I now when I go search for chunks that are relevant to computer science students, I may or may not find those bottom requirements, because the bottom requirements down there, when you take away the sentence that says the BS in computer science requires a minimum of 120 hours distributed as follows that provides context for the information that comes next. If you take that away and you strip it away, now I'm running into the problem that my computer science requirements are no longer scoped to computer science and instead, I see I have a bunch of requirements that include computer science classes, but it doesn't tell me what major they're for, and there's other majors on campus that have requirements that include computer science classes. Now I can't tell the difference between the two, because I've just got lots and lots of chunks that tell me about computer science requirements, and I might not get the chunk I want, or, even worse, I get The wrong chunk, and because We've removed The Top So [17422:13:20] 0: It. And if we're now a medical student looking for information, we might not find this if we're chunking at the page level. On the other hand, if we are chunking at a smaller level, we may miss something, and that becomes the issue. So let's, let's take a look at what we might miss if we chunk at a smaller level. So it might seem like, Okay, well, it's no problem. We just go and chunk at a smaller level. Well, if we go and chunk at a smaller level, I want you to take you to this bottom part, where it has course requirements. Let's imagine we go and split course requirements, and we end up splitting that into two different chunks. Now, there's different ways of like, trying to make these things overlap, all kinds of stuff to try to solve this problem, but we're not going to look at those specifically in detail. But let's just look at this problem of let's assume that we've taken this last bit of the page, the curriculum requirements, and we built that, and we've now chunked it into two chunks. So this was the curriculum requirements, and we've now split it into two chunks. [17736:37:20] 0: What's the issue that we're going to run into here? Well, I [17777:46:40] 0: I thank you for going on this journey in advanced prompt engineering with me. As you go forward, make sure and remember all the key techniques that we use. So I want to just quickly review some of the most important ones, one in context learning. Yes, instructions can be really powerful ways of telling the large language model what we want, but sometimes just providing examples can be the most powerful way that we can get it to refine its behavior. And, you know, pull out that behavior that we're really looking for. There's nuances, for example, when we're writing and it's really hard to write the instructions for what we want in context, learning can be a really, really powerful tool when we're going and building prompts. And in fact, most prompts can really benefit from in context learning and providing examples of what we want. Second one preference driven refinement. You don't have to have all of the examples up front. You can actually iteratively use the prompts to build the examples that we later bring back into the prompts for in context learning. So remember, you don't have to start off with a data set. You don't have to start off with all the examples you built by hand. You can actually do it interactively, and you can teach and improve the the large language model through your prompts with in context learning by having it generate things, find the parts of those output that you like, bring them back in as positive examples or negative examples to instruct it what you're looking for. Second, I want you to really remember that these models are powerful or general tools for machine learning and AI and you can go and do classical machine learning and AI problems with these things, things like classification, sentiment analysis. So make sure and know that and be aware of it and tap into it. And then when you need to teach it something new, go back again to in context learning. Third, output, formatting. Output. Formatting is one of the secret tools in advanced prompt engineers tool belt and so many people just go and say, This is what I want, but they don't say, this is the format that I want to add. And the format, particularly when we start using placeholders, can be a rich way and a very concise way, to help instruct the model how to produce exactly what we're looking for, and then use your knowledge of retrieval logs in a generation to help you know, build prompts that have safety built into them, that have references back to information that was given to them in the prompt, or maybe was retrieved from results that have citations, all kinds of other things that make the output more fact checkable and something that helps us to ensure that we can trust the results that we're getting. So I really hope you've enjoyed this course, and I hope you'll continue learning more and more about prompt engineering and how to tap into these powerful capabilities in generative AI models. [18651:54:40] 0: You go and retrieve the similar text to the prompt. Slide up these chunks, put them into the prompt, and we're done right. Seems so simple, If only that were the case. Unfortunately, we're going to see that it's not quite so simple. And this is where rag, although it's phenomenal, requires a vast amount of work and thought and some effort to get it right. Now, there's all kinds of techniques that are used to get rag right. And I'm not going to go into the depth of all the different techniques, but I want to give you just a sense of the challenges that we begin to face with rag. And one of the basic ones is the chunk. What is the chunk? Is the chunk a paragraph? Is it an entire page of the document? Is it a sentence? Is it a few words? Is it a table? What the heck is a chunk? And this is a critical, painful problem to determine. Now it doesn't have to be, but it can be. Now, why would this matter? Well, I want you to think about it. What is the meaning of this page of text? Take a moment read it and tell me what the meaning of this page of text is. Now, read one individual paragraph in this page, and does it have the same meaning? Well, let's look at an example. The whole thing is all about the computer science department at Vanderbilt and the curriculum and other requirements for undergraduate students. Now let's read an individual paragraph. The Computer Science major provides an excellent background for medical students, and the flexibility provided by its mainly mini open electives allow students to prepare for medical school, while also earning a degree in computer science with a normal load in four years. Interested students should discuss their plans with the computer science advisor. Well, the meaning of that paragraph is probably very different in semantics, in distance, in representation, than the meaning of the overall document. The overall documents are really about computer science and the computer science department, the meaning of that paragraph is about computer science for medical students. And so depending on what our chunks are, our beddings are going to be different. And if we're now a medical student looking for information, we might not find this if we're chunking at the page level. On the other hand, if we are chunking at a smaller level, we may miss something, and that becomes the issue. So let's, let's take a look at what we might miss if we chunk at a smaller level. So it might seem like, Okay, well, it's no problem. We just go and chunk at a smaller level. Well, if we go and chunk at a smaller level. I wanted to take you to this bottom part, where it has course requirements. Let's imagine we go and split course requirements, and we end up splitting that into two different chunks. Now, there's different ways of like trying to make these things overlap, all kinds of stuff to try to solve this problem. But we're not going to look at this specifically in detail, but let's just look at this problem of let's assume that we've taken this last bit of the page, the curriculum requirements, and we've built that and we've now chunked it into two chunks. So this was the curriculum requirements, and we've now split it into two chunks. What's the issue that we're going to run into here? Well, one issue is, if I am a computer science student and I now and I go search for chunks that are relevant to computer science students, I may or may not find those bottom requirements, because the bottom requirements down there, when you take away the sentence that says the BS in computer science requires a minimum of 120 hours distributed as follows that provides context for the information that comes next. If you take that away and you strip it away, now I'm running into the problem that my computer you know, science requirements are no longer scoped to computer science, and instead, I see I have a bunch of requirements that include computer science classes, but it doesn't tell me what major they're for, and there's other majors on campus that have requirements that include computer science classes. Now I can't tell the difference between the two, because I've just got lots and lots of chunks that tell me about computer science requirements, and I might not get the chunk I want, or, even worse, I get the wrong chunk. And because we've removed the top part, that gives context to what we've got, now we've got a problem like, how are we going to know that we got the right chunk, and how is the LLM now going to know that what that information means, or what happens if it gets a whole bunch of chunks that say curriculum requirements, none of them scoped with that header? Does it assume that all of them are relevant? Does it assume that in one of them is relevant? It just picks randomly some subset of them, and you see how a chunk. Can now become a problem if the chunk is not the right chunk, like if it's not semantically whole for the question that we need to answer, we're going to be in trouble. Okay, what else can go wrong with the chunking? Well, let's think about the presentation of the chunks. Let's say we split that apart, but we go and we get lucky and we get both those chunks. Well, what happens if we present them out of order? We say, You know what the requirements seem like, they're more relevant. So we're going to put that chunk first, and then we're going to put curriculum requirements, and then we're going to lay this all out as text into the prompt. Well, if you're the LLM now this looks a little tricky. Are what you see? What the thing you're seeing above is that the set of requirements, and then when this is describing the start of a new set of requirements that aren't provided, or are they the same thing? And if they're the same thing, then maybe I need to merge them together. And you see, now the complexity that happens is like this simple concept of like, reading the document. Well, you can imagine if somebody went and just took a paper cutter and they sliced up your document into all these strips of paper, and then they scattered them across the floor, and then they and then you asked a question, and they're like, Yo, no problem. And they pull out a couple random pieces of paper, and they hand them to you, and those strips of paper have chunk of text on it, and you're reading them, and you're like, do these go together? And what order do they go in? And these are all sort of augmentation aspects and prompt engineering aspects that really, really matter, right? Because if those things are given to you without the appropriate context or incomplete you get half the requirements, but you feel forced to answer the question. You may give an incomplete answer that looks like a right answer, and so many things can go wrong. Another simple thing is what happens and how you present the information and the prompt. So if you go and you show the information, and you say relevant information, you almost are implying that the information needed to answer the question is there. So imagine again, we've sliced up that documented a bunch of strips of paper. We've dumped them on the floor. You go, and you're like, I have this question. And the retrieval person goes and searches through this stack of paper. He pulls out all these slips of paper with different chunks of text. Chunks of texting. He shows them in your face. He says, here the answer is there. Here is the relevant information. Go help yourself and answer the question. You're like, man, it's kind of weird, but I think the relevant information is here, so I'll do my best to answer the question using what's put here because he told me this is the relevant information, so it must be right. So I'm going to answer the question, right? But what if the information you're given is not actually relevant? Like, what is it if it's garbage in the fact that he told you that it was relevant? Now is a problem? What if we simply, he he told you, well, I searched through this back of papers, and I found a bunch of slips of paper, these chunks of text, they might be relevant to you. Why don't you look through them and see if anything's valuable to you? And you see how that slight change in how we word and present it totally, you know, influences the way that we're going to answer this question. So there's so many subtle details, everything down to, you know what? What is a chunk of text? When we go and retrieve do we put them back together? And if so, how many of them do we stitch back together? Do we stitch them back together in order? Do we reorder the chunks of text after they've been stitched together in some way. Do we how do we word what we are doing when we present it like all of these things can have an impact on what happens, and we have to think very carefully and thoughtfully about this from a prompt engineering perspective, but as a user of the system, we want to be cognizant of this and try to design prompts in such a way that we don't end up, you know, having bad things happen, because these retrieval, augmented generation systems are imperfect and may not find the answer, you know, that we need, may not find the chunks that we need, may not present them in the right order, may not merge them together appropriately, may not do all kinds of Things it, and this is What makes it challenging. [21257:09:20] 2: So thank [21277:46:40] 0: you for going on this journey in advanced prompt engineering with me. As you go forward, make sure and remember all the key techniques that we use throughout this course. So I want to just quickly review some of the most important. Important ones, One I [21856:13:20] 1: Now this right here portion is going to be directly communicated when I when I ask about anything from here, so, like, the last word should be the last word should be of any service, comma, product, comma or site of corporation, comma, organization or individual responsible use of generative artificial intelligence For the federal workforce. So that's the beginning of it. [22060:56:00] 3: Produce communications materials you should nope wrong. [22117:28:00] 3: Responsible Use of generative [22132:40:00] 3: are. Artificial Intelligence for the [22147:28:00] 3: federal workforce. [22159:44:00] 3: Artificial intelligence, AI, as used here, refers to a machine based system that can make predict. Decisions, recommendations or decisions. Is when used responsibly, it is a powerful technology. That can improve federal government operations and service delivery within the broad field of AI generative. Ai Gen. AI is a rapidly evolving technology that can generate content, including text, audio, images or video in response to a prompt or input data. It includes conversational AI applications, for example, OpenAI, chatgpt, Google, Gemini, meta, Lama anthropic, clod and image generation. AI applications, for example, open AI Dolly, mid journey, stability. Ai stable diffusion. Adobe, Firefly, as well as applications to generate speech, video or programming code, for example, GitHub copilot, Amazon code whisperer, Gen AI technology is trained on large amounts of data, which can include publicly available text, images, audio and videos scraped from the internet. [22577:41:20] 3: What does this mean to me as a federal employee, [22597:30:40] 3: genai has the potential to improve the way the federal workforce delivers results for the public. Federal employees can leverage genai to enhance creativity, efficiency and productivity. Federal agencies and employees are encouraged to consider how best to use these tools to fulfill their missions. As a federal employee, you should carefully consider the benefits and risks of using Gen AI in your work and use these tools in a safe, secure and responsible way. [22756:00:00] 3: How should I use this web page? [22771:33:20] 3: Learn about Gina's potential benefits and risks. [22790:45:20] 3: Explore best practices for safely, securely and responsibly using Gen AI in your work. Find ways to learn more about Gen AI. Note that this web page is not comprehensive. You should review and follow your agency's relevant policies and procedures. This content may be periodically updated to account for advancements in Gen AI and evolving workforce needs, [22920:58:40] 3: potential benefits and risks of using Gen AI. [22940:26:40] 3: Potential benefits. [22954:08:00] 3: September 12, 24 1:40pm responsible use of generative artificial intelligence for the federal workforce. HTTPS, colon, slash, slash, www.opm.gov/data/resources/ai-guidance, 1/5 in Gen AI applications offer the federal workforce many potential benefits related to productivity and agency [23074:13:20] 3: operations, including [23089:09:20] 3: increasing the efficiency of manual or repetitive tasks synthesizing information, such as summarizing meeting notes or transcripts or extracting the main idea [23152:10:40] 3: or key elements from documents, [23167:38:40] 3: brainstorming and ideating, [23184:26:40] 3: drafting and designing communication products, including generating outlines or text and images for reports, presentations, emails, web or social media, improving and refining writing, including providing grammar, spelling and style suggestions and [23274:56:00] 3: transforming complex concepts into plain language, [23294:24:00] 3: translating products into other languages, [23313:57:20] 3: enhancing customer experience by creating customized responses to inquiries, improving accessibility through features such as audio and video transcription, accelerating software development by generating explaining or debugging code, or by translating code [23402:50:40] 3: from one programming language to another, [23423:54:40] 3: analyzing and deriving insights from data sets and generating graphs. [23450:02:40] 3: Potential risks. [23467:54:40] 3: The use of Gen AI also presents potential risks that need to be managed so that the federal workforce can leverage this technology responsibly, including fabrications and errors such as reasoning mistakes or factually inaccurate text, speech images or the. Videos, [23569:25:20] 3: plagiarism or copyright violations, [23587:33:20] 3: security vulnerabilities of the tools, [23607:49:20] 3: privacy risks, including from unintended disclosure of training data, proms or input data, amplification of biased, inequitable or discriminatory content, legal or ethical risks, such as AI generated content that encourages illegal or unethical behavior, risks to Agency, credibility, if content is inaccurate, unreliable or discriminatory, uneven performance, depending on languages, fields and applications, harmful use by individuals external to the federal government, to create misinformation in person, aid [23808:00:00] 3: elected officials or spam an agency [23826:24:00] 3: recommendations for federal employees using Gen AI [23846:45:20] 3: when using Gen AI in the workplace to conduct official business, remember to follow your agency's policies and procedures, including for AI governance, data governance, privacy and [23913:57:20] 3: security [23924:42:40] 3: use your agency's Gen AI resources to assist with your official duties, and not for personal use. Expect that your use of Gen AI technology may be logged and monitored. Consult with your agency for a list of approved Gen AI technologies that may be used for official business. Follow agency directives on when and how to use Gen AI technology through public interfaces that is any applications or software that use genai, that are available to the general public or through your agencies Secure Enterprise system, as there are risks associated with either type of access, including risks related to Storage, reuse or disclosure of information. September 12, 24 1:40pm responsible use of generated artificial intelligence for the federal workforce. HTTPS, colon, slash, slash, www.opm.gov/data/resources/ai-guidance, [24258:18:40] 3: two fifths, understand [24275:38:40] 3: any response. Restrictions on information that can be input into Gen AI interfaces and only input information that is allowed, do not input non public information into public Gen AI interfaces oversee the use of Gen AI technology. Do not leave Gen AI technology to operate autonomously without [24404:37:20] 3: human accountability and control [24423:01:20] 3: review all AI generated materials, including sources cited to check that they are valid, accurate, [24464:42:40] 3: complete and safe. [24485:46:40] 3: Review AI generated material for potentially biased, harmful, stereotypical or otherwise offensive language or images, do not tamper with or attempt to turn off guard rails against unsafe, offensive or [24580:00:00] 3: misleading inputs or outputs of Gen AI systems [24608:00:00] 3: maintain integrity and avoid ethical misconduct, for example, fabrication, falsification or plagiarism, [24652:05:20] 3: including in any AI generated material. [24689:41:20] 3: Follow your agency's policy on when and how to disclose uses of Gen AI, for example, labels, watermarks [24734:34:40] 3: or disclaimers on AI generated material. [24758:50:40] 3: Use Gen AI tools only for appropriate purposes and not to generate malicious, inappropriate or illegal material, such as malware, deep fakes, toxic content or other material. Considered not suitable for work. [24836:10:40] 3: Examples of Gen AI uses. [24854:34:40] 3: Some federal agencies already use AI to improve operational efficiency and effectiveness. You can find your [24894:34:40] 3: agencies reported federal AI use cases on ai.gov [24913:36:00] 3: this inventory will be updated with Gen AI use cases as agencies continue to explore adopting this technology. Below are examples of potential uses of genai that you may encounter as part of your work which provide the I do. Additional use specific considerations and recommendations. These do not present a comprehensive set of the. The possible uses or recommendations that federal. Employees should abide by when using Gen AI work with your. A supervisor and relevant agency officials to. Understand your agency's particular policies, including whether Gen AI is appropriate for your use case, and which Gen AI technology should be used. Using Gen AI to summarize or analyze information. Use Gen AI technology can be used to synthesize information, such as summarizing meeting notes and transcripts, extracting main ideas from documents like research papers or policies, or analyzing data, for example, producing summary statistics or graphs. It also can answer questions about a particular topic [25297:36:00] 3: appearing in documents or data. [25316:48:00] 3: Considerations. Gen AI technology may omit essential details from summaries, fabricate information that is not included in the documents or data, or include additional materials from its training set that are not in the source inputs. Gen AI technology may also introduce biased or outdated language when synthesizing it can also [25432:37:20] 3: be subject to reasoning and mathematical errors [25450:45:20] 3: recommendations when using Gen AI to summarize information or analyze data, you should review the accuracy and validity of AI generated summaries to detect and correct potential issues, including factual inaccuracies logical reasoning or mathematical errors and inappropriate language. Verify that the AI summary is consistent with the input is complete and does not include information [25587:28:00] 3: beyond the scope of the documents or data. [25605:36:00] 3: September 12, 24 1:40pm responsible use of generated artificial intelligence for the federal workforce HTTPS, colon, slash, slash, www.opm.gov/data/resources/ai-guidance, [25686:29:20] 3: three fifths, [25712:37:20] 3: check that AI generated content has appropriate citations, references or other attributions for [25746:50:40] 3: information used [25765:30:40] 3: using Gen AI to create communications materials. Use Gen AI can be a powerful tool for developing communications for various reading levels, languages platforms and audiences. Gen AI technology can be used to draft content, develop outlines, improve grammar and spelling, transform content into plain language, translate materials in multiple languages or generate audio [25924:53:20] 3: or visual assets, [25944:37:20] 3: considerations because Gen AI technologies training data may not equally represent non English languages and perspectives from underserved communities, generated communication outputs may be inaccurate, biased or harmful. Training data may also be outdated, so AI generated material may not include recent events or [26076:42:40] 3: perspectives. [26090:18:40] 3: Additionally, the use of Gen AI technology to produce communications may not be appropriate for sensitive [26131:44:00] 3: topics or events. [26148:16:00] 3: Recommendations when using Gen AI to produce communications materials you should review and fact check the content produced by Gen AI tools with subject matter experts, for example, if translating products to another language or for a new audience, your agency may require that person's proficient in that language And with knowledge of that cultural context, review these materials, select AI generated text and images that are respectful and inclusive, and review final products for [26319:38:40] 3: accessibility, [26331:22:40] 3: check if AI generated content includes copyrighted material, and consult with your agency legal counsel [26364:32:00] 3: about use of such materials, [26384:16:00] 3: verify your agency's requirements on disclosing use of genai for materials produced for external and [26417:20:00] 3: internal audiences [26430:56:00] 3: using genai. For software and code development [26450:29:20] 3: use. Gen AI technology has the potential to improve the efficiency and speed of software and code development. For example, it may help with programming, code generation, review, explanation and debugging considerations. Ai generated code may include bugs or introduce security vulnerabilities. It can also introduce new libraries and dependencies, including nonexistent core malicious packages. It may also borrow [26597:46:40] 3: from open source code without attribution [26616:58:40] 3: recommendations when using Gen AI for software or code development, you should verify that you have the necessary agency approvals for conducting code generation and review with Gen AI prior to leveraging Gen AI for this purpose, review your agency's policies and industry best [26741:25:20] 3: practices for generating software and code, [26767:49:20] 3: conduct review and testing of AI generated code before deploying it. Fix bugs, address vulnerabilities and check the legitimacy of AI generated libraries and dependencies. Verify that AI generated code is [26859:22:40] 3: performing as intended. [26880:26:40] 3: Familiarize yourself with your agency's requirements for code documentation and storage and for disclosure of use of genai. Pay special attention to restricted activities such as prohibitions on inputting. September 12, 24th 1:40pm response. Responsible Use of generative artificial intelligence for the federal workforce. HTTPS, colon, slash, slash, www.opm.gov/data/resources/ai-guidance, four, fifths, internal code, for example, code from an agency's enterprise code repository that is not publicly available [27107:22:40] 3: into public interfaces [27126:50:40] 3: follow agency security procedures, such As not including passwords keys or security credentials in prompts or data sets input into Gen AI technologies. Follow your agency's policy on using open source code and comply with agency licensing and attribution [27245:36:00] 3: requirements. [27267:33:20] 3: To learn more about these uses and any others in which you are interested, consult with your agency's chief AI [27301:25:20] 3: officer or other agency AI governance officials, [27323:33:20] 3: continuous learning and training. [27350:18:40] 3: This is an evolving field, and as we adapt to the tools available to us, it's important to stay up to date with relevant trainings the Office of Management and Budget OMB, in collaboration with the General Services Administration, GSA has piloted free AI training for federal employees, and will continue to create, adapt and deliver federal AI training modules in partnership with OPM and informed by agency needs. As a federal employee, you can access the 2023 training here Max page. [27541:09:20] 3: Additionally, Executive Order 14,110 [27557:57:20] 3: tasks agencies to implement or increase the availability and use of AI training and familiarization programs for employees, managers and leadership in technology as well as in relevant policy, managerial, procurement, regulatory, ethical, governance and legal fields, [27684:42:40] 3: contact your agency's chief human capital officer or chief learning officer to learn more or join the AI [27737:20:00] 3: Community of Practice. [27757:20:00] 3: Ai communities of practice, a. [27781:57:20] 3: If you are interested in AI, or intend to use, manage, develop or procure Gen AI technology, you are encouraged to join the AI Community of Practice. AI comp, open to any federal government employee this community of practice regularly shares resources, including centralized information around training, [27912:10:40] 3: endorsement, disclaimer, [27934:34:40] 3: links to invention of brands, services, products or websites external to the US government on this web page are provided as examples and for informational purposes only. They do not constitute an official endorsement or approval by the US government or US Office of Personnel Management of any brand, service, product or site of the corporation, organization or individual. The [28284:26:40] 0: Me. I want you to think of chatgpt and these large language models as tools that you can use to give your ideas form, to give your thoughts realization, to be able to explore lots of different concepts and be able to refine them over interactions with the tool. I don't want you to think of these tools as something that you use to just write essays or answer questions, that's really missing the capabilities of the tools. These are tools that really allow you to do fascinating things. So now I'm going to try to give you an example of this, hopefully motivate you that these tools have immense capabilities, and that those capabilities can allow you to do things that would be very difficult to do otherwise. So what is a task that I thought of that would be something that we could all relate to? And I thought about my family, and I thought about this crazy idea, we have some great we have this great restaurant from Uzbekistan that's in Nashville. We have a great restaurant Ethiopia. We've actually got lots of great Ethiopian restaurants. And I thought to myself, you know, what would it look like to create a meal plan? It was based on a fusion of cuisine from Uzbekistan and Ethiopia. You know, what would that look like? And in the past, I've eaten keto. So could we try to make it kind of keto? Because I still kind of like to limit my carbs. And, you know, at the end of the day, realistically, I'm going to have to buy all the ingredients for this, and if they're not easily accessible at the grocery tree, for me, I'm probably not going to cook the meals. So I thought, well, let's go to chatgpt and see if it can help us with this problem. If it can help us prototype what this meal plan might look like. So I went to chatgpt, and I said, Please create a meal plan for my family that is based on a fusion of food from Ethiopia and Uzbekistan. I want to eat keto and up to 2000 calories per day. Pick dishes where the ingredients are easy to get from an average US grocery store. Now this is a hard problem, right? I don't think that there's a human on the planet that easily answer this question, and if they are, I probably could not find them. It would probably cost me too much to hire them, and they certainly couldn't do this as fast as I'm about to get it done for me. So I asked chatgpt to do this for me, and chatgpt says, Here is a sample meal plan that combines flavors from Ethiopia and Uzbekistan, while also being keto friendly and within a 2000 calorie per day limit, breakfast, scrambled eggs with sauteed onions, tomatoes and Ethiopian Berber spice. Now notice what it does. It puts in parentheses. It says, made with chili powder, paprika, garlic powder, ginger, cumin and coriander. Now what it's signaling is berbera spice is something you can get at the average US grocery store. All of these spices are easy to obtain from a normal us grocery store. So not only is it answering my question, it's giving me an Ethiopian breakfast dish, it's giving me information that I'm going to be able to get these spices. Now, I don't know enough about Ethiopian cuisine to know if this is a really accurate dish. It may not be. It may be sort of inspired by it and very Americanized, but I'm still for me, and what I'm trying to do this is pretty impressive. Then goes on to say, lunch, Uzbek style lamb kebabs with grilled vegetables, bell peppers, zucchini, eggplant and a side of cucumber and tomato salad dressed with olive oil and lemon juice. Now you notice all of this is pretty keto friendly, too. Now, some people could take issue with the onions, but it's a really good first start of giving this crazy idea I have for now. It may have errors in it. It may not be perfect, but I could go and work with this and refine it and start improving it. And that's one of the things I want you to think about throughout this course, is don't think of this as a one off. I give it a question, I look at the answer and I say it's good or bad, no. So I went back to it and I thought, well, one of the things that I'm really missing from this is I don't know how much to eat. So I said, Can you get me an approximate serving size for myself for each dish that is within my 2000 calorie limit? And Chad, GBD says, Sure, here are approximate serving sizes for each dish based on a 2000 calorie per day limit, breakfast, scrambled eggs with sauteed onions, tomatoes and Ethiopian Rivera spice mix. And then it has a parenthesis, two eggs, half a cup of onions, half a cup of tomatoes, one teaspoon of Berber spice mix, served with a side of sliced avocado, one quarter medium avocado. And it goes on to give me now serving sizes for each of these different dishes. Now, again, I didn't. Go, and I didn't take it into some calorie calculator and look at the macros and check if it really fit my diet, because I was just fascinated about prototyping this idea, exploring this concept. And I could keep refining it. I can keep looking and improving it, asking it, to break down things really, and analyzing and making sure it exactly fits what I'm looking for. But instead, I want to do something kind of different. I'm going to go and continue this thread of conversation, this crazy idea that I had, and give it a little more form. And so what I thought about is, if I was really going to take this crazy idea into my family, I'd have to think about my nine year old son. My wife and I are more adventurous either, but my nine year old, he's not always going to want to eat everything that we come up with. And so I thought, well, what could I do to help him get excited about trying these things up? And so I thought, I can go back to chatgpt and I try to get chatgpt help with it. So I said, chatgpt. My son is nine. Sometimes he won't try new dishes to make this culinary adventure more fun for him. Can you create a short Pokemon battle story to go with each dish, and if you're not familiar with Pokemon, it's trading cards and a game, a cartoon. My son loves it. I will read the stories with him before dinner to get him excited about trying the new food. Make sure the story ends with a cliffhanger that will motivate him to try the new food. Now maybe I could find somebody who could give me a meal plan based on boost back cuisine and Ethiopian cuisine, but and make it keto, and do all those things and look it up. I'm not sure they could do it anywhere near as fast, but now we're really moving into territory where it's going to find be hard to find be hard to find a single human being and to get somebody to do all this is going to be expensive, and I'm doing this in a matter of minutes. So what does chatgpt say? Certainly, here are some short Pokemon battle stories to go with each dish. And then we had this breakfast dish with the berbera spice, and it says, Sorry. Pikachu and his friends were exploring the wilds of Ethiopia, and they were suddenly ambushed by a group of sneaky Pokemon peas, and it goes on to have this Berber dragon that they're battling. And then it says, In the end, they emerge victorious, but not before the dragon left a fiery spice that imbued their breakfast eggs with a flavorful kick. Can you help Pikachu and his friends defeat the berbera dragon and enjoy this spicy breakfast that's pretty amazing, right? We've gone from a meal plan to now help my son get excited about meeting me eating this by mixing in some concept that he's really excited about. And it's actually produced a cliffhanger. Is this the best cliffhanger? Maybe? Maybe not. But does it matter? No, because I'm rapidly sort of experimenting with my ideas. I'm trying to get my thought form. I'm trying to understand what this would look like. And I could go and I could refine it and improve it further, but it's already done a pretty good job. I could probably take this and read it to my son and have him more excited about trying the dish. So then I thought, well, let's take this crazy idea further. So we're going to be sitting at the dinner table. We're going to read these crazy stories that chatgpt has generated for me try to get my son excited about eating these dishes. I thought, what else do we do at the dinner table that I could weave into this? And I thought, well, one of the things we do is we talk about what my son is learning at school, and one of the things he loves is he learns loves. [30591:12:00] 0: Welcome to this course on prompt engineering. I'm Jules white, and I'll be guiding you through this exploration of an absolutely fascinating topic that I'm really excited to talk to. You about I'm an associate professor in computer science at Vanderbilt, and I'm the Associate Dean of strategic learning programs in Vanderbilt School of Engineering. I'm going to talk to you about this really fascinating and timely and important topic for all of us, which is, how do we interact with large language models like chatgpt? Now I really hope that this course inspires you to start using large language models like chatgpt. We'll talk about what large language. Your models are in more detail in this course, but you can sort of use it interchangeably until we talk about it as chatgpt is a large link. Each model now we've seen a lot of. The back and forth and discussion in the news about what are these tools? Yeah, and what we've really seen them presented as, in some respects, is tools for cheating on exams or writing essays. We've seen them presented as tools for plagiarism or tools that are going to take over the world. And I really want to reshape your discussion of these tools and make you see that they're also and I primarily from my perspective, a new tool to really help unlock human creativity, to allow you to do things that you couldn't do before, to actually take your thoughts and give them form and do it really rapidly. These are tools that allow me to do things faster and better than I could before. Now I came into computer science. I actually started from visual arts. I went into East Asian Studies for a while, and then I ended up being a computer scientist. But I've always really had a passion for creativity and understanding how I could use different mediums, and be it paint or ceramics or code to do interesting thing. And I look at large language models as sort of a new fundamental medium. I can use it for programming, but I can also use it to create art. I can use it to improve my writing. I can use it to help perform thought experiments. There's so many interesting uses for these large language models, like chat, GPT, and we're not properly seeing them discussed. And so what this course is really about is it's teaching you how to leverage all of these interesting capabilities of these models. But in order to leverage these capabilities, in order to go and do the really creative things, you have to understand how you write props. And that's what this class is about, is how you interact with chatgpt, or another large language model, a prompt is what you write and give to chatgpt or another one of these models to get some type of outcome, but these are fundamentally really exciting tools that I think, expand the capabilities that We have as humans to express ourselves, to explore new ideas and to create realizations of our ideas faster than ever before. Now, to get started on this course, I've actually enlisted chat GPT help to welcome us to the course. Tell us a little bit about what we're going to learn. Chat GPT has said, Welcome to the course on prompt engineering. In this course, you will learn about the exciting field of prompt engineering, which is all about creating prompts that can program large language models to produce high quality output. Now don't worry, we'll talk a little bit about this. Do you need to be a programmer? We'll ask jet and GPT in a second, we will explore the different types of prompts, their patterns and techniques for refining and improving them. You will also learn how to use large language models for various tasks, such as knowledge exploration, prototyping, content production and assessment. By the end of the course, you will have a better understanding of how to effectively use large language models and their potential to shape the future of computing. Let's get started. Well, my first question that comes up out of this is, I want to make sure that I don't have to be a programmer to benefit from this course. Do I? I need to understand programming to take this course? No, you do not need to have any programming experience to take this course, the focus of this course is on creating effective prompts and using large language models to achieve your desire to help. While an understanding of program could be helpful, it is not necessary to understand the concepts and techniques we will be covering in this course. What other things might be helpful to me [31817:09:20] 0: do? To me to know for taking this course while programming [31852:42:40] 0: experience is not necessary, it would be helpful if you have some familiarity with basic computer concepts such as file management, opening and saving files and using a command line interface. Now, by command line interface, we need something like chatgpt. Additionally, having good writing skills and ability to think creatively will be important in generating effective prompts for large language models. Finally, being open to exploring new and evolving technologies and approaches will be key to getting the most out of this course. So there's really not a lot you need to know, as chatgpt has aptly said right here, you need some basic understanding of computer concepts. You need to be able to open up chatgpt. It calls it a terminal, but you can think of it as you need to be able to open up chatgpt and interact with it. Obviously, if you can't use a tool for this, you're gonna have a hard time opening files, but the fact that you're here probably means you have the right computer skills to do this. The second piece is something I want to talk about. Now, we think of these models as something that came out of computer science, but they're actually things that having experience writing, being able to think about writing clearly and effectively is actually really. Performance. My father was a professor of creative writing, and it's been really interesting to me, because this is helpful to me when I am working with these tools, to think about what I learned from him and how I designed the prompts. And finally, I want to emphasize this last point, creativity and then openness to exploration is really, really important with these tools, the creativity of the human that's putting in the words for the props, who's deciding what goes into that prompt and the organization and what gets asked and what instructions are given are fundamentally important for using these tools effectively. Now we think we've heard a lot about these tools, is like they are plagiarism tools. They are tools to do, you know, X, Y and Z, bad thing. But the truth is, if you really want to use them effectively, you have to be skilled. You have to be a creative thinker, a creative problem solver. The more creative you are, the better the outputs are going to be. You also need an openness to explore. You have to remember, this is very early days for these tools. We haven't developed the best practices in all the different domains for how we're going to use these tools, for how we're going to write prompts for every domain, from healthcare to customer service to creative writing, whatever the domain is, we're still figuring out how to write the best prompts, and so having an openness to go and explore and try out different things is really important. In fact, when you're programming with these tools, or working with these tools, and don't get scared because I said programming, because you'll see that you can program with these tools. Anybody can just by writing normal human language. But when you're working with these tools, often you need to go and try out different things. You need to try something and be open to trying a different variation and seeing what happens, running little experiments. A lot of times in life, it's so much effort to write something to generation program. Programs, software, you don't get to explore as much as we should. We don't get to think enough about design. Don't get to think enough about the big ideas, the problems we're trying to solve. And one of the things that's good is an openness to explore in using these tools. So what are some of the key concepts that we will learn in the course that will help us with problem solving? In this course, we will learn several concepts that can help with problems, on solving, understanding what prompts are and how to use them to program large language models to generate high quality outputs, learning how to create effective prompts by tapping the patterns from training data being specific with our input in using patterns of Persona, patterns verifier, understanding How to refine prompts from these techniques such as rewriting, combining, splitting and standing to achieve the desired output, learning how to use large language models to various tasks, prototyping, concept production, assessment and more, understanding how to use screenshot examples to teach large language models new tasks, how to format these examples properly to achieve the desired output. By learning and applying these concepts, we can effectively use large language models to solve problems and generate high quality outputs across a wide range of applications. So I hope that as we go through this course that you will become inspired to take the ideas that you're learning, to go into chatgpt or whatever tool is available to you, and to try them out about more of the things that you're passionate about, and to see ways that you can unlock your own creativity, that you can give yourself more time for high level problem solving, as opposed to being down In the details of how you give your thought form. So throughout this course, one of the themes you'll hear from me is try to give your thought form through this use it as a tool to accelerate your ideas into realization. So I look forward to exploring this fascinating concept, this fascinating topic, prompt engineering. [33393:25:20] 0: To help you understand why prompt engineering is so important. I'm going to give you an initial example that shows that we tap into really complex capabilities of chatgpt, but you can also do this with other large language models. And the way we tap into these capabilities is by using a pattern, a pattern that we can use when we're writing prompts to. To get into these really interesting abilities of the large language models. Now, if you know these patterns, and we'll talk about them in detail, in this course, you'll be more effective in writing prompts, you'll be able to do things that other people won't be able to do as easily. Now I'm going to give you an example. It's going to use something called the persona pattern. Now I'm not going to go into detail about the persona pattern at this point, but basically it's a pattern that we see all over the place. You'll see lots of different examples of this pattern out there on the internet where people talk about using it to do lots and lots of different things. But the basic idea is, you're going to ask the large language model, in this case, chatgpt, you're going to ask it to act like a particular persona. So now what does that mean? It means like you're going to ask it to act like a person or some inanimate object or an animal or some system. There's all kinds of ways that you can use this. It's really, really interesting, but we're going to use it in this example to tap into a persona that is close to me, but one that I know nothing about the domain. So one of the really useful things about the persona pattern is you can imagine, if you needed to go phone an expert to get help on some problem, you know who you would call, but you don't know exactly what they would tell you or how they would analyze your problem. And so I wanted something where I know an expert that I could go to. In this case, my wife is a speech language pathologist, so I could have her look at the output and tell me how good it was. But I know nothing about being a speech language pathologist or how to do their job. So I imagined that when my son was three, he was not saying things properly, and so I went to chatgpt, and I said, act as a speech language pathologist. I'm going to tell you what a three year old said, and he will write an assessment for you. The child said, I need way one. Now you can imagine this might just me being a parent, hearing it incorrectly. The child's not pronouncing things correctly. I don't know the right way to even capture this, to even express what's being said in words, the right way to do all of this. So this is a complex problem from my perspective, like, I don't know how to express all of this in language, even to ask the question properly. But I know I would go to a speech language pathologist, and I would describe this truth sounded like something my son might have said at that point in time. So what does chatgpt say? Well, you notice, first off, its output looks like a report. It's a subject assessment of a three year old speech sample, child speech sample, I need Wei. Woi has it in quotation marks and it says, assessment based on the provided speech sample. It appears the child may be experiencing some phonological and articulation errors, which are common in children around this age. I don't know what phonological or articulation errors are. I would not have known to ask chatgpt for these things, but based on this pattern that I'm using this persona pattern, I'm tapping into this capability for chatgpt to look at this and know what the right things are to tell me. So it says there's phonological and articulation error. So it says the child's utterance appears to have errors in consonant production of possibly some difficulty with syllable structure. And so it says consonant errors. It seems that the child is having difficulty with the production of some consonant sounds, specifically the in and all sounds the child said need instead of need and why, instead of toy. And then it has in parentheses its assumption. It says assuming the intended words were need and toy, because you can remember my speech sample was I need way, why? When my wife told me it wasn't a very good example. May not be something that a child would actually say. And despite that, it's still figuring out. This is probably what if that's really what the child said, this is probably what they were intending to say. And it's figuring that out. And then it's telling me they're having consonant errors. They're replacing, you know, they're specifically having trouble with n and l sounds. Then it goes on to say syllable structure, the child's production of the word way may indicate some difference. It is possible that the child intended to say play but produce way, which suggests a substitution of the initial consonant, cluster PL, with a single consonant W. This could be an example of a simplification process called cluster reduction. I would not have known how to ask chatgpt to see if there was problem with syllable structure or cluster reduction, but I use this pattern act as [34803:54:40] 0: and I said activist [34815:38:40] 0: and the pathologist announced. That I wouldn't even know how to ask. And then it goes on to say, because, by the way, when I went, you know, whenever you want to do something really unpopular, ask chatgpt to produce an output that looks like it's doing somebody's job. And that'll that's always a way to be very popular. So I did this with my wife one morning, and my wife was not very happy, because she was trying to get ready to get ready to go to work. And here I am saying Chad, TBD is producing things that look like what you produce. And one of her things that she said to me was, if that was a three year old, I'd be telling the parents, they probably don't need to worry. You know, children's speech is continuing to evolve like and I'm paraphrasing what she said. She said it much more elegantly, but she was like, it's just giving you way overblown analysis of this. And I said, Yeah, but Chad CPT says that too at the end, considering the child's age, it is important to remember that some speech sound errors are developmentally appropriate and they resolve on their own with time and of. Course, by that time she was walking out the door, because she really didn't, was it? Was it ready to sit around in the morning and listen to me tell her that chatgpt is doing and what a speech language pathologist does do? I think it's going to take her job. No, but do. So I think it has really vast and powerful capabilities that we can tap into. With the right patterns. Absolutely, I think it gives us the ability to focus on the things that maybe we really want to spend our time on. My wife loves working with kids. She loves interacting with them and trying to understand how to help them writing reports. Maybe, I'm not sure. I'm not going to speak too much from our wife, but I would guess, maybe not her most favorite part of the job. She really loves working with. And so you could imagine something like this, where it allows her to focus more on the things that she really cares about in the real world. You know, maybe it can help her to give form to her thought around the child's needs, and write these reports, and I just hope that you'll see that with a little bit of a right structure in our props, you can create these really powerful ways of giving form To our ideas and our thoughts through large language models. Ni team, the [35479:28:00] 0: basic thing that you're going to need to complete this course is a web browser and access to a large language model like chatgpt. Now you can use a variety of different language models to complete this course, but I'm going to recommend that you use chatgpt, because all of the examples have been tested on chatgpt, and it's also really easy to get started with. All you'll need is a browser, an internet connection and an account with OpenAI. [35596:37:20] 0: Now the way they did that is going to go to chat.openai.com [35619:22:40] 0: as you see in the address bar up here. And so you will go there and you'll be presented with a screen to sign up or log in. Now, if you already have an account on chat, GPT, and you've been using this to write prompts, you can skip this video and go ahead and move ahead. But if you haven't done that yet, this video will kind of give you what you need to get started and understand how you're going to write prompts and interact with chats you can teach. So you'll go to chat.openai.com as seen up in the address bar here, and then you'll want to sign up and box to begin the [35763:44:00] 4: elimination. So rather than go out and pick up a pizza [35783:17:20] 0: delivery job or any other second job or change in her lifestyle, we wanted to give her solutions that patterns or things as well. But we're starting off with sort of the most well known example, which is chat GPT. And more than likely, things are going to only build from here in terms of sophistication and capability of these models. If you know how to use and write prompts and chat GPT, using this interface, you'll be able to write prompts that could then be taken and built into programs or used with some other tool as well. So know this is a great interface for getting started and learning about prompts and how the large language models for expenses [35957:04:00] 4: can go on a credit [35984:32:00] 4: card, that being her electric bill, phones, water, food, gas and car insurance, etc. So anything that can go on a credit [36026:56:00] 0: so what are large language models Exactly? And what do they do? How do they work? Now, I'm not going to go into the full details of this, but I want to give you just enough about how they work that helps you in thinking through designing prompts. So there's a couple things to know about them that will be useful when you're designing prompts. Now, the fundamental thing that you want to know about this large language model is basically what they're doing is they're taking your input and they're trying to generate the next word, and then they'll take that that word that they generate, they'll add it to you, what your original gave it, and they'll try to generate the next word. This is the way to think of it. Now there's a lot more detail than this to think of it basically. Is it trying to generate word by word, the response to your input, whatever your prompt is, trying to generate word by word, the next word that's going to be in the output, until it gets to a point that it thinks it's generated enough, and then the last word is basically going to be the equivalent of salt, but it's going to be it's not going to be something you're going to see. So what it's doing is basically producing words or tokens, basically to respond to your prompt. And so what we're trying to do with large language models is we're trying to produce prompt that's going to cause it word by word to produce an output. Now I want to show you a little bit about this and kind of give you some intuition of it. So if I go and I write, Mary had a little and we stop right there. And if you're familiar with it, the nursery rhymes, Mary had a little lamb. It's fleece as white as snow. And. I'm giving it a prompt. And if I say Mary had a little, it's going in completely. It starts from my last statement, Mary had a little, and it's giving and predicting the next word, which is lamb. Its fleece was white as snow. And everywhere that Mary too went, the lamb was sure to go. It follows her to school one day, which was against the rule. It made the children laugh and play to see a lamb of spirit. And so the teacher turned it out, but still it lingered here, and it goes on and on until it stops. Now you notice what it's doing is it's my prompt triggered. It produced the next word, which was Marietta little with my props. The next word was lamb. If I go and I say, Roses are red, what does chatgpt do? It says violets are blue. Sugar is sweet, and so are you. And it says, This is a classic point. Is often used to express affection or admiration for someone. But the key thing to note is it's doing a next word prediction. I said Roses are red, and it's picking up where I stop and predicting the next word, which is violet, then adding that in and saying, roses are red violets. And it's predicting art, then going back, adding that in and says, roses are red violets art, and it's predicting blue. And it's doing this over and over and so it does really sophisticated, sort of incredible things. But underneath the hood, when it was trained and created, basically what was done was a large portion of the text and other things on the internet were taken and it was taught basically over and over again. It was given a series of words, and it tried to predict the next word, except that it was given, you know, a paragraph of text from the internet, and they would show it part of the text, you know, part of the sentence, and they would ask it to try to predict the next word in the sentence, and when it got it wrong, they would go and tweak the model is what they call these things, large language models. And they're large because they were trained on so much data and they have so many different parameters to them. There are these large language models, and what they're doing is they're basically they've learned patterns from our language, our human language, that was out there on the internet, and they basically learned the idea of given what came before in the text, try to predict the next word. And then if I take that word and I add it back in, try to predict the next word. And so they trained these models to get really good at looking at the context of the information. Now if you think about it, you know, it has a lot of conduct. It's tapping into a pattern that it's seen. I said Mary had a little and it says lamb, you know, it could have been Mary had a little bit of peanut butter on her shirt, you know. But it's learned context, right? And that's part of what makes it work. It could be, Roses are red, daffodils are yellow. But it's learned the context, right? And so that's a part of the piece of this is it pays attention to words and uses that knowledge of the context. It's paying attention to different words that have come before, that are in the current sentence. It's paying attention to their relationships, and it's using that knowledge, that contextual knowledge, to try to predict the next word. And it's taking the word that it produced, putting it back into the output, and trying to produce the next word, the next word, this is the basis of things. Now this will be helpful to know when we start thinking about the patterns of our props, when we think about conversations, when we think about what we can do to tap into this, this fundamental concept of predicting the next word. Now, one of the things to know with these models is they are rapidly, rapidly evolving. We're seeing a lot in the news about chatgpt, but there's lots of competing models that are coming out, and probably by the time you're watching this video, there'll be even more that I'm not going to mention or talk about because they won't. They didn't exist today. Hey, when I started talking about it. So chatgpt is certainly out there. There's a new version GPT, four. There are models like llama. There are variations on llama, like alpaca. There's all kinds of different models that are coming out, and they're rapid, right, rapidly evolving. So more than likely, the discipline of prompt engineering and what you're learning, some parts of this are going to be, hopefully timeless, but some parts of it will probably evolve and adapt as the different capabilities of these models evolve. Now, one of the things you'll want to do is always have that openness to experimentation, to creativity and doing trying things out. Remember, with these tools, we can rapidly prototype, we can rapidly explore things and try things out. And so we want to always tap into that. Now one thing to note is that a lot of times these tools will produce output that is not the same every time. Now it's possible that we could get the same output every time, in certain cases, like roses are red. And now we get something different. And then, if we went in and we did it again, we get something different. Now notice that initially we got something that was what we kind of expected, but each time, we're getting some variation on this, and this is something else that's useful to know, is these models aren't designed to do exactly the same thing every time there is inherent randomness or variation in what they produce. And so this is something you need to know about. When you're using the models, it's really powerful and useful if you use them the right way. If you aren't using the models the right way, or you're trying to fit them in for a task that they're not good for. You're going to have to do a lot of work to deal with this fundamental aspect of it, but it's also an aspect that makes you want to think about this as you know, you should never expect these outputs to be perfect, necessarily on the first try. You know, it's a tool that can help you get an output that you want, but it's not necessarily perfect in the first try. There may be errors, there may be variations, and you need to build that into the processes and the other things that you build around the tool. So if you're going to use it in your business, know that it may not give you exactly the same output every time. Now, there's ways to try to help limit what it does and try to guarantee that, but it's not guaranteed to do that. And so you want to know that, you want to know there's some randomness, there's some variation, which can be great when we're writing, you know, prose with this because we don't get exactly the same text every time, or else we would all have, you know, exactly the same outputs, and we wouldn't be able to explore and try things. So knowing that is an unhelpful, you know thing to realize now, it was chained on a vast amount of data that came from the internet, knowing that its knowledge is based on the time that the training data was collected. So in the case of chatgpt, it's cut off around 2121 [38436:00:00] 0: newer ones have more up to date knowledge bases, but they're always going to be behind in what they were trained on. So they were taught to predict the next word, and they learned from that idea of predicting the next word, and they learned to predict the next word in the context of a lot of different domains, be it speech language pathology or programming, or be it about, you know, creating recipes, whatever it is that their knowledge that they were trained on and the patterns that they learned cut off at some date. And so when we want to introduce and reason or work with new knowledge, we're always going to have to provide that as part of our prompt, as part of our input into conversation. Is that whatever additional information they need in order to reason they're not necessarily continually updating, they can't retrain these things necessarily all the time. Now it may change at some point. The technologies may change, but right now today, know that when you need new additional information that wasn't publicly available on the internet, you're probably going to need to provide it in the prompt. Now those are some of the key things you'll need to know as we go forward in this course in order to help you write more effective prompts. You [38814:18:40] 0: large language models are unlikely, at least if in the near term, to give you an exact and repeatable answer every single time, there's always going to be the possibility they do something a little bit unexpected. And this is by design, and can be a really good thing. Now, a lot of what we're going to be doing in prompt engineering is trying to deal with the fact that large language models have some unpredictability to them, and we want to sort of constrain that unpredictability. We want to mold it and shape it and work with it in a way that's that's helpful to us. Now, what I mean by this is that there's always some randomness, some, you know, ability to generate new and different ideas each time you put a prompt in. And this can be really good sometimes, like if we're writing fiction and we want a lot of different ideas, a lot of different storylines, a lot of different characters. And each time we ask for new data or ask for a new output, we get something completely new and unique, then it's really good. On the other hand, if we're trying to have the large language model do some type of reasoning on a system, we may not want it to have a lot of variation in what it gives us out. For example, if we want a yes or a no answer, we don't want it to say yes some. Times, no sometimes, and then suddenly decide to say, Well, maybe not, because here are these other things that I'd like to tell you about, why it's hard to determine and goes on on this tirade for a paragraph or two about why it can't exactly be given the hand give us the exact answer. Sometimes we just want a yes or a no without any explanation, and we can't always get that easily. So a lot of the prompt engineering techniques are going to be dealing with this. Now I'm going to just show you a quick sample of the randomness, the fact that the same input is not necessarily going to give us exactly the same output every time. And I want you to remember this when we go through this course, because I'm going to show you a lot of different techniques to try to get the large language model to do certain things, and sometimes they're going to work really well, and sometimes they won't work. But what these techniques will typically give you is they will give you something that's more reliable, that works most of the time or a lot of the time, but isn't guaranteed to work every single time. Now this is an important point. We're always going to have some randomness here. We're always going to have some unknown, and we have to accept that and deal with that. So I asked chatgpt, I said, How many birds are outside my house? And it says, As an AI language model, I don't have the capability to perceive the physical world. And it goes on, and then it says, if you're interested in finding out how many birds are outside of your house, you can go outside and observe the area yourself. You might also considering set up a bird feeder. Okay, well, that was an interesting one. Let's see if we ask it again, what it says so now we're going to go and get a different answer out of it says, Well, I can't see what's going outside your house. I don't have access to cameras. I'm. I only do text processing, and then it says, you know, you could go outside and observe the area yourself, or you could set up a camera or other money monitoring device to record, get the number of. Birds, you know, availability of food, shelter and present and so now we've. Gotten something different. You know, what we don't have anymore is this advice to set up a burger. Word feeder. If we went and ran this again, we're probably also. Going to get yet another example. It's probably going to have some similar characteristics. It's still going and saying, Hey, I don't have the ability to do that. It's running some of its things, that sort of standard text that it tells you. But then it's saying, Hey, if you're interested in how you could try observing the area, or to capture images of the area, you can then count the number of birds you see, additionally, you could consider setting up bird feeders or bird baths. So we're getting a similar output each time, but it's not exactly the same output. [39820:05:20] 0: And so this is a fairly constrained [39831:33:20] 0: set of outputs for this question. You know, we're still getting similar type of things each time, but we're not getting exactly the same thing, and that's always going to be an issue for us. So know that when you're developing prompts, a lot of what you're dealing with is the fact that there is variation. Now, if I wanted it to give me an exact number and I was using a prompt like this, this is obviously not going to work, like we're not going to get an exact number of birds outside of my house with this prompt now we might need to be able to go back and give it additional information that can help it decide I [40072:21:20] 0: now we talk a lot about prompt engineering, and we're talking about interaction with large language models, and so let's dive into this word a little bit, because I want to give you a sense of the depth of what A prompt can be. It's more than just a question that you're asking to the large language model. So to do this, I think it's helpful to go through a couple prompts and actually interact with chat GPT to understand the concept of a prompt and sort of the dimensions to a prompt. So I started off here by just asking, chat GP chat, GPT, what is? [40225:52:00] 0: What is the word prompt mean? [40232:32:00] 0: And it comes up with some really helpful, I think, information for us to use when we're talking about prompts. One, it says it's a verb to cause or encourage someone to do something, to spur them to action. And it says, example, the teachers reminder about the upcoming exam, prompted the students to start studying. So part of what a prompt is, it is a call to action to the large language model. It is something that is getting the large language model to start generating output for us, basically, to start generating words that will form the basis of our output. And those words could take all kinds of different formats. It could be software, you know, defining the instructions in a program. It could be the words that we need for that it could be words in a poem. It could be words and many, many different types of things we we could do it as structured data that we need. All of these things are possible, but the key is the prompt is basically our way of getting the large language model to begin to provide some output for us. The second thing it says is, it's an adjective. It's done without delay on time. And this is an important thing to think about with large language models, is we're prompting them right now do this. But this is also a useful point of discussion, because a prompt doesn't necessarily, depending on how you work with it, have to be something that happens right now, prompts can have time associated with them, and now we haven't a little bit of an Illusion of Time, and I'll talk about this later in the course. But when we give props to the large language model like chat GPT, the prompt could affect what's happening right now in my next statement that I give it, or in the current statement, or it could affect something in the future, and this is because of some of the conversational capabilities of these large language models. Now we're going to talk about prompts themselves as conversations later on, but for now, the way to think about it as a prompt doesn't just have to be something that's immediate. It can be but it doesn't have to be. The next thing it says is a prompt can be a noun, a cue or reminder that help someone remember what they were supposed to do or say. Now this is important because we can use prompts to remind the large language model of information or things that it needs to do. And so we may be asking it to do something now we may be asking it something to do in the future, in which case it needs to remember something. So we need to give it a reminder of what it's trying to do. We may need to to go back and, you know, give it a history of the conversation of things that have happened, other things that will help it remember what it's trying to do. And then it can be another noun. A message or screen that appears on a computer or electronic device asking the user for input. So this is kind of a helpful thing, because we can prompt the the large language model to produce things for us. But the the large language model, if we structure things correctly, can actually elicit information from from the user. So the large language model can ask questions to us. So a prompt could both serve as as a call to action or to spur, spurring the large language model to action, or it can actually be an input. It could be asking us for input. So the the last output from the large language model could have been a question for the human, and basically we're then providing information back to it. So props have a lot of different dimensions to them, and if you actually look at the definition of prompt, in fact, the definition that chat GPT gives us, it gives us sort of that nuance to the capabilities of a prop. Now I've gone on a little bit here, and I'm gonna give you an example of this, this time aspect to a prompt, because I think this helps to see the complexity and dimensionality of these, of this, of this concept. I'm gonna say from now on, when I ask a question, suggest a better version of my question, and ask me if I would like to use it. So right here, I'm starting off by saying, from now on, I'm attaching time to my prompt so it's not just immediate and we get a response. Sure. I can do that. However, I will store that. Ask you the original question to the best of my ability, and it goes on to try to reframe this original question, which wasn't what I necessarily needed. But then I say, What color is the sky? Now notice we're done, right? We asked. The original prompt was back here. I said, from now on when I ask a question, and it immediately gave us a response because of that prompt. But now I'm going to ask a follow on question, but the earlier prompt is going to affect this question. So right now, I'm asking in something immediate, what color is the sky, and it responds with a possible better version of the question could be, what is the scientific exclamate explanation for the blue color of the sky during the daytime? Would you like me to use this version instead? And then I say yes. Now notice, here we have a lot of those different dimensions of a prompt that we talked about up here we are creating a prompt that isn't just immediate. It is going to affect us in the future. It's going to continue to influence the output of the large language model. So it is we can't have immediate prompts that right now, right right at this moment do something, but we can also have prompts that span time. And in this case, that's what we're doing. We're creating something from now on. Go and do this now. We're going to have an immediate prompt, which is what color is this guy. We're asking this right now, and now our earlier prompt that we provided that was spanning time is now impacting the way that the large language model responds to our questions. So now what's happening is it's taking our current immediate question, what color is the sky, but it's using the context that we had previously said to suggest better versions of all of our questions, and then ask us if we'd like to use them to generate its output. And its output is, here's a better question, what is the scientific explanation for the blue color of the sky during daytime? And you can see how that really is a better question than my first question. My first question was sort of, they didn't provide enough context, and now it's giving us a more specific question that truly is better, and that's because of this prompt that we attached some time to it we said from now on, and so it's influencing what's said. Now the other thing that we can see is we talked about a prompt being something that can elicit information from the user, and so now we're seeing that the chatgpt, in this case, the large language model, is asking us for information. It's prompting us, it's it's soliciting information, and it's saying, Would you like me to use this version of the question instead? So now we've got that extra dimension of a prompt. It's soliciting information from us, and we say yes, and then it goes and answers the question, and it says, Great to answer your revised question. The blue color of the sky during the daytime is due to a phenomena called Raleigh scattering, a really scattered and I apologize I don't know this term, and I'm actually learning something from chatgpt As I read this, the Earth's atmosphere is composed of various gasses and particles that scatter sunlight in all directions. Blue light has a shorter wavelength and higher frequency than other colors. Which causes it to scatter more easily in the atmosphere. The results, this results in the blue color that we see when we look at the sky in a clear day. Now we've seen a lot of different dimensions to prompts through this short interaction. We've seen creating time prompts that span longer. We then see an immediate prompted spurring the large language model to action. We see the concept of the large language model prompting and getting input from us, and then we see the output of all of this. Now, one of the things to note is we also talked about memory, that the prop that the the prompt had a source of concept of sort of memory to it, and we'll talk about how this works in the future, but right here, I [42488:58:40] 0: say from now on, when [42494:50:40] 0: I ask a question that's something that. The large language model has to remember in the future interactions, and we'll see how it actually does this. And so then, when. I say, What color is the sky? It's remembering that I said, Whenever ask a question, ask a better version of a question, and then it's responding right here with the better version of the question. And then, if I go and I do this again, we'll see that it still remembers my original statement, that it need to suggest better versions of of my question. So I said, How many countries are there in the world? And it says, a better version of your question would be, what is the current estimated number of countries in the world, and how is a country defined? Would you like me to use this version instead? And then I say, Yes. And then says, Great as of my knowledge cut off in September 2021 [42725:14:40] 0: there were 195 [42737:36:00] 0: recognized sovereign states or countries in the world. However, this number may vary depending on how a country is defined. The United Nations, for example, has 193 member states, while other organizations and countries may recognize different numbers. Generally, a country is defined as a sovereign state with its own government, territory and international recognition. Now, one other interesting thing that we talked about is that a prompt, you know, has some memory associated with it, and this also shows us some of the limitations that the the large language models knowledge cuts off in September 2021 so one of the other things that we may need to do for the large language model is we may need to remind it of what has happened since it was finished being trained, and we can use a prompt to provide information to the large language model like chatgpt About what happened after it was trained. So we can also use it to provide information that the large language model didn't have access to it was trained, like our own private information or other things. Now, of course, you have to be cognizant that when you're using chat, GPT, or many of these other tools, you're actually sending information to their servers. So you do want to make sure that that is something that you're willing to do before doing this. But if you're using a large language model locally on your machine, or you're willing to send the information, you can provide information that it doesn't have access to in order to reason about. So prompt can also be about providing information to one of these language models. So if we look at this example, we say, what was Vanderbilt University's acceptance rate in 2020 it should have access to that, and so it provides this information. It says the acceptance rate was 9.6% if we say, what was Vanderbilt University's acceptance [43274:40:00] 0: rate in 2022 [43296:32:00] 0: it'll say, I'm sorry, but doesn't have access to that information because it was cut off in 2021 if we then provided that information. So here I'm cutting and pasting the admissions data that was released and published by Vanderbilt just a few days ago. So clearly, didn't have access to this by now. Provide this to it in a prompt. Then it says, based on the information you provided, it appears, the Vanderbilt University's acceptance rate for the regular decision applicants of the class of 2026 was 4.7% so a prompt can also serve as a way of providing new and updated information to the Large language model like we saw in this example. [43532:42:40] 0: I Let's talk intuitively about what a pattern what a prompt is doing, and how the patterns in the prompt sort of tap into the capabilities of a large language model. Sort of, I think looking at some examples will help to give you a sense of how your prompts are really affecting and eliciting different behaviors from the underlying large language model that you're interacting with. So let's take a look at this example. I want to start off by talking about Pattern. Pattern is really important. Remember, as we talked about large language models are trained to basically predict the next word, they're constantly trying to predict the next word based on what came before. So you give it a sentence, and it's trying to predict the next word, and then it's taking that and adding it and trying to predict the next word, and over and over and over. And so it was train a large pieces of the internet trying to predict the next sentence. So one of the things that it's learning to do is to recognize patterns that tell it what the next word should be. That's basically what it's doing. Now this is a really simple example of this concept. I'm going to tell chatgpt complete this story, and I start with Mary. A little, and I stop. Now, if you know the nursery rhyme, it's Mary Had a Little Lamb. Its fleece was white as snow, and you can imagine that this story showed up over and over and over and over in the data that chat GPT was trained on. So when I say Mary had a little that is a very powerful pattern that chat GPT has seen many, many, many times, and so it immediately tries to pick up with lamb, its fleece as white as snow. And everywhere that Mary went, the lamb was sure to go. So that pattern was seen so many times that chat GPT, when I put in the first part of it, it immediately responds with the next part of the sentence. It knows where to pick up. So one thing we have to think about is, if we know the right patterns, if we can tap into things that the model has been trained on and seen over and over and over again, will be more likely to to not only get a consistent response, so we're going to consistently get a particular completion of Mary had a little because it's been seen so many times in the training data, or get more consistency, but we're also going to more likely get a particular sort of ability to tap into it, to unlock it like if we want a particular behavior, we want to have the right pattern that we're tapping into. Now, let's look at what happens if we change the pattern a bit. And so I say, rather than, you know, Mary had a little, I say, complete this story, a girl named Mary had a microscopic Now, this isn't the pattern that it was trained on right, and it's and it says a girl named Mary had a microscopic friend named Max. Max was so small you could only see him through a microscope. Despite his size, he had a big personality and was always eager to go on adventures with Mary. One day, Mary decided to take max on a trip to the local pond. You know, now, one of the interesting things is you can imagine that when you start talking about microscopic that, like you can think about, there's probably descriptions of going to a pond and doing, you know, science with a class of students. I mean, I almost have a vision of it, reading stories about students getting samples of pond water and looking at them under a microscope. But the important thing is, you notice that [44546:18:40] 0: Mary had a little [44552:58:40] 0: created a very, very specific response, whereas a girl named Mary had a microscopic creates a much different response. And then if we go and rerun this, we get something completely different, pet name Max. Max was a tiny creature that little small group. And [44629:52:00] 0: so, you know, this pattern isn't [44641:52:00] 0: as strong. There are words in this, this pattern that are strong and sort of give context to help to shape the story, [44688:05:20] 0: but the pattern itself is not as strong as doing it [44711:01:20] 2: again completely. I'm [44727:01:20] 0: still getting the same completion with [44745:09:20] 0: this. I'm still getting white snow, so every time I'm getting a very consistent response. To this pattern. So one of the things to think about when you're writing a pattern or writing a prompt is, what patterns do I have in my prompt, and what patterns will these will that probably tap into if the large language model was trained on? Now, if there's a very strong pattern and prompt, you're more likely to get a response to that pattern. On the other hand, if that's not a pattern that it was trained on, it's not as clear, then you're going to have other things that are going to matter, like specific work is going to fundamentally that word is fundamentally going to change the behavior of this prompt because it's such a strong word, London area is sort of generic. There were probably lots of stories, but microscopic, it has all of this feeling and implications to it, and that's going to then influence the large language models out, but specific words alone, because of the patterns around those words, like microscopic has always been talked about in the context of small things, probably, or maybe [45091:06:40] 0: in terms of things like, in this case, like a small creature [45105:14:40] 0: that lived in a glass jar that made itself have a [45135:44:00] 0: strong sort of pattern of other words that are being around it, but it's not as strong as the pattern Mary had a ripple. Now, one thing to note is that when you're writing poems, you want to be really specific, or you want to be you want to provide. Enough detail in your words that it will the large language, not model, will know the right level of detail to put into the output. So if your words are very generic and high level, then you're more likely to get an output it is also generic and high level. So if you look at this example, and I get a very generic sort of response. It's a private research university located in Nashville, Tennessee, founded in 1873 by Cornelius Vanderbilt. You know, ranking other things I