Program of Thought: Definition and Examples
Prompting technique where the model generates executable code to solve a reasoning problem, instead of producing a natural language chain of thought.
Full definition
Program of Thought (PoT) is an advanced prompting method introduced by Chen et al. in 2022, which separates reasoning from computation execution. Rather than asking the model to solve a problem step by step in natural language (as in Chain of Thought), it is asked to generate a program — typically in Python — that encodes the solution logic. This program is then executed by an external interpreter to obtain the final answer.
The intuition behind this approach is simple: language models are excellent at understanding a problem and formulating a solution strategy, but they frequently make arithmetic or logical calculation errors. By delegating execution to a code interpreter, we combine the best of both worlds — the LLM's linguistic understanding and the computational precision of an execution engine.
PoT has proven particularly effective on math reasoning benchmarks like GSM8K and AQuA, where it significantly outperforms classic Chain of Thought. It also excels in problems involving iterations, complex data structures, or financial calculations — areas where natural language reasoning reaches its limits.
This technique is part of a broader movement to augment LLMs with external tools. It is now natively integrated into several AI agent frameworks and constitutes one of the foundations of the "code as reasoning" approach gaining popularity in the community.
Etymology
The term "Program of Thought" was introduced in the research paper "Program of Thoughts Prompting: Disentangling Computation from Reasoning for Numerical Reasoning Tasks" published by Wenhu Chen et al. in 2022. The name directly echoes "Chain of Thought" by replacing the textual chain with a computer program, thereby highlighting the shift from verbal reasoning to programmatic reasoning.
Concrete examples
Solving a complex math problem
Solve this problem by writing a Python program.
Problem: A store offers a 15% discount on all items. If a customer buys 3 shirts at €45 each and 2 pants at €62 each, how much do they pay after the discount and with 20% VAT?
Write the Python code to calculate the final amount.
Reasoning about dates and durations
Write a Python program to solve this problem:
Marie was born on March 14, 1990. She started her first job exactly 23 years and 147 days after her birth. What day of the week was it?
Financial analysis with iterations
Generate a Python program to answer this question:
An investor puts €10,000 at a compound interest rate of 4.5% per year. Each year, they add €2,000. After how many years does their capital exceed €50,000?
Practical usage
To apply Program of Thought, explicitly ask the model to generate executable code rather than a natural language answer. Formulate your prompt with an instruction like "Write a Python program to solve this problem" and execute the generated code in a secure environment. This technique is particularly recommended for any problem involving calculations, iterations, or structured data manipulation.
Related concepts
FAQ
What is the difference between Program of Thought and Chain of Thought?
Do you need to know how to program to use Program of Thought?
In which cases is Program of Thought more effective than other techniques?
See also
How to use this prompt
- Copy the prompt with the button above.
- Paste it into ChatGPT, Claude or your favorite AI assistant.
- Replace the bracketed variables with your details, then refine the result.
About Prompt Guide
Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.
More definitions
Prompt Chaining: Definition and Examples
Prompt chaining is a technique that involves chaining multiple sequential prompts, where the output of each step feeds the input of the next, to
Prompt Compression: Definition and Examples
Technique for reducing the length of a prompt while preserving its meaning and effectiveness, to optimize token usage and improve
Prompt Decomposition: Definition and Examples
Technique of breaking down a complex task into several simpler and more targeted sub-prompts, in order to obtain more precise and reliable responses from the LLM.
Prompt Engineering: Definition and Examples
Prompt engineering is the art and science of formulating precise and structured instructions to get the best possible results from a generative AI model.
Prompt Ensembling: Definition and Examples
Technique of submitting multiple variants of the same prompt to an AI model, then aggregating or comparing the responses to produce a more reliable result.
Prompt Injection: Definition and Examples
Attack technique consisting of inserting malicious instructions into a prompt to divert the intended behavior of a language model (LLM) and
Get new prompts every week
Join our newsletter.