ChatGPT Prompt Engineering – 2. 基本原则 (2)

基本原则

原则 2:给模型时间去“思考”

技巧 1:显式制定完成任务所需要的步骤

输入:

Perform the following actions:

1 – Summarize the following text delimited by triple quotes with 1 sentence.
2 – Translate the summary into French.
3 – List each name in the French summary.
4 – Output a json object that contains the following keys: french_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. Though slightly battered, the pair returned home to comforting embraces. Despite the mishap, their adventurous spirits remained undimmed, and they continued exploring with delight.
”’

输出:

Two siblings, Jack and Jill, go on an adventurous quest to fetch water from a hilltop well, but misfortune strikes as Jack trips and tumbles down the hill, with Jill following, yet they return home with comforting embraces and continue their exploration undeterred.

Deux frères et sœurs, Jack et Jill, partent pour une aventureuse quête pour aller chercher de l’eau d’un puits au sommet de la colline, mais une malchance les frappe, et bien que légèrement blessés, ils continuent leur exploration avec des esprits intrépides.

Names: Jack, Jill.

{“french_summary”: “Deux frères et sœurs, Jack et Jill, partent pour une aventureuse quête pour aller chercher de l’eau d’un puits au sommet de la colline, mais une malchance les frappe, et bien que légèrement blessés, ils continuent leur exploration avec des esprits intrépides.”, “num_names”: 2}

也可以提供格式化输出,例如输入:

Your task is to perform the following actions:

1 – Summarize the following text delimited by
<> with 1 sentence.
2 – Translate the summary into French.
3 – List each name in the French summary.
4 – Output a json object that contains the
following keys: french_summary, num_names.

Use the following format:

Text:
Summary:
Translation:
Names:
Output JSON:

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. Though slightly battered, the pair returned home to comforting embraces. Despite the mishap, their adventurous spirits remained undimmed, and they continued exploring with delight.>

输出:

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. Though slightly battered, the pair returned home to comforting embraces. Despite the mishap, their adventurous spirits remained undimmed, and they continued exploring with delight.>

Summary: <Two siblings, Jack and Jill, go on an adventurous quest to fetch water from a hilltop well, but misfortune strikes as Jack trips and tumbles down the hill, with Jill following, yet they return home with comforting embraces and continue their exploration undeterred.>

Translation: <Deux frères et sœurs, Jack et Jill, partent pour une aventureuse quête pour aller chercher de l’eau d’un puits au sommet de la colline, mais une malchance les frappe, et bien que légèrement blessés, ils continuent leur exploration avec des esprits intrépides.>

Names: <Jack, Jill>

Output JSON: {“french_summary”: “Deux frères et sœurs, Jack et Jill, partent pour une aventureuse quête pour aller chercher de l’eau d’un puits au sommet de la colline, mais une malchance les frappe, et bien que légèrement blessés, ils continuent leur exploration avec des esprits intrépides.”, “num_names”: 2}

技巧 2:“教导”模型做判断

这个技巧用来辅助 ChatGPT 模型做出更准确的判断。

思路是:对给定的问题 Q 和解决方案 S,与其让模型来判断 S 是否正确,不如先让模型得出自己的解决方案 S1,然后再让模型比较 S 和 S1,来判断 S 的正确性。

输入:

Determine if the student’s solution is correct or not.

Question: I’m 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.

Student’s 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

输出:

The student’s solution is correct.

The total cost is the sum of the costs of land, solar panels, and maintenance.

So, the total cost for the first year of operations is:

Land cost: $100/square foot * x square feet = $100x
Solar panel cost: $250/square foot * x square feet = $250x
Maintenance cost: $100,000 + $10/square foot * x square feet = $100,000 + $10x


Total cost = Land cost + Solar panel cost + Maintenance cost

Total cost = $100x + $250x + ($100,000 + $10x)

Total cost = $450x + $100,000

注意输出并没有捕获到 solution 里的 typo(10x 写成了 100x)

如果先让模型检验再做判断,模型就可以发现这个问题:

Your task is to determine if the student’s 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 student’s solution and evaluate if the student’s solution is correct or not.

Don’t decide if the student’s solution is correct until you have done the problem yourself.

Use the following format:

Question:
”’
question here
”’
Student’s solution:
”’
student’s solution here
”’
Actual solution:
”’
steps to work out the solution and your solution here
”’
Is the student’s solution the same as actual solution just calculated:
”’
yes or no
”’
Student grade:
”’
correct or incorrect
”’

Question:
”’
I’m 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 foo.

What is the total cost for the first year of operations as a function of the number of square feet.
”’
Student’s 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
”’

输出:

The student’s solution is incorrect.

To calculate the total cost for the first year of operations as a function of the number of square feet, we need to add up the costs of land, solar panels, and maintenance:

Total cost = land cost + solar panel cost + maintenance cost

Land cost = $100/sqft * x sqft = $100x
Solar panel cost = $250/sqft * x sqft = $250x
Maintenance cost = $100,000 + $10/sqft * x sqft = $100,000 + $10x

Total cost = $100x + $250x + $100,000 + $10x = $360x + $100,000

Therefore, the total cost for the first year of operations as a function of the number of square feet is $360x + $100,000.

Is the student’s solution the same as the actual solution just calculated?
No

Student grade:
Incorrect

(未完待续)

发表回复