Introduction
Large Language Models (LLMs) have demonstrated remarkable capabilities in natural language understanding, yet they frequently struggle with complex, multi-step reasoning tasks. Existing techniques like Chain of Thought (CoT) and Program of Thought (PoT) attempt to bridge this gap. However, PoT often suffers from a "triviality" problem, where the model avoids actual computation by hardcoding answers within comments or failing to structure the problem effectively. This paper introduces Per-Instance Program Synthesis (PIPS), a framework designed to enforce faithful reasoning by decoupling perception from logic and iteratively refining generated code.
The PIPS Framework
PIPS addresses the shortcomings of standard program synthesis through a structured, three-stage pipeline that ensures models compute answers rather than guessing them.
1. Selective Program Synthesis
Not every problem requires a Python script. PIPS employs an "Algorithmicity Selector" that evaluates a problem instance against ten criteria—such as formalization ease and logical complexity—to decide whether to use text-based CoT or code-based PIPS. This prevents unnecessary overhead for simple prose-based tasks.
2. Symbolic Extraction
A major failure point in PoT is the attempt to perform perception (e.g., counting objects in an image) directly within the code. PIPS mandates a "Symbolic Extraction" step where the LLM first parses the input into a structured JSON format (symbols). This separates the messy task of perception from the rigid task of logical execution.
3. Iterative Synthesis with Structural Feedback
The model generates a program that must operate on the extracted symbols. A dedicated "PIPS Evaluator" then inspects the code for "smells," such as syntax errors, incorrect return types, or hardcoded answers. If the code fails these checks, the evaluator provides specific feedback, prompting the model to iterate (up to 30 times) until a valid, non-trivial program is produced.
Experimental Results
The researchers evaluated PIPS across 30 diverse benchmarks, including Big Bench Extra Hard (BBEH), Visual Question Answering (CLEVR), and mathematical reasoning (OmniMath).
Accuracy and Reliability
PIPS achieved a significant performance boost, improving absolute harmonic mean accuracy by up to 8.6% over PoT and 9.4% over CoT. On algorithmic tasks, PIPS reduced the generation of undesirable "trivial" programs (where the answer is hardcoded) by 65.1% compared to standard PoT using Gemini-2.0-Flash.
The "Triviality" Trap
The study revealed that in standard PoT, over 50% of programs are trivial. By forcing the model to use extracted symbols and validating the code structure, PIPS ensures that the reasoning is "faithful"—the answer is a direct result of the program's execution on the data, not a hallucinated guess.
Conclusion and Future Work
PIPS demonstrates that making LLMs "think" with code requires more than just prompting for a script; it requires a structured environment that enforces logical consistency. While PIPS significantly improves reasoning reliability, it remains dependent on the accuracy of the initial symbolic extraction. Future research may explore hybrid models where CoT and PIPS work in tandem to solve different sub-components of a single complex problem.
Summary updated