[Paper Review] Teaching Algorithmic Reasoning via In-context Learning
This paper introduces Algorithmic Prompting to teach algorithmic reasoning to LLMs via in-context learning, achieving substantial improvements across arithmetic tasks (addition, subtraction, multiplication) and parity, with strong out-of-distribution generalization.
Large language models (LLMs) have shown increasing in-context learning capabilities through scaling up model and data size. Despite this progress, LLMs are still unable to solve algorithmic reasoning problems. While providing a rationale with the final answer has led to further improvements in multi-step reasoning problems, Anil et al. 2022 showed that even simple algorithmic reasoning tasks such as parity are far from solved. In this work, we identify and study four key stages for successfully teaching algorithmic reasoning to LLMs: (1) formulating algorithms as skills, (2) teaching multiple skills simultaneously (skill accumulation), (3) teaching how to combine skills (skill composition) and (4) teaching how to use skills as tools. We show that it is possible to teach algorithmic reasoning to LLMs via in-context learning, which we refer to as algorithmic prompting. We evaluate our approach on a variety of arithmetic and quantitative reasoning tasks, and demonstrate significant boosts in performance over existing prompting techniques. In particular, for long parity, addition, multiplication and subtraction, we achieve an error reduction of approximately 10x, 9x, 5x and 2x respectively compared to the best available baselines.
Motivation & Objective
- Identify four stages for teaching algorithms as skills to LLMs via in-context learning.
- Show that detailed, unambiguous algorithmic prompts enable robust OOD generalization on arithmetic tasks.
- Demonstrate skill accumulation by teaching multiple algorithms simultaneously.
- Explore skill composition and using learned algorithms as tools in broader math reasoning tasks.
Proposed method
- Define four learning stages: teaching algorithms as skills, skill accumulation, skill composition, and using skills as tools.
- Propose Algorithmic Prompting that provides detailed algorithm execution steps and explicit explanations within prompts.
- Compare algorithmic prompting to few-shot, chain-of-thought, and instruction-only baselines across multiple arithmetic tasks.
- Evaluate length generalization and out-of-distribution (OOD) performance by testing on longer answer lengths than seen in prompts.
- Perform ablations to assess impact of explicit calculations, natural language descriptions, and prompt ambiguity on performance.
- Investigate multi-algorithm learning (addition and subtraction) and composition (multi-number addition, multiplication-as-addition).
- Study using learned algorithms as tools in GSM8k and GSM8k-Hard, including a second-pass and dialogue-like tool-use approaches.
Experimental results
Research questions
- RQ1Can LLMs learn algorithms via in-context prompts that generalize to longer problem instances not seen in prompts?
- RQ2Does providing explicit, unambiguous algorithmic steps outperform traditional prompting strategies (few-shot, chain-of-thought, scratchpad) for arithmetic tasks?
- RQ3What is the impact of teaching multiple algorithms simultaneously and composing them into more complex tasks?
- RQ4Can learned algorithms serve as tools within broader mathematical reasoning tasks without hurting general reasoning?
Key findings
- Algorithmic Prompting achieves near-perfect accuracy and strong length (OOD) generalization on long addition problems, outperforming baselines by large margins.
- For addition, subtraction, multiplication, and parity, algorithmic prompting yields error reductions of approximately 10x, 9x, 5x, and 2x respectively over the best available baselines.
- Ablation studies show non-ambiguous explanations are crucial, and errors in algorithmic steps dramatically reduce performance when the prompt is systematically wrong.
- The model can learn multiple algorithms in a single prompt (skill accumulation) and can compose them to solve composite tasks with performance exceeding baselines.
- Using a learned algorithm as a tool can improve performance in math word problems, though potential interference with general reasoning can occur; second-pass and dialogue-style tool use mitigate some issues.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.