Master Prompt Engineering for Generative AI with ChatGPT | Idan Gabrieli | Skillshare
Search

Playback Speed


1.0x


  • 0.5x
  • 0.75x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 1.75x
  • 2x

Master Prompt Engineering for Generative AI with ChatGPT

teacher avatar Idan Gabrieli, Online Teacher | Cloud, Data, AI

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

    • 1.

      S01L01 Welcome

      2:05

    • 2.

      S02L01 - A Framework for Building Prompts

      1:22

    • 3.

      S02L02 Instruction

      7:27

    • 4.

      S02L03 #2 - Context

      3:56

    • 5.

      S02L04 #3 - Examples

      4:55

    • 6.

      S02L05 #4 - Persona

      2:57

    • 7.

      S02L06 #5 - Format

      2:55

    • 8.

      S02L07 #6 - Tone

      2:14

    • 9.

      S02L08 A Couple of Tips

      3:24

    • 10.

      S02L09 Summary

      3:11

    • 11.

      S03L01 - Prompt Engineering Methods

      1:29

    • 12.

      S03L02 #1 Splitting Complex Tasks

      6:01

    • 13.

      S03L03 #2 Sharing the Reasoning Steps

      3:54

    • 14.

      S03L04 #3 Using Interactive Prompts

    • 15.

      S03L05 #4 Generating Knowledge

      4:06

    • 16.

      S03L06 #5 Adding External Knowledge

      5:02

    • 17.

      S03L07 Summary

      3:14

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

16

Students

--

Projects

About This Class

Unleash the Power of Generative AI

In today's fast-paced AI landscape, the ability to interact seamlessly with AI systems has become a game-changing skill. Mastering prompt engineering is key—it’s the vital connection between human creativity and artificial intelligence, allowing us to guide AI systems to deliver precise, relevant, and impactful results. With advanced models like ChatGPT and Google Gemini processing vast amounts of data, the quality of their output hinges on how effectively we shape our prompts.

This interactive course is designed to give you hands-on experience in crafting powerful prompts that unlock the full potential of large language models (LLMs).

A Proven, Simple Framework

Discover a streamlined yet robust framework for building highly effective prompts. Our approach focuses on six core elements: instruction, context, examples, persona, format, and tone. These building blocks will enable you to structure prompts that get the most from AI.

Real-World, Practical Techniques

In the second part of the course, we'll dive into the most effective prompt engineering techniques, tailored to help you solve complex challenges and execute advanced tasks with AI.

Join the Generative AI Movement

Are you ready to be part of this AI-driven transformation? Join me in exploring the limitless possibilities of Generative AI and learn how to harness its power to your advantage.

Meet Your Teacher

Teacher Profile Image

Idan Gabrieli

Online Teacher | Cloud, Data, AI

Teacher
Level: Beginner

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. S01L01 Welcome: Hi, and welcome to this training about pumped Engineering for generative AI. My name is Ian and I will be a teacher. It is becoming very clear that GAI is everywhere. It's a huge technological disruptive wave that is reshaping many industries. It's a big wave, and many things are going to change. Services like HAGPT and Google Gymini are becoming embedded in the daily work and workflows of many jobs. Now, to be able to successfully serve on that wave and maximize the potential of using GAI for different use cases, it is important to be able to effectively communicate with large language models or in short LLMs. We need to be able to think, structure, and optimize our requirements using a text pumped. That's the essence of pumped optimization, also called pumped engineering. It is the art of asking the right questions to get the best output from an LLM. It is useful for anyone that is using a service like hachPT with a web interface or indirectly using APIs as part of a larger integration project. In this training, we are going to establish a simple framework for building highly effective prompts and then review the most popular prompt engineering methods. I will do my best to keep it simple, fun and interesting. Thanks for watching and I hope to see you inside. H 2. S02L01 - A Framework for Building Prompts: Hi, and welcome. Large language models are the core building block of generative AI solutions. They added the amazing capabilities to digest text as human language. The input is called pumped and the output is called response. Pumped engineering is the art and science of asking the right question to get the best output from an LLM. It's all about optimizing the input prompt to handle a specific task. In this section, we will explore a simple framework for building much more effective prompts. This framework has six building blocks, instruction, context, examples, persona, format, and tone. Each one of them will contribute something to the overall pumped structure. We can use a single or multiple building blocks based on the required output. Last thing to consider is that learning how to optimize prompts, it's like a muscule in our body. We need to invest some time to develop that muscle by consistently practicing and trying different things. After a couple of weeks using this framework, it will be embedded in our daily work. All right, let's start with the first building block. See you next. 3. S02L02 Instruction: Hi and welcome. The first component or building block of a prompt is the task itself, also called instruction. This is the core directive of the prompt. It is telling the model what we want to do. That's the most important building block. Now, unfortunately, the model cannot read our mind and guess what we are looking for. Maybe that's going to change in the future when we establish a direct link between computers to our brain. Until then, the required instruction must be articulated as clear as possible. The less the model must guess, the more likely we will get what we're looking for. Therefore, the definition and overall scope of the instruction should be very clear. I think the best way to understand this concept is to review practical examples. For the demonstration, I'm planning to use services like hachPT and Google Gemini. You can pick whatever you want. The first example is about simple Tweet classification. I would like to provide a text from a tweet and get the sentiment of the text. Inside ChargPTPmpt I'm writing, you will be provided with a tweet about a movie and your task is to classify the sentiment as positive, natural, or negative. The tweet itself is, I love the new Batman movie, even though it's quite scary. That's the text I would like to classify. So what we have here? I clearly articulated the required task, classify a short text, which is a tweet with specific categories. I'm providing the categories, meaning positive, natural, or negative. Everything is clear, including the objective of the task. The model will use its own knowledge to understand the text and then classify the best matching sentiment. Next example is related to content generation, which is a very common and practical use cases of GNAI. In that case, the prompt can be generate a blog title for an article about the effectiveness of dip plans. I'm starting the definition of the task by using an action verb like generate, write, explain, analyze, classify, et cetera. The action verb is an important element as part of the instruction. Then I'm trying to articulate my end goal, which is a title for a blog article related to a specific topic. I got one suggestion, one title, let's tune it a little bit. Generate ten block titles for an article about the effectiveness of diet plans. In this prompt, I added a specific scope, meaning ten titles. I can see that some of them are a bit long and others are phrased as a question structure. Let's adjust it a mode to better define the required task. Generate ten block titles for an article about the effectiveness of diet plans. A title must have maximum of ten words and without using a question structure. As you can see, I added scope and boundaries for the specific output that I'm looking for, like maximum of ten words and without using a question structure. In many cases, it is important to limit and frame the required output. Moving next, write a blog post about the effectiveness of diet plans. Writing a complete post is a much more complex task, right? This task definition is too generic and therefore we get generic content. We must better define the requirements of the task and set some boundaries that can help frame and guide the model towards the desired output. What about this one? Write a blog post about the effectiveness of diet plans. The article should be broken into four main sections. Each section should explore a different aspect of the topic and will be limited to one page while providing scientific evidence and practical tips for increasing the effectiveness of diet plans. Include a brief introduction to set the context and a conclusion summarizing the key points. Now we are getting a block content that is more optimized to our specific requirements, including information about the length of each section, the overall structure, and what kind of content to include like scientific evidence, practical tips, et cetera. Next example is to generate lesson plan for a specific topic. Write a short lesson plan for introduction to statistics. The lesson plan should cover topics such as types of data, descriptive statistics and probability basis. Come up with some examples that show common students ero. We have an action verb, which is right. The end goal is to create a lesson plan about statistics, and we are providing the required scope. Moving next, in this example, I would like to extract keywods from a text using GenaI as a reasoning engine. The prompt is going to be, you will be provided with a text and your task is to extract a list of top ten keods. Here is a text about the probability. Let's see the identified keywords. Please note that this time we are providing the knowledge about the topic and the LLM is used as a reasoning engine to identify keywords in the text we are providing. Let's see a little bit more complex pumped that is a multitask request. The pump is going to be the following. Analyze the following list of users feedback about an online game. Classify each feedback as positive, negative or natural. Summarize two takeaways from each feedback. Categorize which department should get the feedback, product support, marketing sales, and finally present it on a table. Here is the list of users feedback. As you can see, it's a couple of different sequential tasks related to the feedback raw data. We are asking to classify, summarize, and then categorize. The output is an organized table with four columns, the feedback, classification, takeaways, and the target department. A nice example showing the power of GEI while handling more complex tasks. All right, that's our first core building block of any prompt. We must clearly define the required instruction. Let's move on to the next one. 4. S02L03 #2 - Context: Hi, and welcome back. The second and highly important building block of a prompt is the context. The context provides the necessary background information or environment that helps clarify the intent and scope of the request. If someone says to me over the phone, it is cold without providing any context, I will have some trouble understanding if he is talking about the weather, a room temperature, a drink in his hands, or even someone behavior. If I know that it's standing outside on a winter morning, the statement makes perfect sense, right? In everyday life, context is highly important because it shapes our understanding of the situations, conversations, actions around us. It can be the tone of conversation that we can hear, the historical background of a situation, or the details surrounding an event. Context fills the gaps and help us to visualize the complete picture. This concept is 100%, the same when asking a GAI model to perform a specific task. By providing relevant background information, we can help the AI understand the context of our request leading to more optimized and accurate responses. Let's review a couple of examples. Generate a tutorial for beginners to build a simple chair from wood. The task is about generating a tutorial about building a chair. The context here is the target audience, meaning specifying who is going to use that information. Next example, generate a totoyal for building a chair from wood, including a list of materials like wood, screws and tools such as a table saw, power sender and drill. The context is now about the required materials and tools, mentioning the specific materials and tools needed for the project. Generate a tutorial for building a simple wooden chair that takes about 3 hours, and it's suitable for Novice woodworkers. The context now is about the skills level and require time to complete the project. One of the main challenges related to context is about the level of details. How much context information should we add to a pumpt. That's a great question. To tackle this one, we need to think about what is just enough information that is needed to understand the required task and to narrow down the number of possibilities. It is useful to use a layered approach, built the context in layers. Begin with high level context and then add more details as needed. The first layer is the must have information. We should start with the most essential information directly relevant to the task, problem or question. This typically means mentioning the assumptions, configurations, tools, framework or features that play a critical role in achieving the goal. We should focus on things that are unique to our situation or could potentially influence the solution in a non standard way. Next layer is the nice to have information. That's specific details that could affect the solution but are not critical. Try to avoid repeating information that we're already provided because it can confuse the model. Alright, that's the best way to make sure we provide just enough context information in our bompts. Let's move to the next building block. 5. S02L04 #3 - Examples: Hi, and welcome back. So far, we have covered the instruction and context building blocks, which are core elements of almost any prompt. Describe the required task and provide just enough background around it. The model is taking our prompt, analyze it, and based on the model's existing knowledge, it will generate response. However, there are cases where the pre trained model knowledge is not enough. The output we are getting is too generic and it's not fulfilling our requirements. The model is not fully tuned to handle our specific request, or it is hard to explain using a text pump what we need to achieve. The solution for those challenges is to use examples as part of the prompt. There are cases where it will be easier to show the model what we mean using examples. This method is called few shot pumpting. It is the practice of passing a pump coupled with one or more examples, also called shots to show the model how to response for a specific task. An example is basically a pair of input and output. We can provide one example or multiple examples. By looking on those examples, the model can learn to follow new patterns. The assumption is that the model will be able to extract the relevant patterns from those examples that we are providing and use them to generate the response. Let's see a couple of demonstrations. So the first example, write a funny poem about a cat, for example, and then I'm providing some example of such a text. There once was a cat with a mighty roar who thought it was king but slept on the floor and so on. That's an example of a specific style. Now, what will happen is that the model we use this example and extract the patterns from it. So the example provide a specific poetic style and theme, guiding the model to generate a new text that is more aligned with the required style. Moving next, write a formal letter of complaint about a low quality new kids bike while complaining about the loose pedal, unbalanced front wheel and weak brakes. Use the following example. And then I'm providing a specific structure, their company name. I'm writing to express my deepest dissatisfaction with the recent purchase of product. The quality of the product is not aligned with the described product description and expected quality from the company, I would like to get a full refund. The example establish a specific structure for the letter, helping the model to generate a response that is appropriate to the context. Next example, generate a list of strategies about online marketing of a new online course using the following structure. Avoid details for each one. The structure is the following. Strategy number one, content marketing, priority high cost low. And I'm providing another example inside strategy number two, social media marketing, priority medium, cost high. I didn't explain the required structure. I just provided examples. The model will evaluate the structure of those two examples, identify the patterns, and generate the complete list of relevant strategies using the same structure. I have a couple of tips related to examples. How many examples are needed? Well, most probably two up to five well chosen examples are sufficient to guide the model. Again, it's a case by case situation. Diversity, use a variety of examples that cover different scenarios. If you have some edge cases, take them into account. Relevant to the task, we need to make sure that the examples are directly related to the task. We want the model to perform. And lastly, it is important to use a consistent format for all examples. This helps the model recognize the patterns that is needed to follow. Alright, that's about using examples, moving to the next building block. 6. S02L05 #4 - Persona: Hi, welcome back. The next useful component in a Pompt is the persona. A persona is a fictional character that we think will be the perfect match to answer or fulfill the requirements of a specific pompt. I'm sure you have one or more friends that can imitate famous people, imitate their voice, facial expression, behavior style, and more. It is funny, but at the same time, it is amazing to see that their performance influence how we perceive the data. It is adding context to the situation. We can do the same with prompts. We can ask the model to answer a specific prompt while playing a specific character or identity. It can be very useful in different cases. Let's see a few examples. You are a hiring manager at Google. Create a job description of data analyst. As you can see, the output is structured from the perspective of a hiring manager at Google. The model has comprehensive knowledge about how hiring managers from Google will structure their job description. It is also having knowledge about the most relevant requirements to hire a data analyst. All we need to do is to define the persona. Next example, let's assume I would like to create a light, funny explanation about the future of generative AI. In that case, the persona will be a funny teacher. The prompt will be, you are a funny teacher, explain the future of generative AI in one paragraph. Moving next, as a creative artist, how would you use technology to enhance your work and showcase your portfolio to a wider audience? The persona is a creative artist. The model will try to generate a response from the perspective of such persona. And the last one, you are a student struggling to balance your studies, activities and social life. How could technology help you stay organized, manage your time effectively, and reduce stress? The persona is a student. Using a persona, we can better tailor the content to resonate with our target audience. It can also direct the model to respond in specific expected behavior like being more polite, more formal, or the other way around. By adding a persona into prompts, we can create more effective and engaging content that will drive better results. 7. S02L06 #5 - Format: Hi and welcome back. The next component in a prompt is about the expected structure and format of the required output. We can define the desired format and ensure that the response follow a specific structure. This is highly useful for many things. Let's mention a couple of very popular formats that we can use. So the first one, list five benefits of learning math in bullet points. The required format is a list of items in bullet points. Next one, provide a step by step guide for setting up a WordPress blog. Here, I'm asking to get a step by step format. Create a table of the top popular science fiction movies over the last 20 years. The table columns will be here movie title director and IMDB rating. In this case, the required format is a table with specific headers, specific columns. That's very useful structure for organizing information. Write a short dialogue between a customer and a support agent resolving a billing issue. The output is like a PingPong dialogue session. Provide five Q&As about the benefits of electric cars. The required format is a question and an answer. I can take it even one step further and ask to generate five different possible answers for each question. Provide a JavaScript code, snip it that reverse string. By providing the programming language, I'm asking for specific format that aligned with Javascript. Create a checklist for pecking items for a weekend trip. The next one is highly useful for many use cases. Provide an outline for a report on renewable energy sources. Asking for an outline is a great tool to brainstorm ideas for a list of subtopics related to a main topic. We will use it many times. I'm using that for many use cases. The last example is about Imoges, it's going to be the following. You will be provided with text and your task is to translate it into Imoges. Do not use any regular text. Do your best with emojis only. The text will be artificial intelligence is a technology with great promise. We're getting a funny sequence of images related to that text. Probably there are people that can easily translate that back to text. All right. That's about format and structure. Let's move to the last building block. 8. S02L07 #6 - Tone: Hi, and welcome back. The last optional building block in a prompt is setting the right tone. This option can help to guide the response style, whether it should be formal, casual, informative, persuasive, or creative. By setting a specific tone, we can enhance and tune the generated content to our audience and make it more enjoyable experience. If they're expecting to get informal, casual response, then it is more likely that structuring the generated content in a more friendly way will make it more effective. Let's see a couple of examples. Please provide a detailed explanation of key benefits of generative AI. That's a formal tone inside the pumped itself, and it will be reflected in the generated content. That's a long list of items we are getting. Each one is based on a very structured and detailed format. Let's try something less formal. Hey, could you tell me a bit about the key benefits of generative AI? As you can see, it's a more light version because the model is trying to understand the overall required tone from the text itself. On the other end, we can specifically mention what we are looking for. So for example, I can say, create an engaging and fun post about the key benefits of prompt engineering for AI content creation. By adding the words engaging and fun, we're setting the required tone to be more friendly and relaxed. And the last example, review the provided text, fix the grammar mistakes, and make it more formal. Bold all changes that are being made, and here I have some text with some arrow. The text will be fixed and the model will adjust it to be more formal, because this is what we required to get. That's about the tone building block we can use inside the prompt. 9. S02L08 A Couple of Tips: Hi, and welcome back. We have the complete list of building blocks for prompt. It is like a simple formula, prompt, equal, and then the sixth component, instruction, context, examples, persona, format, and tone. The first two building blocks, instruction and context must be included in the prompt, and all others are optional based on a specific use case. Now I would like to review a couple of useful tips. The first one is combining the relevant building blocks. Sometimes we need to use just the instruction with context and in other cases, the full list of building blocks. As a pre step before building a prompt, consider for a minute which building blocks are needed. Do I need to set up a specific persona? Do I need to specify the required format? Do I need to provide a couple of examples? What should be just enough context for that specific task? Those questions will help you to frame and consider your strategy and generate more effective points. The next tip is to iterate and refine. Don't try to make it a perfect prompt when you are just starting to build your skills. It is taking time and a lot of practice to make it highly effective prompt on the first pumped. Therefore, consider starting with a more generic prompt and gradually refine it based on the model response, like a ping pong session. If the initial response doesn't meet your needs, that's okay. Rephrase your pumped and add more details. Change the mix of building blocks, refine the pumped until you get it. Another useful tip is to snooze the response. Sometimes you want to break the process into two steps. In step number one, provide a list of rules or requirements to the model and avoid getting any response. You don't want to get any response. In step number two, provide a sequence of inputs, and for each input, you want the model to apply those rules that you already provided in the first prompt. It's like snoozing the response. How can we do it? Well, we can achieve that by adding at the end of the pumped a request to ask us for the next input. It is forcing the model to wait for our next pump. Let's see a simple example. The pumped will be, I'm going to provide a block of code check the code syntax for errors and optimize the code. Ask me for the code. That's the added request that I'm putting at the end of the prompt. Now, the LLMs is basically snoozed until it's waiting for my next pmt. Now I will copy paste the code itself. It will, of course, generate a new code based on a list of recommendations. That's about snoozing the LLM response. In the next lecture, let's summarize everything. 10. S02L09 Summary: Hi, and welcome back. Thanks for watching so far. In this section, we managed to review the simple framework to build effective prompts. I would like to quickly review those topics. Instruction is the first core building block. We need to be clear and specific. Start with a direct action verb like generate, analyze, classify and clearly states what you want. What is your end goal. In addition, it is important to limit and frame the required output by defining the scope. Context is the next essential building block of almost any prompt. We need to provide just enough relevant background information to frame the response. When providing the context, consider must have and nice to have information. Try to provide it in layers, starting from browser information, and if more specifics are necessary, add them step by step. Examples are a great way to teach a model about new patterns to follow. The model can extract patterns related to expected structure and style while generating the response. We can provide one example or multiple examples. Make sure that the structure of the examples is consistent. It will be easier job for the model to understand the required patterns. Adding a persona is a nice way to ask the model to play a specific role and better tailor the content to resonate with our target audience. We can create more effective and engaging content. Defining the desired format to ensure that the response follow a specific structure. This is highly useful for many things, and they are very practical formats such as bullet points, step by step guide, a table with specific header, a short dialogue, a question and answer, and more. And the last building block is setting the right tone. We can enhance and tune the generated content and make it more enjoyable experience. Tuning the response style to be formal, casual, informative, persuasive, or creative. I also mentioned a couple of useful tips in the previous lecture. When building a prompt, try to consider the best mix of building blocks as part of the input prompt. I assume that around 70 to 80% of all use cases that you will experience can be handled very nicely using this simple framework. Now, as you will gain more and more experience, eventually, you will want to take it to the next level while using additional methods, handling the interesting layer of the 20%, handling more complex situation, more complex projects. That's what we are going to do in the next section. Thanks for watching and see you again. 11. S03L01 - Prompt Engineering Methods: Hi, welcome back. If you just started to use tools like ChaGPT or Google Gemini, most probably the prompt engineering framework, we learned in the previous section will be more than enough. You will need to get used to it by practicing and using it more and more as part of your daily workflow. Eventually, this framework will be embedded without even thinking about it. Now, sooner or later, you will start to use those tools for more complex tasks. It is part of the learning journey while exploring new options. For example, when I started to use tools like HGPT for code development, I eventually found myself trying to push the boundaries of those tools and in some cases, not using them correctly or efficiently or not considering their limitations. Therefore, as part of the goinging market experience with pumped engineering, additional methods were created to handle more complex situations. That's the topic of this section. We are going to review the top practical pumped engineering methods. Maybe you will not use them on day one, but as I said, sooner or later, one of them will be useful for a future project you will handle. All right. Let's start. 12. S03L02 #1 Splitting Complex Tasks: I think this lecture is probably the most important one in this section, and that's why it is the first one. Let me emphasize something. Most GAI solutions will not be able to digest, understand, and generate good responses for a very complex task. LLMs can only take in a limited amount of information at one time. Any model will have limitations on the input prompt size, the output size, and how much it can remember in a long conversation. Eventually, those models will get better and stronger, but there will be always some limitation. Now, what is the meaning complex task? If I will ask a service like Chachi PT to summarize a book of ten pages, it will be just fine. However, if I will try to inject a textbook with 1,000 pages, it may hit a limitation. It is too complex and too long to digest. I need to break and split the size of the input to smaller pieces and then feed each piece to dedicated prompt. I took a complex input and split it down into smaller pieces. The same is true for the actual task itself. If the task is highly complex, then it makes sense to break it into smaller pieces. Let's take an example from the software engineering domain, even if you are not a software developer. It's just as an example. A typical software application is a combination of multiple modules, components, and layers. All those elements are integrated to establish a variety of end to end workflows inside that software application. If I will try to use a GII solution to generate a complete software application, I will need hundreds or maybe thousands of text lines to describe the full requirements and features of that application. It's a very complex task. Now, at least today, it doesn't make sense to expect that level of sophistication from AI system. Most probably, I will get half baked generic output with many arrows that will reduce my productivity instead of helping me to speed up things. Secondly, many GAI solution like HGPT will have limitations on the prompt input and output based on pricing models. More premium services will have less limitation, of course. How can we overcome those limitations? Well, by splitting a big piece to smaller pieces, taking a complex task and consider how we can break it down to a list of sub tasks. Then we'll take each sub task and fit it into a dedicated prompt, get the output, and move to the next sub task, working in a sequence of steps. The advantage of this approach is to keep the focus of each prompt on a task with limited scope and eventually get much better out. Let's take an example. Assuming I would like to develop a customer support chatbot using Chachi PTAPI for an ecommerce website. Sounds scary, but it is just an example to illustrate the concept. Instead of putting that complex project in a single prompt as a one big task, I'm splitting it into smaller components like mini projects. By the way, if you are not sure how to break your project into smaller sub tasks, ask that specific question using a prompt. It's like creating an outline for your project. It will provide you with some directions, and then you can adapt it to your project. Going back to our example, here is a list of mini projects that are related to that high level task, and for each one of them a dedicated prompt. The first pompt is about setting the required development environment. So the pumpt can be, how do I set up a development environment for building a HGPT based chat boat, including installing necessary libraries and framework. Next pumpt will be about using the HAGPTAPI. How can I integrate the Open API chatbat into my application to handle conversation? Then a prompt about the interface for that application. How do I build a user friendly chat interface using HML, CSS, and JavaScript? And more, it is breaking a complex project into smaller pieces. In some cases, we can even continue to break each individual mini project to even smaller pieces. So the scope of each prompt will be let's take another example. Assuming I'm planning to launch a new ecommerce website, and I need a marketing campaign. Most cases, marketing a new website can be a very complex project that involves many things, many steps. It is a great example how to divide it to multiple sub task and each one will have its own prompt. For example, the first step or mini project is to identify the target audience and create bio personas. That's the first prompt. Next, will be about developing a unique value proposition to differentiate the new website, et cetera. I think you got my point. That's about splitting complex task. Let's move on to the next method. 13. S03L03 #2 Sharing the Reasoning Steps: Hi, and welcome back. Do you remember filling a math exam at high school? I guess you have, even if it was a long time ago. One option is to provide the final answer to a question like the answer is 256. Another option is to show the steps leading to that answer. Many teachers will say, show me your ticking pauses as part of the answer and not just the final answer. So even if the answer is wrong, maybe you can get some points by showing me the steps used to get that solution. It's like asking, show me your reasoning pauses. In addition, when we solve a problem in small steps, the chance of making mistakes is lower than just quickly providing the final answer. You will be surprised that it's also applicable for GAI system. This approach of going through the thinking process as steps can be useful also as a prompt engineering method. Sell out to chain of thought prompting. When using a chain of thought prompting, the main goal is to encourage the model to share the reasoning steps, articulate its thought process in a logical sequential manner, like a step by step reasoning. As part of the prompt, we will directly ask to show us the thinking process, generate a chain of thought. So inside the prompt, we can ask describe your reasoning step by step. Walk me through a step by step process. Getting a large language model to explain its reasoning behind something actually can make the model perform better. It will increase the chance to get better results and secondly, will help us to see the reasoning behind the answer, providing not just the final answer of what we would like to get, but also the intermediate steps to reach that answer. It is making the process more transparent. Let's see a few examples. Alice left a glass of water outside overnight when the temperature was below freezing. The next morning, she found the glass cracked. Explain step by step why the glass cracked. The model will generate a sequence of events that eventually reached the final outcome. Let's look on another example. A classroom has two blue chairs for every three red chairs. If there are total of 30 chairs in the classroom, how many blue chairs are there? Describe your reasoning step by step. Again, we are asking that specifically from the model as part of the pumped. Now, we can take another step forward. Instead of just asking as part of the pumped to explain the reasoning process step by step, we can specifically ask the GEI model to follow a list of predefined steps according to our requirements. Let's see an example. So the problem can be how climate changes influence the sea level rise. Use the following steps to explain it. So step number one, greenhouse gas emissions. Step number two, melting of ice in polar regions, step number three, thermal expansion of seawater. Okay? So we are providing the steps that the model will follow. That's about asking the model to share the reasoning process or defining for the model, the thinking process and steps. Let's move to the next method. 14. S03L04 #3 Using Interactive Prompts: We just talked about the chain of thought prompting method where we ask the model to describe the reasoning process that it is using to get the output as a step by step structure. We can even enhance it by providing L required steps that the model must follow. In any case, the input is a single prompt where we ask the model to do something, and the output is a sequence of steps like a chain of thought. Step number one, step number two, et cetera. Our next method called pumped chaining, has a very similar name while using the same word chaining, but it is used for completely different use cases. Pumped chaining is all about dynamic iteration and interactivity while using a sequence of pumps. It's like talking with a good friend about some topic and developing ides around it in a step by step approach while taking the output of the last pump and using it to refine or adjust the next input pompt creating a chain of related text. That's the name prompt chaining, which is creating an interactive list of prompts. It is a great method for generating more creative content, brainstorming ideas and exploring selected ideas in different directions. Let's use a simple straightforward example of prompt chaining, using the task of planning a birthday party. That's the main task. So as a first step, I'm asking for IDs. Generate a list of ideas for a birthday party theme for 6-years-old boy. I'm getting a response with a list of themes. After reviewing that list, I decided to go with the superheroes team. By the way, I have a kid on that age, so I'm pretty sure it is the right direction. Next, I'm using this selected theme and asking for ideas about creating the party invitation. So it will be the following. I will go with the superheroes team. What should I include in the party invitation? Next, asking the guest to come dressed up as your favorite superhero is a great idea. What are top five fun games or activities for this team? As you can see, I'm working in an interactive mode, so I keep updating the model on my decisions or conclusions. And then I'm getting a new prompt based on the previous decision. So number four, I will go with superhero craft station, recommend a list of materials and quantities for around 20 kids, and so on. Let's review another example while developing a short story. So the first pomp will be write a short story about a robot called Mikey Robot who dreams of becoming more human. That's generic, but we are going to direct the model in interactive mode. So the next pompt will be describe the regular day of Mikey Robot while working in a factory to create gadgets. He is confined to the walls of the factory, but his thoughts are focused on human activities. The mother will take that pompt and continue developing the story. And then I'm adding as the next pump. One day, a little curious child stumbled upon Mickey Robot, and they became good friends. What happened next? Okay? By chaining those prompts together, we can shape the direction of the overall story line. Okay? That's about pumped chaining. Let's move to the next method. See you next. 15. S03L05 #4 Generating Knowledge: Hi and welcome back. And LLM has a huge pool of knowledge about a wide range of topics. This knowledge was created as part of the pre training process of those models. It is like a huge storage area with many containers in each container, many small boxes. When we ask that model to perform a specific task, the model will try to find the relevant knowledge stored in that huge storage area and then generate the required output. It is using an internal two step process, find the required knowledge and then generate a response based on that knowledge. Sometimes it will be useful to manually control that two step process. That's the concept of a method called generated knowledge prompting. In this approach, we first prompt the LLM to generate knowledge or a couple of facts about some topic, and then we feed that information into another bump to perform the final required task. This method is used to steer the model in a specific direction. Let's see a simple example. You are an expert in painting pictures on walls. Generate a list of best practices being used to paint large pictures on outdoor street walls. Okay, I'm getting the response, meaning the model extracted specific knowledge. If at this stage, the knowledge is not good enough, I can identify that gap without moving to the next step. Assuming the output is good enough, I will now ask for the actual task. Now I will write use the generated information to write a comprehensive blog post on how to paint a picture on ALDO street walls. I basically divided that into two steps. Step number one, extract the knowledge, step number two, ask the actual task using that knowledge. Let's review another example. Suppose we want LLM to write a short report on climate change. Instead of asking it to perform that task directly, we would like to control the steps and see the knowledge before it is being used to generate that report. So we could create the following prompts and run them sequentially. The first prompt will be summarize the key trends in global warming over the past ten years. I'm getting a list of key trends about global warming. Then in the next prompt, I will write based on the identified trends, list the major scientific studies that discuss the causes of those changes. As you can see, I'm using the knowledge extracted in the first prompt as input to the next prompt. I'm forcing the model to focus on specific points, specific pieces of the knowledge. I can even ask to filter some of the trends, for example, and ask the model to focus on specific trends. Next, I will write summarize the finding of the listed studies, focusing on the impact of humans. This is again asking DM to extract specific knowledge. The last step, propose five main strategies to mitigate the impact of humans to climate change based on the summarized findings. That's about generated knowledge prompting. What about the situation that the knowledge inside the model is not good enough? It is not holding the required knowledge. That's the topic of the next lecture. See you next. 16. S03L06 #5 Adding External Knowledge: Hi, and welcome back. Until this point, our core assumption is that an LLM that we are using has the required knowledge to answer our question about some topic. We know that those LLMs are trained using a massive amount of data and their knowledge expands horizontally across multiple domains and vertically inside many domains. Still, those LLMs are not perfect. They will never be perfect. Knowledge is something that is constantly being created as we speak. Each day, humans are creating unbelievable amount of new data. Even if the data is available, you cannot train a model with any piece of data. The knowledge of any model will be limited. It can be limited for a couple of reasons. Domain specific information that was not available when the model was trained, like a very specific knowledge about a medical procedure as an example. The second one is called knowledge cutoff, meaning the model was trained up to a certain date until November 2024, any data created after that date is not part of the model knowledge. The cut off date is not a problem when we are dealing with topics that are not changing so much like cooking methods. But if our question is related to things that are changing very fast like information about technologies, then we might have a problem. And the third one is private data. Just think about any business company with data that is stored in internal databases. This private data is not part of a public services like HGPT or Google Giminy. So how can we bridge that gap? How can we bring the missing knowledge from external data sources? Well, there are two main options manually or automatically. I will start with the second option that is suitable for developers. There is a method called retrieval, argumented generation or in short lag. Using this method, developers are creating a system that automate the process end to end, meaning a softer component will get the input prompt, use the content of the prompt to identify the required knowledge and then extract that knowledge from external sources. Finally, it will take the extracted knowledge and fit it into the model together with the original prompt. It's like an enrichment process. It is feeding the LLM with specific external data. By using this method, companies can leverage internal private data as additional information to enhance and tailor the generated content. As you can imagine, we can do the same process manually. Meaning, in case we would like to utilize a private data or any other type of data stored in a document, a spreadsheet, a website, or in a database, we can add that extra content as part of the input prompt, together with the task we would like to perform, copy paste relevant text from documents, articles, websites into the prompt to provide more context or specific information for the LLM to use when generating responses. The model will use that extra content together with the knowledge it already has to generate a response. Now, if the extra content is one page, we can just copy paste it into the input prompt coupled with our required task. However, if the extra content is 100 pages, then it will be ten, it may not fly. We will quickly hit the limitation of the model. We need to identify the most relevant information required to perform our specific task. So from 100 pages, we may zoom on two or three most relevant pages. Another thing to consider is about sharing sensitive information of your company with external services like HAGPT or Google Gemini. Don't assume that those services are safe in a sense that your private data will not be used. It is something to take into account. And the last thing to remember is that this extra data you will share in a prompt is not changing the stored knowledge inside a model. It is just part of a temporary model memory. If you will open the service again in another tab, this extra knowledge is gone. It is not part of the model, and you will need to share that information again to run the same prompt. 17. S03L07 Summary: Hi, and welcome back. We covered several important methods in prompt engineering, and now I would like to quickly summarize them. We started with the method of splitting complex tasks to smaller pieces. We need to remember that a typical Generi model will have limitations, and today they are not so good while handling a complex task that requires substantial amount of requirement and information. I guess the benchmark of defining complex task is going to change. There is a constant market trends to improve those models, so a complex task today may be simple in the future. In any case, we can always take something complex and try to break it down to simple pieces. Each piece can be a specific task that we will handle with a dedicated prompt. Next, we talked about the method of asking the model to share the reasoning steps that were used to get the final response. It is called chain of thought prompting. As part of the prompt, we directly ask to show us the thinking process, generate a chain of thought as intermediate steps to reach that answer. Using this method, we can better evaluate how the model reach that final response. Method number three is the method of using interactive prompts, also called pumped chaining. It is like talking with a good friend about some topic and developing ideas around it in a step by step approach while taking the output of the last pumped and using it to refine or adjust the next input pumped, creating a chain of related text. It is a great method for generating more creative content, brainstorming ideas, and exploring selected ideas in different directions. Method number four, generating knowledge as a prestep. Using this model, we first ask the model to generate knowledge about the topic, and in the next prompt, use that generated knowledge or a subset of that knowledge to handle the required task. It is helping us to manually control the knowledge the model is picking from its internal repository that is used to handle our task. Method number five, adding external knowledge. That's quite straightforward method. There are cases where we would like to leverage specific private data or domain specific data that is not part of the model knowledge. There are two main options here automated or manually. The automated option is applicable for developers that would like to use GAI tools in their applications. The option is the ability to copy paste text data directly into the prompt coupled with the task we would like to handle. As you can see, all those methods are not complex. It is just a matter of experience and awareness that we can use them for different use cases. That's a quick summary. Thanks for watching this section.