Play ChatGPT: Wu Enda/OpenAI cooperation tutorial "ChatGPT prompt project for developers"

1. Write in front

Recently, Andrew Ng and Close Open AI collaborated on a tutorial "ChatGPT Prompt Project for Developers". I watched it for the first time, and I have some experience. Now I will carry over what I personally find interesting.

My introduction to machine learning is to watch Wu Enda's tutorial! The boss looks like Feng Gong, hahaha.

Original video address:

https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/

Station B already has a Chinese version:

https://space.bilibili.com/15467823/channel/seriesdetail?sid=3247315&ctype=0

Below are the notes from the first lesson. Let me just say one more thing, I think the content of the first class is full of dry goods (it's about methodology, which is worthy of careful review) , and the following classes are based on these principles:

2. Two key principles of prompt engineering

(1) Write clear and specific instructions. Write clear and specific instructions

(a) You should express what you want the model to do by providing as clear and specific instructions as possible , this will guide the model towards the expected output and reduce the chances of you getting irrelevant or incorrect responses.

(b) Don't confuse writing a clear hint with writing a short instruction, because in many cases longer instructions actually provide a clearer description and context for the model , leading to more detailed and relevant output .

To sum it up: the clearer the instructions, the more specific the better, and don't skimp on your sentences.

(c) The first strategy to help you write clear and specific instructions: use delimiters to clearly point out the different parts of the input. for example:

Mantra: Summarize the main content in {text} into one sentence, about 50 characters.

{The so-called unbalanced data set refers to the extremely unbalanced sample size of each category of the data set. Taking the binary classification problem as an example, assuming that the number of samples of the positive class is much larger than the number of samples of the negative class, usually the data in which the ratio of the majority class samples is close to 100:1 is called unbalanced data. Learning from unbalanced data requires learning useful information from unevenly distributed data sets. }

 To summarize: Using a delimiter such as curly braces makes it clear to the model the exact text that needs to be summarized, a delimiter can be any clear punctuation mark that separates a specific piece of text from the rest of the prompt.

(d) A second strategy to help you write clear and specific instructions: Ask for a structured output. For example, output in Markdown, HTML, or JSON, or in a table like I did before. for example:

Incantation: Generate a list of three made-up book titles , authors, and genres . Display their book IDs, titles, authors, and genres in tabular form.

(e) A third strategy that helps you write clear and specific instructions: ask the model to check whether conditions are met. A bit of a mouthful, she explained it this way, if the assumptions in the task are not necessarily satisfied, then we can tell the model to check these assumptions first. If these assumptions are not met, point this out and stop in the process of completing the task. You can also consider potential edge cases and tell the model how they should be handled to avoid unexpected errors or results. for example:

Mantra: If the main content of {text} contains step information, then summarize the text content in the following format:

Material:

step:

first step:...

Step 2:-

Step N:-

If the main content of {text} does not contain step information, then simply output "cannot be overwritten".

{Beer duck is a very popular roast duck dish. To make beer duck, you need to prepare duck, beer, salt, dark soy sauce, sugar, ginger, green onions, and spice bags (star anise, grass fruit, cinnamon, cloves, pepper, etc.) and other materials. First, the duck is slaughtered and cleaned, the internal organs and head are removed, and then the duck is cleaned and set aside. Next, put the spices in the spice bag into the pot and stir-fry until fragrant, then take it out and set aside. Then, boil a pot of water, add an appropriate amount of beer, salt, dark soy sauce, sugar, ginger, green onions and spice bags, and cook until the fragrance overflows. Let the boiled beer juice cool, soak the duck in the beer juice and marinate for more than 4 hours (the longer the time, the better the taste). In order to make the duck taste good, you can add some salt and soy sauce to the beer juice, or you can smear some soy sauce and cooking wine on the surface of the duck. Put the marinated duck in the oven and bake it at 180 degrees for 40 minutes, take it out and coat it with honey, then put it back into the oven and continue to bake it for about 20 minutes, until the duck skin is golden and crispy. During the roasting process, you can adjust the roasting time and temperature according to your own taste to achieve the best taste. Finally, take out the roasted beer duck and cut it into suitable pieces to serve. Spice bags can be added when boiling the juice to make the beer juice more fragrant, and honey can be applied to add sweetness. When enjoying beer duck, it can be paired with beer or other beverages to make it more delicious. }

 I change the text to:

(f) A fourth strategy to help you write clear and specific instructions: Include a specific example in the instruction and let the model follow suit. This is not an example, everyone knows how to operate.

Summary: First we need to write clear and specific instructions. Provides 4 strategies, using separators to clearly indicate different parts of the input; requiring a structured output; requiring the model to check whether the conditions are met; giving a specific example in the instruction to let the model follow the gourd.

(2) Give the model time to think. Give the model time to think

Daxie explained: If a model has a reasoning error due to its eagerness to draw conclusions, it should try to redesign the query, requiring the model to have a series or a series of related reasoning, and then the model provides the final answer . If you give a model a task that is too complex, it won't be able to do it in a short amount of time or with very few words, and may end up making up an incorrect answer.

In human terms, it is necessary to give the model time to think , just like we have to draft a math problem.

(a) First strategy: specifies the steps required to complete a task. To cite her first example directly:

Mantra: Perform the following actions:

1 - Summarize the following text delimited by triple backticks with 1 sentence.

2 - Translate the summary into Chinses.

3 - List each name in the Chinese summary.

4 - Output a sheet object that contains the following keys: chinese_summary, num_names.

Separate your answers with line breaks.

Text:

‘’’ In a charming village, siblings Jack and Jill set out on a quest to fetch water from a hilltop well. As they climbed, singing joyfully, misfortune struck-Jack tripped on a stone and tumbled down the hill, with Jill following suit. Through slightly battered, the pair returned home to comforting embraces. Despite the mishap, their adventurous spirits remained undimmed, and they continued exploring with delight. ‘’’

 Then, she switched to another incantation (mainly a change in the output format):

Perform the following actions:

1 - Summarize the following text delimited by <> with 1 sentence.

2 - Translate the summary into Chinese.

3 - List each name in the Chinese summary.

4 - Output a sheet object that contains the following keys: chinese_summary, num_names.

Use the following format:

Text: <text to summarize>

Summary: <summary translation>

Translation: <summary translation>

Name: <list of names in Chinese summary>

Output JOSN: <josn with summary and num_names>

Text:

< In a charming village, siblings Jack and Jill set out on a quest to fetch water from a hilltop well. As they climbed, singing joyfully, misfortune struck-Jack tripped on a stone and tumbled down the hill, with Jill following suit. Through slightly battered, the pair returned home to comforting embraces. Despite the mishap, their adventurous spirits remained undimmed, and they continued exploring with delight. >

 To sum up: first read the text --> summarize the text content in English --> translate the summary sentence --> extract the name --> output the JSON format. Decompose the task layer by layer, solve it step by step, and finally summarize it.

(b) Second strategy: instruct the model not to rush to conclusions, but to try to find a solution first. After the model gives a conclusion, tell TA whether it is correct or not. The so-called people in the loop? Check out her example:

咒语:Determine if the students solution is correct or not.

Question:

Im building a solar power installation and I need help working out the financials.

- Land costs $100 / square foot

- I can buy solar panels for $250 / square foot

- I negotiated a contract for maintenance that will cost me a flat $100k per year, and an additional $10 / square foot

What is the total cost for the first year of operations as a function of the number of square feet.

Students Solution:

Let x be the size of the installation in square feet.

Costs:

  1. Land cost: 100x
  2. Solar panel cost: 250x
  3. Maintenance cost: 100,000 + 100x

Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000

 However, the model concludes that the student is correct. Indeed, the student's problem-solving thinking is fine, but he misread a number carelessly. At first glance, I did think it was correct.

 Therefore, the strategy needs to be modified: let the model come up with a plan for this problem by itself, and then compare it with the student's plan, so that it can accurately judge whether the student's plan is correct.

咒语:Determine if the students solution is correct or not.

To solve the problem do the following:

- First, work out your own solution to the problem.

- Then compare your solution to the students solution and evaluate if the students solution is correct or not. Dontt decide if the students solution is correct until you have done the problem yourself.

Use the following format:

Question:

‘’’

question here

‘’’

Students solution:

‘’’

Students solution here

‘’’

Actual solution:

‘’’

steps to work out the solution and your solution here

‘’’

is the students solution the same as actual solution just calculated:

‘’’

yes or no

‘’’

student grade:

‘’’

correct or incorrect

‘’’

Question:

Im building a solar power installation and I need help working out the financials.

- Land costs $100 / square foot

- I can buy solar panels for $250 / square foot

- I negotiated a contract for maintenance that will cost me a flat $100k per year, and an additional $10 / square foot

What is the total cost for the first year of operations as a function of the number of square feet.

Students Solution:

Let x be the size of the installation in square feet.

Costs:

  1. Land cost: 100x
  2. Solar panel cost: 250x
  3. Maintenance cost: 100,000 + 100x

Total cost: 100x + 250x + 100,000 + 100x = 450x + 100,000

 Do you have a feeling that TA's thinking mode is a bit like human beings, and even the mistakes they make are very similar.

Summary: The model is also impatient, and the correct answer given by patting the head is not high. Solution: Give TA time to think, and guide TA to think of a way first, and then draw conclusions after comparison. All in all, think twice!

 

3. Limitations of the model

We've all seen it, and it's serious nonsense:

The boss said: Although the language model has been exposed to a lot of knowledge during the training process, during its training process, it does not perfectly remember the information it has seen. As such, it doesn't know very well the boundaries of its own knowledge, which means it may try to answer obscure questions, and it can make up things that sound plausible but aren't actually true. We call these fabricated thoughts hallucinations.

Suggestion from the big guy: There is an additional strategy to reduce hallucinations . If you want the model to generate answers based on text, you need to first ask the model to find any relevant references from the text, and then ask it to use these references to answer the question.

Well, she didn't give a case! ! !

 

Fourth, write at the end

  1. Very informative. Listen to the official courses directly and avoid detours.
  2. Goodbye for the next 6 classes. Because I watched it once, nothing amazing, maybe my level is not enough. When I have some insights, I will add another issue.

Guess you like

Origin blog.csdn.net/qq_30452897/article/details/130468345