[KongchangAI]
· 2 min read· 1,190 words

Language Model Priors + Interactive Queries: Program Induction Accuracy Improved by 22%

Language Model Priors + Interactive Queries: Program Induction Accuracy Improved by 22%

The study proposes a Bayesian interactive program induction framework using a language model prior and greedy queries to resolve ambiguity, significantly improving accuracy and sample efficiency.

The study re-examines program induction from a Bayesian perspective and formalizes it as posterior concentration: given a language model prior, the learner actively selects the most informative inputs and queries the user for outputs, so posterior mass concentrates on the target program. Theory proves greedy query selection terminates after O(1/γ log 1/p0(f*)) queries and returns an approximately equivalent program. Using importance sampling, it improves accuracy by 22 percentage points and reduces examples by 10.5× on CodeARC versus a language-model-only agent, validating the combination of a Bayesian framework and language model priors.

Bayesian Perspective on Program Induction

Program induction aims to recover a program from a small number of input-output examples, thereby lowering the barrier to programming—users only need to demonstrate the desired behavior instead of manually implementing it. However, recovering a program from limited examples is inherently ambiguous: infinitely many programs may produce different outputs on unseen inputs while remaining consistent with the finite examples. Recently, a study re-examined this problem from a Bayesian perspective and proposed an interactive program induction framework that uses a language model as a prior and actively maximizes information gain through queries, significantly improving accuracy on the CodeARC benchmark.

Interactive program induction framework diagram

This study formulates program induction as a posterior concentration process: given a program prior (p^0), after observing more input-output examples, the posterior probability mass of the target program gradually concentrates. In an interactive setting, the learner actively selects the most informative inputs and queries an oracle (e.g., the user) for outputs. Theoretical analysis shows that a greedy query selection algorithm terminates after (\mathcal{O}(\frac{1}{\gamma}\log 1/p^0(f^\star))) queries and, when no other class surpasses it under the prior, returns a program approximately equivalent to the target (f^\star).

The key to this framework is using a language model as the prior and estimating the query selection objective via importance sampling under a PAC-style relaxed definition of program equivalence. The theoretical guarantee provides an interpretable termination condition for the algorithm, while the introduction of the language model makes the prior closer to the real distribution of programs.

Posterior concentration is a core concept in Bayesian statistics: as observed data increases, the mass of the posterior distribution gradually concentrates around the true parameter, with the rate determined jointly by the prior mass and the data-generating distribution. In program induction, the "parameter" is an entire program, the prior (p^0) is the program distribution given by the language model, and the observations are the input-output examples provided by the user. The theoretical convergence bound (\mathcal{O}(\frac{1}{\gamma}\log 1/p^0(f^\star))) reveals two key factors: (\gamma) reflects how well each query can distinguish the target program, while (p^0(f^\star)) reflects how much the prior favors the true program—the more the prior "favors" the target program, the fewer queries are needed. This is precisely the theoretical motivation for introducing a language model prior.

PAC-style relaxed program equivalence: the classical PAC learning framework requires the learned hypothesis to exactly match the target concept on the input distribution, but in program induction, many semantically equivalent programs (e.g., sorting functions implemented in different ways) differ greatly syntactically, and exact equivalence is difficult to determine from finite examples. Therefore, the study adopts a relaxed equivalence definition: rather than requiring exact agreement on every input, it allows deviations on low-probability inputs. This relaxation makes "approximately recovering the target program" an operational goal and provides a mathematical basis for importance sampling estimation.

Greedy Queries and Importance Sampling

The core of the algorithm is to greedily select the most informative query. At each step, the learner evaluates the potential impact of candidate inputs on the posterior distribution and selects the input that best distinguishes candidate programs. Because exact posterior computation is difficult, the study uses importance sampling to estimate the query selection objective, thereby efficiently approximating the optimal query.

This design enables the algorithm to balance query count and accuracy: theory guarantees a logarithmic number of queries, while in practice the language model prior further reduces the required examples. On the CodeARC benchmark, the algorithm improves accuracy by up to 22 percentage points compared with an agent that uses only a language model, while observing up to 10.5× fewer input-output examples.

Importance sampling is a Monte Carlo technique that estimates expectations under a hard-to-sample distribution using an easy-to-sample distribution: it samples from a proposal distribution (q) and corrects the bias with weights (p(x)/q(x)), thereby unbiasedly estimating statistics under the target distribution (p). In this algorithm, the true posterior (p(f \mid \text{examples})) is difficult to compute exactly because it requires summing over all possible programs; the study therefore constructs a proposal distribution from the language model prior and the observed examples, samples and reweights candidate programs, and approximately estimates the "information gain" of each candidate input on the posterior. As a result, greedy query selection does not need to enumerate the entire program space and can approach the optimal query at a computable cost—this is the key engineering technique behind the algorithm's significant reduction in query count in experiments.

Experimental Results and Significance

Experiments on the CodeARC benchmark show that interactive program induction combined with a language model prior can significantly improve sample efficiency. A 22-percentage-point accuracy improvement means more complex programs can be correctly induced, while a 10.5× reduction in query count lowers the burden on user interaction. These results validate the effectiveness of combining a Bayesian framework with a language model prior.

This study provides a scalable path for program induction: capture prior knowledge about programs through a language model, then resolve ambiguity through active queries. In the future, this approach is expected to be applied to broader programming assistance scenarios, enabling non-expert users to obtain reliable programs from a small number of examples.

The CodeARC benchmark is a test set for evaluating program induction and program synthesis capabilities. Its tasks typically provide a set of input-output examples and require a model or algorithm to recover a function implementation consistent with the examples. The benchmark emphasizes generalization from few examples to unseen inputs, so it directly measures sample efficiency and induction accuracy. The reported "22 percentage point accuracy improvement" and "10.5× fewer examples" are both measured under the benchmark's interactive setting relative to an agent that uses only a language model, indicating that the active query mechanism can more effectively resolve program ambiguity under the same interaction budget.

Conclusion

This study formalizes program induction as a Bayesian posterior concentration problem, proposes a greedy query selection algorithm, and uses a language model as a prior. It provides theoretical guarantees for query efficiency and achieves improvements in both accuracy and sample efficiency in experiments. Its core contribution is to provide a rigorous framework and a practical algorithm for interactive program induction, advancing the development of few-shot programming.

One-line Summary

This study proposes a Bayesian interactive program induction framework that uses a language model as a prior and greedy queries to resolve ambiguity, significantly improving accuracy and sample efficiency.

Paragraph Summary

This study re-examines program induction from a Bayesian perspective and formalizes it as a posterior concentration process: given a program prior provided by a language model, the learner actively selects the most informative inputs and queries the user for outputs, so that posterior mass gradually concentrates on the target program. Theoretical analysis proves that the greedy query selection algorithm terminates after O(1/γ log 1/p0(f*)) queries and can return an approximately equivalent target program. To implement the algorithm efficiently, the study uses importance sampling to estimate the query selection objective. On the CodeARC benchmark, compared with an agent that uses only a language model, accuracy improves by 22 percentage points and required examples are reduced by 10.5×, validating the effectiveness of combining a Bayesian framework with a language model prior.

#program induction#language model prior#Bayesian posterior concentration#greedy query selection#importance sampling#CodeARC benchmark
Share:

Related articles