Once Upon an Input: Reasoning via Per-Instance Program Synthesis
Adam Stein, Neelay Velingker, Mayur Naik, Eric Wong
TL;DR
This work addresses the difficulty of multi-step reasoning in large language models by introducing Per-Instance Program Synthesis (PIPS), which selectively synthesizes and refines executable programs at the instance level. A learned confidence switch decides, per instance, whether to use direct inference via chain-of-thought or to generate a structured program, thereby avoiding unnecessary code generation on non-algorithmic tasks. PIPS iteratively refines programs through structural feedback and explicit instance-specific symbolic extraction, reducing undesirable code and improving solution correctness across 30 frontier datasets and multiple LLMs. The approach yields up to 8.6% absolute harmonic mean accuracy gains over Program of Thought and 9.4% over Chain of Thought, while maintaining or improving performance on non-algorithmic tasks and reducing brittle handling of unstructured inputs. These results suggest that instance-level synthesis, guided by robust feedback and symbol extraction, is a promising direction for scalable, reliable reasoning in AI systems.
Abstract
Large language models (LLMs) excel at zero-shot inference but continue to struggle with complex, multi-step reasoning. Recent methods that augment LLMs with intermediate reasoning steps such as Chain of Thought (CoT) and Program of Thought (PoT) improve performance but often produce undesirable solutions, especially in algorithmic domains. We introduce Per-Instance Program Synthesis (PIPS), a method that generates and refines programs at the instance-level using structural feedback without relying on task-specific guidance or explicit test cases. To further improve performance, PIPS incorporates a confidence metric that dynamically chooses between direct inference and program synthesis on a per-instance basis. Experiments across three frontier LLMs and 30 benchmarks including all tasks of Big Bench Extra Hard (BBEH), visual question answering tasks, relational reasoning tasks, and mathematical reasoning tasks show that PIPS improves the absolute harmonic mean accuracy by up to 8.6% and 9.4% compared to PoT and CoT respectively, and reduces undesirable program generations by 65.1% on the algorithmic tasks compared to PoT with Gemini-2.0-Flash.
