LLM-ERM: Sample-Efficient Program Learning via LLM-Guided Search
Shivam Singhal, Eran Malach, Tomaso Poggio, Tomer Galanti
TL;DR
This work tackles learning succinct algorithms from limited data by contrasting exhaustive short-program search with gradient-based methods that struggle on non-local tasks. It introduces LLM-ERM, a propose-and-verify framework that uses a pretrained reasoning LLM to generate a small set of candidate programs and selects among them via ERM on held-out data, avoiding gradient-based optimization. Theoretical analysis links the sample-efficiency-computational-efficiency trade-off to statistical-query lower bounds, showing exponential sample requirements for SGD on high-SQ-dimension classes like parity, while length-first enumeration remains sample-efficient but intractable computationally. Empirically, LLM-ERM achieves exact or near-exact recovery of target rules with just ~200 samples across parity variants, pattern matching, and primality, and generalizes to longer inputs, whereas SGD-based training overfits even with large datasets. The work suggests language-guided program synthesis as a practical path to robust, interpretable, and sample-efficient learning of succinct hypotheses beyond the reach of standard gradient-based training.
Abstract
We seek algorithms for program learning that are both sample-efficient and computationally feasible. Classical results show that targets admitting short program descriptions (e.g., with short ``python code'') can be learned with a ``small'' number of examples (scaling with the size of the code) via length-first program enumeration, but the search is exponential in description length. Consequently, Gradient-based training avoids this cost yet can require exponentially many samples on certain short-program families. To address this gap, we introduce LLM-ERM, a propose-and-verify framework that replaces exhaustive enumeration with an LLM-guided search over candidate programs while retaining ERM-style selection on held-out data. Specifically, we draw $k$ candidates with a pretrained reasoning-augmented LLM, compile and check each on the data, and return the best verified hypothesis, with no feedback, adaptivity, or gradients. Theoretically, we show that coordinate-wise online mini-batch SGD requires many samples to learn certain short programs. {\em Empirically, LLM-ERM solves tasks such as parity variants, pattern matching, and primality testing with as few as 200 samples, while SGD-trained transformers overfit even with 100,000 samples}. These results indicate that language-guided program synthesis recovers much of the statistical efficiency of finite-class ERM while remaining computationally tractable, offering a practical route to learning succinct hypotheses beyond the reach of gradient-based training.
