ChatGPT Prompt Engineering for Developers ChatGPT 05: Inferring 开发人员提示工程 05: 推断

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this next video is on inferring I like to think of these tasks where the model takes a text as input and performs some kind of analysis so this could be extracting labels extracting names kind of understanding the sentiment of a text that kind of thing so if you want to extract a sentiment positive or negative of a piece of text in the traditional machine learning workflow you'd have to collect the label data set trainer model figure out how to deploy the model somewhere in the cloud and make inferences and that can work pretty well but it was you know just a lot of work to go through that process and also for every task such as sentiment versus extracting names versus something else you have to train and deploy a separate model one of the really nice things about large language model is that for many tasks like these you can just write a prompt and have it start generating results pretty much right away and that gives tremendous speed in terms of application development and you can also just use one model one API to do many different tasks rather than needing to figure out how to train and deploy a lot of different models and so with that let's jump into the code to see how you can take advantage of this so here's a usual starter code um I'll just run that and the motivating example I'm going to use is a review for a lamp so need a nice lamp for my bedroom and this one additional storage and so [Music] um so let me write a prompt to classify the sentiment of this and if I want the system to tell me you know what is the sentiment I can just write what is the sentiment of the following product review with the usual delimiter or the review text and so on and let's run that and this is the center of the probably review is positive which is actually seems pretty right this lamp isn't perfect but this customer seems pretty happy seems you're a great company that cares about the customers and products I think positive sentiments seems with the right answer now this prints out the entire sentence the sentiment of the product review is positive if you wanted to give a more concise response to make it easier for post-processing I can take this prompt and add another instruction to give your answers a single word either positive or negative so it just prints out positive like this which makes it easier for a piece of text to take to sell points and process it and do something with it let's look at another prompt again still using the lab review here I haven't identified a list of emotions that the rights of the following review is expressing including there are more than five items in this list so large language models are pretty good at extracting specific things out of a piece of text in this case we're expressing the emotions and this could be useful of understanding how your customers think about the particular products um for a longer customer support organizations is important to understand if a particular user is extremely upset so you might have a different classification problem like this is the rights of the following review expressing anger because if someone is really angry it might Merit paying extra attention to have a customer review to have customer support or customer success reach out to figure what's going on and make things right for the customer in this case the customer is not angry and notice that with supervised learning if I had wanted to build all of these classifiers there's no way you know I would have been able to do this with supervised learning in the just a few minutes that you saw me do so in this video I'd encourage you to pause this video and try changing some of these prompts maybe also if the customer is expressing Delight will ask if there are any missing parts and see if you can get the prompt to make different inferences about this lab review let me show some more things that you can do with this system um specifically extracting richer information from a customer review so information extraction is the part of NLP of natural language processing that relates to taking a piece of text and extracting certain things that you want to know from the text so in this prompt I'm asking it identify the following items the item purchase and the name of the company that made the item again if you are trying to summarize many reviews from a online shopping e-commerce website it might be useful for your large collection of reviews to figure out what were the items who made the item figure out positive and negative sentiment to track Trends about positive or negative sentiment for specific items or for specific manufacturers and in this example I'm going to ask it to format your response as a Json object with item and brand as the keys and so if I do that it says the item is a lab the Brand This Luminaire and you can easily load this into the python dictionary um to then do additional processing on this output in the examples we've gone through you saw how to write prompts to recognize the sentiment figure out if someone is angry and then also extract the item and the brand one way to extract all of this information would be to use three or four prompts and call get completion you know three times or four times extract these different views one at a time but it turns out you can actually write a single prompt to extract all of this information at the same time so I'm going to say identify the fine items extract sentiment um as a reviewer expressing anger item purchase completed and then here I'm also going to tell it to format the angle value as a as a brilliant value and then we run that and this outputs a um Json where sentiment is positive anger and there no quotes around false because it also it's just I'll put it as a booted value they extracted the item as lab with additional storage instead of lab seems okay but this way you can extract multiple Fields out of a piece of text with just a single prompt and as usual please feel free to pause the video and play with different variations on this yourself or maybe even try typing in a totally different preview to see if it can still extract these things accurately now one of the cool applications I've seen of large language models is inferring topics given a long piece of text you know what is this piece of text about what are the topics here's a fictitious newspaper article about how government workers feel about the agency they work for so the recent survey conducted by government you know and so on results reviewed in NASA was a popular Department with high satisfaction rating I am a fan of NASA I love the work they do but this is a fictitious article and so give an article like this we can ask it with this prompt determine five topics that are being discussed in the following texts let's make each item 102 words long for my response in a comma separated list and so if we run that you know we get out this article it's about a government survey it's about job satisfaction it's about announcer and so on so overall I think a pretty nice extraction of a list of topics and of course you can also you know split it so you get a python list with the five topics that this article was about and if you have a collection of Articles and extract topics you can then also use a large language model to help you index into different topics so let me use a slightly different topic list let's say that um we're a news websites or something and you know these are the topics we try and also local government engineering employee satisfaction Federal governments and let's say you want to figure out given the news article which of these topics are covered in that news article so here's a prompt that I can use I'm going to say determine whether each item in the formulas of topics is a topic in the text below give your answer as a list of zero one for each topic and so great so this is the same story text as before so this thing's a story and it's about now sir it's not about local government it's not about engineering it is about employee satisfaction and it is about federal government so with this in machine learning this is sometimes called a zero shot learning because we didn't give it any training data that was labeled so that's zero shot and with just a prompt it was able to determine which of these topics are covered in that news article and so if you want to generate a news alert say so that process news and you know I really like a lot of the word the NASA does so if you want to build a system that can take this you know put this information into dictionary and whenever another news pops out prints alert the analysis story they can use this to very quickly take an article figure out what topics it is about and if the topic includes notes there have it print out alert new nonsense story oh just one thing I use this topic dictionary down here this prompt that I use up here isn't very robust if I went to the production system I would probably have it I'll put the answer as a in Json format rather than as a list because the output of the large language model could be a little bit inconsistent so this is actually a pretty Brillo piece of code but if you want when you're done watching this video feel free to see if you can figure out how to modify this prompt to have it I'll put Json instead of a list like this and then have a more robust way to tell if a particular article is a story about NASA so that's it for inferring and in just a few minutes you can build multiple systems so making inferences about text that previously doesn't have taken days or even weeks for a skills machine learning developer and so I find this very exciting that both for skilled machine learning developers as well as for people that are newer to machine learning you can now use prompting to very quickly build and start making inferences on pretty complicated natural language processing tasks like these in the next video we'll continue to talk about exciting things you could do with large language models that will go on to transforming how do you take one piece of text and transform it into a different piece of text such as translated to a different language let's go on to the next video
Info
Channel: 盛少
Views: 117
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: LTUkn8Uj1Xc
Channel Id: undefined
Length: 12min 4sec (724 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.