Program of Thoughts Prompting: Disentangling Computation from Reasoning for Numerical Reasoning Tasks
Written for the Research library (claude-opus-5-5) from the paper text, in our own words: the license "arXiv — non-exclusive license to distribute" does not allow redistributing the text itself. Original — arxiv.org/pdf/2211.12588v4
Summary
Program of Thoughts (PoT) is a prompting method in which a large language model (mainly Codex, code-davinci-002) writes a short Python program instead of a verbal chain of reasoning. An interpreter then does the computation, using SymPy for equations when needed. The model is responsible only for breaking the problem into steps, while arithmetic, iteration and equation solving are handed to an exact executor. PoT rests on two principles. The first is multi-step decomposition: the program breaks an expression into intermediate variables. The second is semantic binding: the variables have meaningful names. There are few-shot and zero-shot variants. In the zero-shot variant, the "#" token is suppressed so the model does not drift into writing comments. PoT can also be combined with self-consistency, and a two-stage PoT→CoT mode is used for AQuA. The method is evaluated on five MWP datasets (GSM8K, AQuA, SVAMP, TabMWP, MultiArith) and three financial ones (FinQA, ConvFinQA, TATQA). For the subtask tree, the paper is a strong argument for our design: the model builds the structure of steps, and a separate exact core computes the numbers. The ablations show that both step decomposition and naming intermediate quantities give a substantial gain.
Key points
- Features: the problem text; tables are linearized (columns separated by "|", rows by line breaks); named intermediate variables carry meaning.
- Architecture: no training; a few-shot (4–8 examples) or zero-shot prompt to an LLM, followed by Python execution; self-consistency by voting.
- Few-shot greedy results (Table 2): PoT-Codex — GSM8K 71.6, AQuA 54.1, SVAMP 85.2, TabMWP 73.2, FinQA 64.5, ConvFinQA 64.6, TATQA 69.0; Codex CoT — 63.1 / 45.3 / 76.4 / 65.2 / 40.4 / 45.6 / 61.4.
- Results with SC: PoT-SC-Codex — GSM8K 80.0, AQuA 58.6, SVAMP 89.1, TabMWP 81.8; Codex CoT-SC — 78.0 / 52.0 / 86.8 / 75.4. With GPT-4: PoT — GSM8K 97.2, AQuA 84.4, SVAMP 97.4.
- Zero-shot (Table 3): PoT — GSM8K 57.0, AQuA 43.9, SVAMP 70.8, TabMWP 66.5, MultiArith 92.2; zero-shot CoT (GPT-3) — 40.5 / 31.9 / 63.7 / 53.5 / 79.3.
- Ablations (Table 6): on GSM8K, without variable names 60.2, direct equation generation 45.8, vs. 71.6; compared with PaL (Table 5) — SVAMP 85.2 vs 79.4, ASDiv 85.2 vs 79.6. Small open models (codegen-16B, xgen-7B) reach only 8–13 on GSM8K.
- Limitations: errors on TATQA are 47% incorrect value grounding and 33% incorrect logic; AQuA remains hard; a sandbox is required for code execution.
Cited by
- Large Language Models for Mathematical Reasoning: Progresses and Challenges
- TheoremQA: A Theorem-driven Question Answering Dataset
- AlphaMath Almost Zero: Process Supervision without Process
- Towards Reasoning Era: A Survey of Long Chain-of-Thought for Reasoning Large Language Models
- Promptbreeder: Self-Referential Self-Improvement Via Prompt Evolution
- Scaling Synthetic Data Creation with 1,000,000,000 Personas
- CRITIC: Large Language Models Can Self-Correct with Tool-Interactive Critiquing
- ToRA: A Tool-Integrated Reasoning Agent for Mathematical Problem Solving
- Evaluating Large Language Models: A Comprehensive Survey
- ToolkenGPT: Augmenting Frozen Language Models with Massive Tools via Tool Embeddings
- Towards Reasoning in Large Language Models: A Survey
- A Survey on Large Language Models for Code Generation
- DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines
- GSM-Plus: A Comprehensive Benchmark for Evaluating the Robustness of LLMs as Mathematical Problem Solvers
- Deductive Verification of Chain-of-Thought Reasoning
- LLM+P: Empowering Large Language Models with Optimal Planning Proficiency
- Chameleon: Plug-and-Play Compositional Reasoning with Large Language Models
- MathVista: Evaluating Mathematical Reasoning of Foundation Models in Visual Contexts
- Faithful Chain-of-Thought Reasoning
- Augmented Language Models: a Survey
- LEVER: Learning to Verify Language-to-Code Generation with Execution
- LINC: A Neurosymbolic Approach for Logical Reasoning by Combining Language Models with First-Order Logic Provers
- Logic-LM: Empowering Large Language Models with Symbolic Solvers for Faithful Logical Reasoning
- Reasoning with Language Model Prompting: A Survey
- Is ChatGPT a General-Purpose Natural Language Processing Task Solver?
- Tool Learning with Foundation Models
- A Systematic Survey of Prompt Engineering in Large Language Models: Techniques and Applications
- DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models
- Large Language Models Can Be Easily Distracted by Irrelevant Context
- Can LLMs Generate Novel Research Ideas? A Large-Scale Human Study with 100+ NLP Researchers
- To CoT or not to CoT? Chain-of-thought helps mainly on math and symbolic reasoning
- ViperGPT: Visual Inference via Python Execution for Reasoning
- ToolAlpaca: Generalized Tool Learning for Language Models with 3000 Simulated Cases
- MathCoder: Seamless Code Integration in LLMs for Enhanced Mathematical Reasoning
- MINT: Evaluating LLMs in Multi-turn Interaction with Tools and Language Feedback
- SciBench: Evaluating College-Level Scientific Problem-Solving Abilities of Large Language Models
- Towards Understanding Chain-of-Thought Prompting: An Empirical Study of What Matters
- Self-Evaluation Guided Beam Search for Reasoning
- MetaMath: Bootstrap Your Own Mathematical Questions for Large Language Models
- MAmmoTH: Building Math Generalist Models through Hybrid Instruction Tuning
- MAmmoTH2: Scaling Instructions from the Web
- Multimodal Chain-of-Thought Reasoning in Language Models
- A Survey of Large Language Models
- Solving Challenging Math Word Problems Using GPT-4 Code Interpreter with Code-based Self-Verification
- ToolQA: A Dataset for LLM Question Answering with External Tools
- BigCodeBench: Benchmarking Code Generation with Diverse Function Calls and Complex Instructions
Cite
@misc{chen2022program,
title = {{Program of Thoughts Prompting: Disentangling Computation from Reasoning for Numerical Reasoning Tasks}},
author = {Chen, Wenhu and Ma, Xueguang and Wang, Xinyi and Cohen, William W.},
year = {2022},
doi = {10.48550/arxiv.2211.12588},
eprint = {2211.12588},
archivePrefix = {arXiv},
url = {https://doi.org/10.48550/arxiv.2211.12588}
}References
- Aida Amini, Saadia Gabriel, Shanchuan Lin, Rik Koncel-Kedziorski, Yejin Choi, and Hannaneh Hajishirzi. Mathqa: Towards interpretable math word problem solving with operation-based formalisms. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Lin… find our card
- Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie Cai, Michael Terry, Quoc Le, et al. Program synthesis with large language models. arXiv preprint arXiv:2108.07732, 2021. find our card
- Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020. find
- Mark Chen, Jerry Tworek, Heewoo Jun, Qiming Yuan, Henrique Ponde de Oliveira Pinto, Jared Kaplan, Harri Edwards, Yuri Burda, Nicholas Joseph, Greg Brockman, et al. Evaluating large language models trained on code. arXiv preprint arXiv:2107.03374, 2021a. find our card
- Wenhu Chen. Large language models are few (1)-shot table reasoners. arXiv preprint arXiv:2210.06710, 2022. find
- Zhiyu Chen, Wenhu Chen, Charese Smiley, Sameena Shah, Iana Borova, Dylan Langdon, Reema Moussa, Matt Beane, Ting-Hao Huang, Bryan R Routledge, et al. Finqa: A dataset of numerical reasoning over financial data. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing… find our card
- Zhiyu Chen, Shiyang Li, Charese Smiley, Zhiqiang Ma, Sameena Shah, and William Yang Wang. Convfinqa: Exploring the chain of numerical reasoning in conversational finance question answering. arXiv preprint arXiv:2210.03849, 2022. find
- Zhoujun Cheng, Tianbao Xie, Peng Shi, Chengzu Li, Rahul Nadkarni, Yushi Hu, Caiming Xiong, Dragomir Radev, Mari Ostendorf, Luke Zettlemoyer, et al. Binding language models in symbolic languages. arXiv preprint arXiv:2210.02875, 2022. find our card
- Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, et al. Palm: Scaling language modeling with pathways. arXiv preprint arXiv:2204.02311, 2022. find
- Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Jacob Hilton, Reiichiro Nakano, Christopher Hesse, and John Schulman. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021. find our card
- Andrew Drozdov, Nathanael Schärli, Ekin Akyürek, Nathan Scales, Xinying Song, Xinyun Chen, Olivier Bousquet, and Denny Zhou. Compositional semantic parsing with large language models. arXiv preprint arXiv:2209.15003, 2022. find
- Nan Du, Yanping Huang, Andrew M Dai, Simon Tong, Dmitry Lepikhin, Yuanzhong Xu, Maxim Krikun, Yanqi Zhou, Adams Wei Yu, Orhan Firat, et al. Glam: Efficient scaling of language models with mixture-of-experts. In International Conference on Machine Learning, pp. 5547–5569. PMLR, 2022. find our card
- Dheeru Dua, Yizhong Wang, Pradeep Dasigi, Gabriel Stanovsky, Sameer Singh, and Matt Gardner. Drop: A reading comprehension benchmark requiring discrete reasoning over paragraphs. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Hum… find our card
- Luyu Gao, Aman Madaan, Shuyan Zhou, Uri Alon, Pengfei Liu, Yiming Yang, Jamie Callan, and Graham Neubig. Pal: Program-aided language models. arXiv preprint arXiv:2211.10435, 2022. find
- Zhibin Gou, Zhihong Shao, Yeyun Gong, Yelong Shen, Yujiu Yang, Nan Duan, and Weizhu Chen. Critic: Large language models can self-correct with tool-interactive critiquing. arXiv preprint arXiv:2305.11738, 2023. find our card
- Dan Hendrycks, Collin Burns, Saurav Kadavath, Akul Arora, Steven Basart, Eric Tang, Dawn Song, and Jacob Steinhardt. Measuring mathematical problem solving with the math dataset. arXiv preprint arXiv:2103.03874, 2021. find our card
- Mohammad Javad Hosseini, Hannaneh Hajishirzi, Oren Etzioni, and Nate Kushman. Learning to solve arithmetic word problems with verb categorization. In EMNLP, pp. 523–533, 2014. find our card
- Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei. Scaling laws for neural language models. arXiv preprint arXiv:2001.08361, 2020. find
- Takeshi Kojima, Shixiang Shane Gu, Machel Reid, Yutaka Matsuo, and Yusuke Iwasawa. Large language models are zero-shot reasoners. arXiv preprint arXiv:2205.11916, 2022. find our card
- Rik Koncel-Kedziorski, Hannaneh Hajishirzi, Ashish Sabharwal, Oren Etzioni, and Siena Dumas Ang. Parsing algebraic word problems into equations. Transactions of the Association for Computational Linguistics, 3:585–597, 2015. find
- Fangyu Lei, Shizhu He, Xiang Li, Jun Zhao, and Kang Liu. Answering numerical reasoning questions in table-text hybrid contents with graph-based encoder and tree-based decoder. In Proceedings of the 29th International Conference on Computational Linguistics, pp. 1379–1390, 2022. find
- Wang Ling, Dani Yogatama, Chris Dyer, and Phil Blunsom. Program induction by rationale generation: Learning to solve and explain algebraic word problems. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 158–167, 2017. find
- Pan Lu, Liang Qiu, Kai-Wei Chang, Ying Nian Wu, Song-Chun Zhu, Tanmay Rajpurohit, Peter Clark, and Ashwin Kalyan. Dynamic prompt learning via policy gradient for semi-structured mathematical reasoning. arXiv preprint arXiv:2209.14610, 2022. find our card
- Shen-Yun Miao, Chao-Chun Liang, and Keh-Yih Su. A diverse corpus for evaluating and developing english math word problem solvers. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 975–984, 2020. find
- Sewon Min, Xinxi Lyu, Ari Holtzman, Mikel Artetxe, Mike Lewis, Hannaneh Hajishirzi, and Luke Zettlemoyer. Rethinking the role of demonstrations: What makes in-context learning work? arXiv preprint arXiv:2202.12837, 2022. find our card
- Swaroop Mishra, Matthew Finlayson, Pan Lu, Leonard Tang, Sean Welleck, Chitta Baral, Tanmay Rajpurohit, Oyvind Tafjord, Ashish Sabharwal, Peter Clark, and Ashwin Kalyan. Lila: A unified benchmark for mathematical reasoning. In Proceedings of the 2022 Conference on Empirical Methods in Natural Langua… find our card
- Erik Nijkamp, Bo Pang, Hiroaki Hayashi, Lifu Tu, Huan Wang, Yingbo Zhou, Silvio Savarese, and Caiming Xiong. Codegen: An open large language model for code with multi-turn program synthesis. arXiv preprint arXiv:2203.13474, 2022. find
- Maxwell Nye, Anders Johan Andreassen, Guy Gur-Ari, Henryk Michalewski, Jacob Austin, David Bieber, David Dohan, Aitor Lewkowycz, Maarten Bosma, David Luan, et al. Show your work: Scratchpads for intermediate computation with language models. arXiv preprint arXiv:2112.00114, 2021. find our card
- OpenAI. Gpt-4 technical report. arXiv preprint arXiv:2303.08774, 2023. find our card
- Bhargavi Paranjape, Scott Lundberg, Sameer Singh, Hannaneh Hajishirzi, Luke Zettlemoyer, and Marco Tulio Ribeiro. Art: Automatic multi-step reasoning and tool-use for large language models. arXiv preprint arXiv:2303.09014, 2023. find
- Arkil Patel, Satwik Bhattamishra, and Navin Goyal. Are NLP models really able to solve simple math word problems? In Proceedings of the 2021 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 2080–2094, Online, June 2021. Assoc… find our card
- Jack W Rae, Sebastian Borgeaud, Trevor Cai, Katie Millican, Jordan Hoffmann, Francis Song, John Aslanides, Sarah Henderson, Roman Ring, Susannah Young, et al. Scaling language models: Methods, analysis & insights from training gopher. arXiv preprint arXiv:2112.11446, 2021. find
- Subhro Roy and Dan Roth. Solving general arithmetic word problems. In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pp. 1743–1752, 2015. find our card
- Subhro Roy and Dan Roth. Mapping to declarative knowledge for word problem solving. Transactions of the Association for Computational Linguistics, 6:159–172, 2018. find our card
- David Saxton, Edward Grefenstette, Felix Hill, and Pushmeet Kohli. Analysing mathematical reasoning abilities of neural models. arXiv preprint arXiv:1904.01557, 2019. find our card
- Timo Schick, Jane Dwivedi-Yu, Roberto Dessì, Roberta Raileanu, Maria Lomeli, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. Toolformer: Language models can teach themselves to use tools. arXiv preprint arXiv:2302.04761, 2023. find our card
- Shaden Smith, Mostofa Patwary, Brandon Norick, Patrick LeGresley, Samyam Rajbhandari, Jared Casper, Zhun Liu, Shrimai Prabhumoye, George Zerveas, Vijay Korthikanti, et al. Using deepspeed and megatron to train megatron-turing nlg 530b, a large-scale generative language model. arXiv preprint arXiv:22… find our card
- Mirac Suzgun, Nathan Scales, Nathanael Schärli, Sebastian Gehrmann, Yi Tay, Hyung Won Chung, Aakanksha Chowdhery, Quoc V Le, Ed H Chi, Denny Zhou, et al. Challenging big-bench tasks and whether chain-of-thought can solve them. arXiv preprint arXiv:2210.09261, 2022. find our card
- Romal Thoppilan, Daniel De Freitas, Jamie Hall, Noam Shazeer, Apoorv Kulshreshtha, Heng-Tze Cheng, Alicia Jin, Taylor Bos, Leslie Baker, Yu Du, et al. Lamda: Language models for dialog applications. arXiv preprint arXiv:2201.08239, 2022. find our card
- Bin Wang, Jiangzhou Ju, Yunlin Mao, Xin-Yu Dai, Shujian Huang, and Jiajun Chen. A numerical reasoning question answering system with fine-grained retriever and the ensemble of multiple generators for finqa. arXiv preprint arXiv:2206.08506, 2022a. — [arXiv:2206.08506](https://arxiv.org/abs/2206.08506) find
- Lei Wang, Wanyu Xu, Yihuai Lan, Zhiqiang Hu, Yunshi Lan, Roy Ka-Wei Lee, and Ee-Peng Lim. Plan-and-solve prompting: Improving zero-shot chain-of-thought reasoning by large language models. arXiv preprint arXiv:2305.04091, 2023a. find
- Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, and Denny Zhou. Self-consistency improves chain of thought reasoning in language models. arXiv preprint arXiv:2203.11171, 2022b. find our card
- Yue Wang, Hung Le, Akhilesh Deepak Gotmare, Nghi DQ Bui, Junnan Li, and Steven CH Hoi. Codet5+: Open code large language models for code understanding and generation. arXiv preprint arXiv:2305.07922, 2023b. find
- Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Ed Chi, Quoc Le, and Denny Zhou. Chain of thought prompting elicits reasoning in large language models. arXiv preprint arXiv:2201.11903, 2022. find our card
- Sang Michael Xie, Aditi Raghunathan, Percy Liang, and Tengyu Ma. An explanation of in-context learning as implicit bayesian inference. In International Conference on Learning Representations, 2021. find our card
- Yuxi Xie, Kenji Kawaguchi, Yiran Zhao, Xu Zhao, Min-Yen Kan, Junxian He, and Qizhe Xie. Decomposition enhances reasoning via self-evaluation guided decoding. arXiv preprint arXiv:2305.00633, 2023. find our card
- Shunyu Yao, Jeffrey Zhao, Dian Yu, Izhak Shafran, Karthik R Narasimhan, and Yuan Cao. React: Synergizing reasoning and acting in language models. In NeurIPS 2022 Foundation Models for Decision Making Workshop, 2022. find our card
- Denny Zhou, Nathanael Schärli, Le Hou, Jason Wei, Nathan Scales, Xuezhi Wang, Dale Schuurmans, Olivier Bousquet, Quoc Le, and Ed Chi. Least-to-most prompting enables complex reasoning in large language models. arXiv preprint arXiv:2205.10625, 2022. find our card
- Fengbin Zhu, Wenqiang Lei, Youcheng Huang, Chao Wang, Shuo Zhang, Jiancheng Lv, Fuli Feng, and Tat-Seng Chua. Tat-qa: A question answering benchmark on a hybrid of tabular and textual content in finance. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and t… find our card