ChatGPT Prompt Engineering for Developers ChatGPT 07: Expanding 开发人员提示工程 07: 扩张

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
expanding is the task of taking a shorter piece of text such as a set of instructions or a list of topics and having the large language model generate a longer piece of text such as an email or an essay about some topic there are some great uses of this such as if you use a large language model as a brainstorming partner but I just also want to acknowledge that there's some problematic use cases of this such as if someone were to use it to generate a large amount of spam so when you use these capabilities of a large language model please use it only in a responsible way and in a way that helps people in this video we'll go through an example of how you can use a language model to generate a personalized email based on some information the email is kind of self-proclaimed to be from an AI bot which as Andrew mentioned is very important we're also going to use another one of the models input parameters called temperature and this kind of allows you to vary the kind of degree of exploration and Variety in the kind of models responses so let's get into it so before we get started we're going to kind of do the usual setup so set up the open AI python package and then also Define our helper function get completion and now we're going to write a custom email response to a customer review and so given a customer review and the sentiment we're going to generate a custom response now we're going to use the language model to generate a custom email to a customer based on a customer review and the sentiment of the review so we've already extracted the sentiment using the kind of prompts that we saw in the inferring video and then this is the customer review for a blender and now we're going to customize the reply based on the sentiment and so here the instruction is your you are a customer service AI assistant your task is to send an email reply to a valued customer given the customer email delimited by three backdicks generate or apply to thank the customer for their review if the sentiment is positive or neutral thank them for their review if the sentiment is negative apologize and suggest that they can reach out to customer service make sure to use specific details from the review write in a concise and professional tone and sign the email as AI customer agent and when you're using a language model to generate text that you're going to show to a user it's very important to have this kind of transparency and let the user know that the text they're seeing was generated by AI and then we'll just input the customer review and the review sentiment and also note that this pop isn't necessarily important because we could actually use this prompt to also extract the review sentiment and then in a follow-up step write the email but just for the sake of the example well we've already extracted the sentiment from the review and so here we have a response to the customer it kind of addresses details that the customer mentioned in their review and kind of as we instructed suggests that they reach out to customer service because that this is just an AI customer service agent next we're going to use a parameter of the language model called temperature that will allow us to um change the kind of variety of the model's responses so you can kind of think of temperature as the degree of exploration or kind of randomness of the model and so for this particular phrase my favorite food is the kind of most likely next word that the model predicts is pizza and the kind of next to most likely it suggests our Sushi and tacos and so at a temperature of zero the model will always choose the most likely next word which in this case is pizza and at a higher temperature it will kind of also choose one of the less likely words and I even at an even higher temperature it might even choose tacos which only kind of has a five percent chance of being chosen and you can imagine that kind of as the model continues this final response so my favorite food is pizza and it kind of continues to generate more words this response will kind of diverge from the response um the first response which is my favorite food is tacos and so as the kind of model continues these two responses will become more and more different in general when building applications where you want a kind of predictable at response I would recommend using temperature zero throughout all of these videos we've been using temperature zero and I think that if you're trying to build a system that is reliable and predictable you should go with this if you're trying to kind of use the model in a more creative way where you might kind of want um a kind of wider variety of different outputs you might want to use a higher temperature so now let's take the same prompt that we just used and let's try generating an email but let's use a higher temperature so in our get completion function that we've been using throughout the videos we have kind of specified a model and then also a temperature but we've kind of set them to default so now let's try varying the temperature so we use the prompt and then let's try temperature 0.7 and so with temperature zero every time you execute the same prompt you should expect the same completion whereas with temperature 0.7 you'll get a different output every time so here we have our email and as you can see it's different to the email that we kind of received previously and let's just execute it again to show that we'll get a different email again and here we have another different email and so I I recommend that you kind of play around with temperature yourself maybe you could pause the video now and try this prompt with a variety of different temperatures just to see how the outputs vary so to summarize at higher temperatures the outputs from the model are kind of more random you can almost think of it as that at higher temperatures the assistant is more distractible but maybe more creative in the next video we're going to talk more about the chat completions endpoint format and how you can create a custom chat bot using this format foreign
Info
Channel: 盛少
Views: 83
Rating: undefined out of 5
Keywords: ChatGPT, AI, artificial intelligence, natural language processing, NLP, GPT, OpenAI, machine learning, ML, deep learning, prompt engineering, chatbot development, AI chatbot, AI-powered conversations, AI language model, AI tutorial, GPT tutorial, AI applications, AI development, AI techniques
Id: rAkU82nsPxc
Channel Id: undefined
Length: 7min 1sec (421 seconds)
Published: Thu May 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.