The prompt
<user query>
{query}
</user query>
Let's first understand the problem,
extract relevant variables and their
corresponding numerals, and make a
complete plan. Then, let's carry out
the plan, calculate intermediate
variables (pay attention to correct
numerical calculation and commonsense),
solve the problem step by step, and
show the answer.
---
<user query>
{query}
</user query>
Let's first understand the problem,
extract relevant variables and their
corresponding numerals, and make a
complete plan. Then, let's carry out
the plan, calculate intermediate
variables (pay attention to correct
numerical calculation and commonsense),
solve the problem step by step, and
show the answer.
<reasoning>
{reasoning.chain_of_thought}
</reasoning>
Therefore the answer (arabic numerals) is What it is
A two-step prompt that has the model extract the variables, make a plan, carry it out with attention to calculation, and then give the final answer from that reasoning. The docs cite the paper Plan-and-Solve Prompting and present this as an improved zero-shot chain-of-thought prompt. The prompt text comes from the Instructor documentation (MIT licence, Copyright (c) 2023 Jason Liu). The two prompts are separated by a line with three dashes, which is ours. Python string quotes and code indentation were removed. Placeholders keep the source syntax. Original author: Jason Liu and contributors (567-labs/instructor).
Who it's for
- Students
- Anyone writing prompts
- Developers
برومبت من خطوتين يجعل النموذج يستخرج المتغيرات ويضع خطة وينفذها بعناية في الحساب، ثم يعطي الإجابة النهائية من ذلك الاستدلال.
Examples
Example from the docs
pythonif __name__ == "__main__":
query = (
"In a dance class of 20 students, 20% enrolled "
"in contemporary dance, 25% of the remaining "
"enrolled in jazz dance and the rest enrolled "
"in hip-hop dance. What percentage of the entire "
"students enrolled in hip-hop dance?"
)
reasoning = generate_reasoning(query)
print(reasoning.model_dump_json(indent=2))
"""
{
"chain_of_thought": "Let's first break down the
problem:\n\n1. Total number of students = 20\n2.
Percentage enrolled in contemporary dance = 20%\n\n
Step-by-Step Plan:\n1. Calculate the number of
students enrolled in contemporary dance.\n2.
Calculate the remaining students after contemporary
dance enrollment.\n3. Calculate the percentage and
number of students from the remaining who enrolled in
jazz dance.\n4. Determine the remaining students who
enrolled in hip-hop dance.\n5. Finally, calculate the
percentage of the entire students who enrolled in
hip-hop dance.\n\nLet's carry out the plan:\n\n1.
Number of students enrolled in contemporary dance =
20% of 20 = (20/100) * 20 = 4\n2. Remaining students
after contemporary = 20 - 4 = 16\n3. Percentage of
remaining students enrolled in jazz dance = 25%\n
Number of students enrolled in jazz dance = 25% of 16
= (25/100) * 16 = 4\n4. Remaining students after
contemporary and jazz = 16 - 4 = 12\n5. The number of
students enrolled in hip-hop dance = 12\n6.
Percentage of entire students enrolled in hip-hop =
(Number of hip-hop students / Total students) *
100\n Percentage = (12 / 20) * 100 = 60%\n\nThus,
60% of the entire students enrolled in hip-hop dance."
}
"""
response = extract_answer(query, reasoning)
print(response.model_dump_json(indent=2))
"""
{
"correct_answer": "60"
}
"""What it does: The usage code and printed output from the Instructor docs. Output as printed in the docs, not re-run by us.
Tips
- The docs describe two steps: generate the reasoning, then extract the answer with a new prompt that includes the reasoning.
- The docs pass a Pydantic response model with this prompt, so the printed output follows that schema.