IN THIS BREAKDOWN · 10 SECTIONS
You can read 19% of this breakdown.
The paper in one minute
Chain-of-thought prompting made language models much better at word problems by having them write out intermediate steps. It left a gap: the model can decompose a problem correctly and still get 93 + 39 wrong, and the errors multiply with larger numbers or longer chains. Luyu Gao, Aman Madaan, Shuyan Zhou, Graham Neubig and colleagues at Carnegie Mellon asked why the model should do the arithmetic at all.
PAL, program-aided language models, keeps the model's role to understanding the problem and writing the steps, but writes those steps as Python. The few-shot prompt shows example questions answered with short programs: meaningful variable names, comments in plain language, and a final answer variable. Given a new question, the model writes a similar program, a Python interpreter runs it, and the result is the answer. The model never computes anything itself.
Across 13 tasks, eight math word-problem sets, three symbolic-reasoning tasks from BIG-Bench Hard and two algorithmic tasks, PAL with the Codex code model beat chain-of-thought prompting with the same model, and often beat much larger models. The most telling result is GSM-HARD, the authors' version of GSM8K with one number in each problem replaced by an integer of up to seven digits. Chain of thought fell from 65.6% to 23.1%; PAL went from 72.0% to 61.2%.
Research notes: the problem, approach and results
GSM-HARD solve rate, PAL versus chain of thought with the same model (Codex)
inspected failures where chain of thought wrote the same reasoning for big and small numbers: arithmetic, not logic, broke
GSM8K solve rate when the model wrote Python but executed it itself, against 72.0 with an interpreter
Chain-of-thought prompting gets models to decompose problems into steps, but they still make arithmetic and logical slips when executing those steps, especially with large numbers.
Prompt with examples whose reasoning is written as Python statements with comments. The model writes a program for the new problem; a Python interpreter runs it and its result is the answer.
With Codex, PAL beat chain-of-thought on all 13 math, symbolic and algorithmic tasks tested, reached 72.0% on GSM8K against 56.9% for PaLM-540B with chain of thought, and held 61.2% on a large-number version where chain of thought fell to 23.1%.
Why it matters to an FDE
Customer workflows are full of arithmetic: invoice totals, prorated refunds, inventory counts, date windows, unit conversions. A model that reasons in prose will occasionally get the arithmetic wrong, confidently and invisibly. PAL is the pattern that removes that class of error.
Never let the model do the math in text. Have it produce an expression, a small program or a structured calculation that code executes. The paper's large-number test shows how fast in-text arithmetic degrades.
The remaining errors are reading errors. A program that subtracts returned items instead of adding them runs perfectly and gives the wrong answer. The interpreter guarantees the arithmetic, not the interpretation. Validate inputs and add sanity checks to generated programs.
Readable code is reviewable. Variable names and comments make each step inspectable, by a person or by an automated check. That is an audit trail chain of thought does not give you.
It is the seed of code actions. PAL is one program per question with no feedback. CodeAct and later agents extend the same idea to multi-step tasks with tools and error messages.
Sandbox it. Running model-written code needs the same containment as any code action, even when it only does arithmetic.
Understand the mechanism. Try it on a real problem.
Unlock this breakdown and 99 more papers.
Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.
6 months · One payment · No auto-renewal
- ◇1 architecture diagram
- </>1 runnable code experiment
- ▦2 results tables
- ?5 interview questions with answers
- 03Key takeaways
How PAL prompts are built, every result family, the ablations, and the misreadings to avoid
Free account - 04How it works
The prompt format, inference, the benchmarks including GSM-HARD, and the ablation setups
Premium - 05The numbers that matter
Margins, robustness to number size, model dependence, and one inconsistency
Premium - 06Try it yourself
Run PAL's own example, break it with a misreading, and model why big numbers hurt text arithmetic
Premium - 07Where it breaks
The limits of offloading to an interpreter, and of this evaluation
Premium - 08Using it on a deployment
Putting program-aided reasoning into a customer workflow safely
Premium - 09Interview angles
Five questions this paper prepares you for, with answer hints
Premium - 10Read next
Where to go from here on this site
Premium
