hello everyone my name is abishek and welcome back to my Channel today is episode two of AI assisted devops Zero to Hero series and in this episode we will focus on prompt engineering so prompt engineering is a very important skill when it comes to geni and it's also super simple that's why in today's video we will start with learning the fundamentals of prompt engineering then we will learn various prompt engineering techniques or types such as zero short prompting few short prompting multi-shot prompting and chain of thoughts out of Which F short prompting is very popular it is highly recommended as well that's why in today's video I will also do a demonstration of few short prompting where I will show you how in real time devops Engineers can make use of few short prompting to get desired output according to their organizational requirements overall it's going to be a very interesting session so make sure you watch it till the end let's get started first things first what is prompt Engineering in a lay and terminology let's say there is a AI model maybe a large language model so usually user provides input to the large language model and depending upon the input it generates the output for you now the input that is provided by the user is called as prompt and the way to enhance the users's input to let AI model generate the desired output or the expected output is called as prompt ins saring so prompt engineering is a way of enhancing the users prompt or writing better prompts to let AI models generate output that is expected let me show you with an example let's go to chat gbt and assume my requirement is to get a kubernetes deployment manifest deployment yl file so I'll just say generate a kubernetes manifest for deployment resource I mean on the first side it looks very good like the input looks to be accurate let's try to give this input or the prompt and let's see if chat GPT responds with expected output it's good that it provided the deployment yaml file however if you notice it provided this description which is not something that I'm interested it provided the explanation again something that I'm not interested steps to apply the Manifest check the deployment status and a suggestion as well which I am not at all interested in so how do I make this output better or something according to my requirement so I should enhance the prompt so I should basically write a better prompt which I will do by modifying the a character here and replacing it with only so generate only kubernetes manifest for deployment resource let's see if it works perfect so I got the expected yaml manifest so what is the simple technique that I used here I just made my prompt more specific by replacing the a keyword a character and placing only word so this is called as direct prompt or zero shot prompting where I try to be more specific so this is a basic example of prompt engineering where you can get output exactly what you need now before we head towards learning other types of prompt engineering or other techniques you might ask me abishek is this the only advantage of prompt engineering no this is another significant advantage of prompt engineering that is costing a good prompt can significantly reduce the cost for the organizations let me explain how so we will take a realtime use case where a devops engineer is assigned with a task to automate this that is any developer if provides an input similar to this or let me explain it here so let's say as a devops engineer you are expected to write a python script where the python script reads single input from the user if the user inputs kubernetes kind as deployment then the Python program should generate listen to the problem statement carefully I said it should generate Equus deployment manifest if users input is service then the python script should generate kubernetes service yaml file or the Manifest file similarly the Python program should support all the native kubernetes resources secret config map service account everything now how do you write this if you listen to the problem statement I use the word generate that means basically you should be looking at Large language models because they are good at generating the output now okay you might use large language model but how do you actually prepare this python script how do you automate this process you can do it in two steps right step one you can prepare the prompt just like how we prepared in the previous example for the deployment manifest you can either prepare this prompt or you can prepare this prompt then once the prompt is prepared you will make an API call to the large language model because that can generate things for you now you cannot make API call to chat GPT because it's just a chat bot it is just for your learning purpose what you need to do is you should be using large language models posted by maybe open AI or deep seek or other equivalent things you might ask abishek how about local large language models I'll come to that point for now let's focus on this so step one is to prepare the prompt step two is to make API call to the large language models either hosted by open aai or deeps or equivalent now the big problem here is that the API calls are not free why because either open AI or deep seek or any equivalent company what they need to do is they need to set up the infrastructure they need to set up the hardware they need to buy the gpus on top of that they will run these large language models so when you make the API call to the open AI end point we will learn all of it how to do it how to write the python script in lecture number three for now just understand the theory part so when you make API call then the request goes to open AI infrastructure which is running somewhere and the gpus process your request llms process your request and they send the output back but for this entire thing open AI will charge you now this is where a good prompt and a bad prompt can make a difference if you writing a better prompt the one that you see here is better prompt because it generates less text it generates the text exactly what you need whereas this is a bad prompt because it generates more text abishek what happens with text so what if I'm writing a bad prompt and it more text so the concept of API requests the costing of API request is based on something called as tokens more the number of tokens more is the cost of your API request and tokens are directly or indirectly related to the wordss for example if you take Gemini model as example for every 100 words it is roughly 60 to 80 tokens that means in this case there are more number of tokens because there are more number of wordss whereas in the second prompt that we provided there are less number of wordss that means less number of tokens so less is the cost abishek would that matter that much for a single API request obviously for single API request it doesn't matter that much but when you are doing it scale when you are sharing it with your organization every day 100 developers might request it overall throughout a year there can be thousands of requests or there can be millions of requests to this python script so that will make difference between the bad prompt and good prompt abishek I want to understand more about tokens let's try that so basically you can go to Google AI studio so just go to Google AI Studio you can create a free account and let's try the same thing to understand how many number of tokens the bad prompt generated and how many number of Tokens The Good prompt generated okay generate a kubernetes manifest for deployment resource let's run it so you can see here the tokens number once the prompt is complete okay it's still generating and the tokens you can see the refresh token count here it is 2,473 for the bad prompt because there is a lot of useless information that is generated now let's look at the good request where I will copy this and we can refresh just remember remember it is roughly 2500 now the token count is zero let's put it here and try to see what is the token count so it is just 179 previously it was 2500 and now it came down to 179 or roughly 150 so you can see the difference in the number of tokens right for 1 million token there will be a pricing or let's say for 1,000 token there is a pricing reason why I'm not talking about the pricing is because different AI models have different pricing at this point of time so just remember that as the tokens go up the price for the API request also go up tomorrow's video when we talk more specific about the API requests when we look at open AI deep seek uh API requests then you will come to know how much tokens are costed so this is how prompt engineering can affect the costing as well overall we learned prompt engineering can help you with generating the desired output and it can also help you with respect to cost optimization perfect I hope this is clear so now let's move ahead to understanding zero short prompting few short prompting multi-shot prompting and chain off thoughts basically they are very very simple to understand it's you know it's something that you should develop as a practice but they are very easy to understand when it comes to zero short prompting this means you provide a prompt without any example till now whatever we did as part of this video is zero short prompting we asked chat G or Google AI Studio to generate a kubernetes deployment manifest but we did not provide any example to it because kubernetes deployment manifest is something I'm sure the AA model should be trained with and I'm sure it can generate the output that's why I did not provide any example so direct prompting zero shot prompting is also called as direct prompting this is useful when you are going with popular or familiar use cases and it works absolutely fine you don't have to provide an example whereas few short prompting is something where you first provide some examples right and then you provide the prompt first let's take a generic example then let me explain from devops point of view so again if you go back to chat GPT if you ask create a random name which starts with a so what CH does is you know it just provides a name right now what if I want chat GP to provide the name or to provide the output in a particular format so what I'm going to do is I'm going to provide some examples so I will say first example create a name that starts with B chat GPT your answer should be random name for alphabet B is Batman then I'll provide another example basically we are training it with our use case create a random name which starts with s random name for alphabet s is Superman now when I ask the same thing create a random name which starts with a you will see that the output is not generated in this format but it will be generated in the form format that we are looking for perfect so it said random name for alphabet a is Aquaman so for B I said Batman S for Superman and for a it said Aquaman I did not provide any description to it I just use the same prompt but what I did is I provided examples because we provide few examples this type of prompting is called as few short prompting abishek please explain me from devops point of view I understand that is very important so let's try to learn from devops point of view it's a very very important use case because a lot of times you can go to chat GPT and you can ask chat GPT to generate a shell script and what chat GPT does is it generates the shell script which is very ideal but but it might not be something that is according to the standards of your organization please understand this every organization has a coding style maybe in your organization you have a coding style where whenever someone writes the shell script in your organization they provide the author name they provide the version they provide the date and only then they write the script and maybe in your or organization you avoid certain kind of keywords or maybe you always declare variables in a particular format now chat GPT definitely is not aware of it or large language models are definitely not aware of it so how do you tell chat GPT or large language models to generate the script according to the format or style of your organization this is where few short prompting comes handy so what we will do is let's say you want to ask llm to generate a shell script for you so before generating the shell script you provide some examples to it where I will say example let's say uh the shell script is to print the or let's say fetch the docker version and answer where I am trying to this is a question for the uh example and this is the sample answer where we are just trying to train the large language model with our requirement not exactly training but we are trying to explain the format that we need so here I'll say shebang slash bin bash then I will say author abishek mirala version B1 then I'll say date close the comms and only then the actual script starts let's say this is the format of your organization where for Docker version let's say you have Docker hyphen hyphen version similarly let's provide another example for terraform fetch the terraform version and here I'll mention terraform hyphen hyphen version now I will ask chat gbt to fetch the versions of all the services that are installed on a virtual machine or all the processes let's say let's see if it can generate according to your organization Style See first it started with shebang author version date and then it generated the complicated scripting for us what's important you need to note that you provided it with a particular format or a style or the desired output that you want and it generated exactly the same this style of prompting is called as few short prompting and it is the most recommended prompting style even I would recommend it because a lot of times large language models do not have the context right they know the ideal answer but they don't know the context they don't know what exactly is your requirement they don't know anything about your company you might be running large language model locally you might be running it externally it always gives you the ideal output to make it give the output that you need always provide some examples okay that is is always try to provide the context you will learn more examples of few short prompting as we proceed with this series throughout the series but the next seven eight episodes we will definitely use prompt engineering and every time I use prompt engineering I will try to share some insights now multi-shot prompting is let's say you're working on even complicated use case then not two examples but you can provide more examples so multi-shot prompting is just similar to few short prompting but you provide more number of examples right you provide more context to it more examples things like that finally chain of thoughts chain of thoughts is a prompting style that actually enhances the performance of large language model so basically your large language model can perform better if you use chain of thoughts prompting style because it basically encourages the large language models to use its reasoning capabilities so if your llm has re reasoning capabilities using chain of thoughts you can actually derive best output from the models however at this point of time it becomes too much for the beginners so we will learn more about chain of thoughts as we proceed with the next videos of this series and as we talk about AI agents for now I hope you understood zero short prompting few short prompting multi-shot prompting and why and how prompt engineering is useful one final thing I would like to say before concluding this video better than writing these kind of prompts right all the prompts that I have written here are for the purpose of video always try to write more elaborated input and make sure the output that is provided by the large language model is concised Right always you should make sure that input is as clear as possible but the output provided by the large language models is only what you require so for that always try to follow a strategy starting with provide context like you can explain that you know I'm a devops engineer or I'm currently working on a particular project so that your llm gets context of what you are doing then you should be providing the instruction you should provide examples that is you should be using few short prompting as much as possible at least that is something that I would recommend so that you get the better performance from the model and you should be also defining the output format let's say you want the output in the MD format or you want output in the Json format so you can just tell know whenever you provide this input you can just say here please provide the output in MD file format and you will get the output in the MD file format so it is currently analyzing and it should generate the output for us in the MD file format see it generated the MD file which you can download so always try to provide the MD file format sorry the formatting style of the output so this is something that I would recommend instead of just writing a prompt provide the context provide the instruction provide the examples and output format that you need I hope you got a clear understanding from this video let me know in the comment section if you have any questions I will see you all in the next video take care everyone bye-bye