Is Programming by Example solved by LLMs?

Programming-by-Examples (PBE) aims to generate an algorithm from input-output examples. Such systems are practically and theoretically important: from an end-user perspective, they are deployed to millions of people, and from an AI perspective, PBE corresponds to a very general form of few-shot inductive inference. Given the success of Large Language Models (LLMs) in code-generation tasks, we investigate here the extent to which LLMs can be said to have"solved"PBE. We experiment on classic domains such as lists and strings, and an uncommon graphics programming domain not well represented in typical pretraining data. We find that pretrained models are not effective at PBE, but that they can be fine-tuned for much higher performance, provided the test problems are in-distribution. We analyze empirically what causes these models to succeed and fail, and take steps toward understanding how to achieve better out-of-distribution generalization. Collectively these results suggest that LLMs make strong progress toward solving the typical suite of PBE tasks, potentially increasing the flexibility and applicability of PBE systems, while also identifying ways in which LLMs still fall short.

Paper

Similar papers

Peer review

Reviewer k14y5/10 · confidence 4/52024-06-28

Summary

This paper investigates the effectiveness of Large Language Models (LLMs) in solving Programming-by-Example (PBE) tasks. Evaluations are conducted on three classic PBE domains including lists and strings, as well as a graphics programming domain. The findings suggest that while pretrained LLMs are not inherently effective for PBE, fine-tuning significantly enhances their performance on in-distribution tasks.

Strengths

- Thorough evaluation and detailed analysis. - Clear cases and illustrations. - Addressing the challenge of small datasets for fine-tuning LLMs.

Weaknesses

- In the experiments, there are no LLM competitors in the graphics domain. Any reasons? - Why are only FlashFill and LambdaBeam compared in the experiments of Figure 6? - The adaptation method used to improve out-of-distribution performance exposes the model to the test set content beforehand. Especially in string tasks, directly selecting the adaptation seed program from all test cases may be unfair. - The examples used in the experiments are relatively weak and do not closely resemble real-world programming tasks. - If the adaptation's seed program is not provided, even after fine-tuning, the out-of-distribution generalization ability of LLMs still appear to be quite weak. Typos: in abs: potentially increasingly the flexibility -> potentially increasing the flexibility

Questions

- How does GPT-4 perform on the entire PROSE dataset? - Would the key factors that lead to the success or failure of LLMs differ across problems in three different domains?

Rating

5

Confidence

4

Soundness

3

Presentation

3

Contribution

2

Limitations

NA

Reviewer mgYE6/10 · confidence 5/52024-07-10

Summary

The paper focuses on the classical task of Programming By Example (PBE): given some (input,output) pairs, the goal is to generate a program that "fits" these examples (producing the outputs when given the inputs), and also generalizes well to new inputs. The paper evaluates mostly 7B and also 33B LLMs on three PBE tasks. The paper finds that finetuning these LLMs on these tasks further boosts their accuracy. The paper also investigates out-of-distribution (OOD) generalization, and finds that OOD can be improved using a semi-supervised approach, where the model is given (input,output) pairs from the new domain (but not the desired program); then the LLM samples potential programs that solve the (input,output) pairs; if the program is correct (which can be validated) - it is added to the training set and the LLM is trained / finetuned again iteratively.

Strengths

1. The paper is very clear and easy to follow, and it contains many examples that are visualized nicely. 1. The paper connects modern LLMs with the classical problem of Programming By Example (PBE)

Weaknesses

1. Undefined, non-scientific, message - the title of the paper is "Is Programming by Example solved by LLMs?". This title leads the paper ("We investigate here the extent to which large language models pretrained on source code can solve PBE"), but I think that it's an undefined question. What does "solve" mean? By construction, and according to the "no free lunch" theorem, PBE can never be "solved". So "solving" PBE just depends on the difficulty of the questions. Even if we could define "solve PBE", how would you measure it? Is 90% considered "solved"? Is 80% "solved"? This problem is further expressed in L214: "absolute performance in LOGO remains poor" - 16% accuracy is not "poor" when you do not compare it to anything. Any accuracy number below 100% is considered as "unsolved" as any other number, and 100% is not possible on a hard enough dataset (because of "no free lunch"). 1. Novelty - this is mostly an evaluation paper, that does not introduce any new approach or technique. Further, from the empirical evaluation, the answer to the question "Is Programming by Example solved by LLMs?" is, as expected, is "somewhat, but not quite": nothing in the empirical results was surprising or unusual: (a) finetuning LLMs on task-specific data works well; (b) semi-supervision on OOD data helps; (c) using Python as the output programming language works much better than the DSLs of classical work, because modern LLMs were trained on much more Python data than niche DSLs. 1. The OOD claim is a bit weak, because only in the relevant section it is said that "assuming we have access to problems drawn from the testing distribution" (without their labels, but these labels can be sampled and validated). 1. The paper compares its approach (a finetuned LLM) to classic symbolic, DSL-based (non-learning / non-neural) approaches several times throughout the paper, and speaks in favor of the LLM-based approach. This comparison to classic approaches is a bit of a strawman, since it is quite obvious that 33B LLMs are much more powerful than Flashfill (which is a paper from 2011) (Table 1). The paper also mentions that: >We also find that the resulting system can cover a broader scope of problems than classic symbolic methods, owing to the use of a Turing-complete language, which, at least theoretically, allows learning any computable function. And I think that such claims completely miss the point: the reason that LLMs are better than classic symbolic methods is **not** the use Turing-complete languages. LLMs would have been better than classic symbolic methods even if the classic symbolic DSLs were turing-complete as well. The reason is that LLMs were trained on trillions of Python tokens. 6. Another trivial claim: in Section 4.2, the authors find that "posterior description length is more predictive than program size and prior description length". Simplifying the paper's claim, without using words from probability, basically says: the perplexity of the desired output sequence is predictive of its accuracy on downstream tasks. I think that this claim is quite trivial, and is very common in practice in LLM training: measuring perplexity on a validation set is usually closely correlated with success on downstream tasks. Isn't this posterior iexactly what the model was *trained* to predict?

Questions

1. Can the authors evaluate the baseline where the "program" is the LLM itself? That is, the LLM is trained/prompted to predict output to unseen inputs, without going through an explicit program. I am asking this specifically in light of Figure 4 - the examples there seem to be much more easy to solve directly with an LLM (in a few-shot prompting fashion, possibly with chain-of-thought), than to write an explicit program for. 1. In L96 the authors write: "we use samples from a generative model to train an inference network, but we do not further train the generative model itself" - what does this exactly mean? What kind of model is each of the "generative model" and "inference network"? Which of them is a pretrained LLM? And why not further training the generative model itself? 1. What exactly does the "Search Budget (Num Samples)" mean in the experimental section? Does that mean "accuracy@k" - sample $k$ different outputs, and consider the output as correct if *any* of these $k$ outputs is correct? 1. In Figure 3 - What temperature was used, and what other temperatures did the authors explore, for their finetuned model and for the baselines such as GPT-4? Since evaluation depends on sampling of up to 200 outputs, the temperature might have a drastic effect on the success of each model. With a proper tuning of temperature, the order of curves in Figure 3 might be different. ## Summary Overall, the paper is not wrong and is presented nicely, but its novelty is limited, I'm not sure about the validity of some of the results such as Figure 3, and most of its conclusions are expected. I am thus voting for a borderline reject.

Rating

6

Confidence

5

Soundness

3

Presentation

4

Contribution

2

Limitations

N/A

Reviewer mgYE2024-08-12

Response to authors

Thank you for your response. >Papers in the past year find negative results for LLMs on PBE [1-3] >and in LambdaBeam, they also compare to a strong LLM baseline - a Python fine-tuned LLM internal to Google - which was found to not do well on PBE >Our system also beats systems like DreamCoder [4] * LambdaBeam compared to PaLM 62B - PaLM is also ~2 years old, and as far as publicly known, pre-RLHF. I am not surprised that the most recent GPT-4 performs significantly better. * DreamCoder (2020), while being algorithmically clever, was also in the pre-LLM era. * I'm not sure what is the "Shi et al. ‘24 ICLR" - can you please give a link? I don't think it is cited in your paper. * I also cannot find a public link to "[2] Rule et al. 2024 Nature Comm" (although it is cited, I can't find a PDF). >A core part of the paper is a wake-sleep inspired algorithm for OOD generalization. Would you mind pointing us to a citation that we can refer to which previously introduced our specific approach/technique for adaptation? As I understand from the paper, the wake-sleep inspired algorithm is explained under standard "finetuning", and "adaptation" starts only later (in page 4). Is the wake-sleep inspired algorithm for finetuning or adaptation? Further, regarding the novelty of the wake-sleep algorithm, as mentioned in the paper: >This method is closely related to self-instruct [29] and wake-sleep [30]. Like self-instruct, we use prompting to bootstrap a large dataset from a small manually-constructed one. Our method differs by using the LLM to generate a hidden latent variable (the program) while a different generative process produces an observed variable (the program outputs). So, what is the difference between this paper and [29,30]? That a **different** model generates the program outputs, instead of being the same model? >Deployed PBE systems are presented with a stream of "testing problems" generated by end users. In the wild, the requisite data is available for our adaptation technique. It's a similar setting for a variety of machine-learning-based systems (e.g., Google Translate, Siri, etc.). If a system depends on "a stream of testing problems generated by end users", how does it respond to the first end-user queries? The authors's argument is almost like saying: "in a real system, we will wait for a few (hundreds? thousands?) queries to be sent, and only then we will be able to respond". In contrast, a machine learning system that "truly" generalizes OOD, should ideally generalize starting from the first OOD example. I know that it's OOD generalization starting from the first OOD example is not trivial and is still one of the open problems in machine learning - I just said that the OOD argument is a bit weak. >Beating SOTA on mainstream benchmarks, including those used for deployed real world PBE systems [we solve in that sense] I would still argue that beating SOTA does not mean that the problem is "solved". >>“absolute performance in LOGO remains poor" - 16% accuracy is not "poor" when you do not compare it to anything >We compare against 3 baselines (Fig 3) I don't understand this response - LOGO is "graphics", right? Which means Fig 3(c)? Isn't "Ours" better than the baselines there? So why is performance considered "poor"? > Please see below for the result of your proposed baseline, which does well on strings but not on lists. Thank you for these additional results. >LLMs benefit from both massive data and expressive Turing-complete programming languages. As a thought experiment, consider an LLM trained on trillions of programs in the FlashFill++ DSL: It would still be utterly unable to solve the problems in Fig 4. But would it change the downstream results if we improved any DSL to be Turing complete? >. We used this somewhat high temperature (by the standards of code generation) because we wanted more diversity in the outputs, and did not tune this parameter because of the high cost of our experiments. Tuning the best temperature for each model separately can significantly affect the results and the order between the models. This tuning is only needed at test time.

Authorsrebuttal2024-08-13

Thank you for your engagement. Our biggest disagreements concern the novelty of the methods and whether the empirical results are surprising. Please see below. ## **Methodological Novelty** > So, what is the difference between this paper and [self-instruct, wake-sleep]? Our adaptation algorithm is a novel hybrid of self-instruct and wake-sleep. Unlike self-instruct it can update its prior using new (unlabeled) data. Unlike wake-sleep it can adapt from few examples, via in-context learning. Mathematically this can be understood by looking at Equation 5 and making the following observations---which we’re revising to include right after Equation 5: > Equation 5 should be seen as a wake-sleep algorithm where "dreaming" corresponds to training $q$ on fantasy data (first equation) while "waking" corresponds to running inference and updating the prior $\mathcal{G}$ (by updating the seed, second pair of equations). Thank you for pushing us to clarify the writing concerning the novel conceptual aspects of our work. The revision will include the above two paragraphs. (Last, you should think of adaptation as wake-sleep: finetuning is like only having the sleep phase.) ## **Significance of Empirical Results** To avoid subjectivity, it’s helpful to consult the literature to understand what those in the area would find surprising/noteworthy/significant. Papers in the last year find negative results on LLMs for PBE: 1. [ICLR ‘24, from DeepMind](https://arxiv.org/pdf/2307.13883) pg 7: **"LLMs in general perform poorly on program synthesis tasks specified only through I/O examples"**, *even for PaLM2 Unicorn, the largest PaLM2 model* 2. [Nature Comms. ‘24, Rule et al](https://www.nature.com/articles/s41467-024-50966-x): see Fig 3 3. [ICLR ‘24: Hypothesis Search](https://arxiv.org/abs/2309.05660) evaluates on ARC **finding GPT4 underperforms older symbolic solvers** (see [here](https://arxiv.org/abs/2402.03507) and [here](https://arxiv.org/pdf/2103.05823)) 4. [NeurIPS ‘23: LambdaBeam](https://arxiv.org/abs/2306.02049): As you point out this compares against a first-gen medium-size PaLM, but the above ICLR ‘24 paper compares against the latest-and-greatest PaLM2 Unicorn and arrives at similar conclusions. Our findings go beyond merely cheerleading LLMs. We instead show how to train small open models (7B, not RLHF’d) to surpass both bespoke neurosymbolic methods and massive closed-source systems, and also investigate uncommon creative applications such as visual graphics code. (Surprise is subjective, but we were *shocked* when LOGO graphics worked!) ## **Miscellaneous** > I just said that the OOD argument is a bit weak Although weakness/strength is subjective/relative, it’s helpful to consult the relevant literature for comparison. OOD for neural program synthesis has been previously studied using [architecture/prompt engineering](https://arxiv.org/pdf/2307.13883) or [handcrafted feature engineering](https://arxiv.org/pdf/1912.12345). Our (wake-sleep$\cap$self-instruct) algorithm instead does unsupervised domain adaptation, requiring **just tens of unlabeled OOD examples**. This is more generic and scalable than handcrafting features/prompts/architectures, hence a major strength of the approach relative to the prior art. > “absolute performance in LOGO remains poor" - 16% accuracy is not "poor" when you do not compare it to anything. The full quotation reads: "absolute performance in LOGO remains poor (*compare Fig. 6c to Fig. 3c*)". Contrasting Fig. 6c (OOD) to Fig. 3c (in-distribution) shows LOGO OOD performs poorly (but please see the updated LOGO results in the global response). > But would it change the downstream results if we improved any DSL to be Turing complete? Yes, because symbolic systems like FlashFill++ hinge on the clever design of non-Turing complete languages to judiciously restrict the search space. Going Turing-complete destroys the tractability of search and significantly impairs performance for (neuro)symbolic methods. (See [DreamCoder page 13 ](https://dl.acm.org/doi/pdf/10.1145/3453483.3454080): So intractable, search used a *year* of CPU time). > I would still argue that beating SOTA does not mean that the problem is "solved". Yes, hence why we propose five different subjective notions of “solve”, instead of merely declaring victory upon beating SOTA. The "scare quotes" were meant to emphasize the subjectivity of the quoted term, but we can revise to avoid "solve", including changing the title of the paper. ## **Parting Words** Obviously, we’re butting heads. But arguing these points has clarified to us how to communicate precisely what it is that is methodologically novel and empirically significant, and we’re confident that refactoring the writing can make that come through in the final paper. While we’d love to have your support, even if we don’t, thanks for forcing us to communicate these issues more clearly.

Reviewer mgYE2024-08-14

Response to authors

Thank you for the clarifications. I am not convinced by the novelty of the wake-sleep algorithm, and I do not think that this is a significant part of the paper. It could have been much easier for me to accept the paper if it was presented as an evaluation paper, without trying to claim novelty on the algorithm. I think that the paper can be more easily accepted by the audience as well if it was presented as an evaluation paper, so if I were the authors I would tone down the novelty of the algorithm. However as an evaluation paper, it is a good paper, and I hope that it will finally convince the rest of the program synthesis community to work with realistic LLMs and Python. I increased my rating from 4 to 6, good luck!

Authorsrebuttal2024-08-14

Thank you so much for your support and for your help in improving the paper; we will revise accordingly. We're very encouraged by your comments on the paper's potential impact on the program synthesis community!

Reviewer e1ch5/10 · confidence 3/52024-07-14

Summary

The paper performs a relatively thorough study on using LLM for example-guided program synthesis tasks. The results presented in the paper suggest that LLMs make strong progress toward solving the typical suite of example-guided synthesis tasks, potentially increasingly the flexibility and applicability of PBE systems.

Strengths

- The PBE problem is interesting and well-motivated. Major papers in the field are well cited and referenced - Extensive amount of traditional datasets are being evaluated - The insights derived from experiments are somewhat valuable

Weaknesses

- CoT and other simple prompting methods are not evaluated - While there is an extensive amount of experiments and comparisons, we find that the outcome is relatively predictable. - While the writing is generally okay and easy to understand, multiple typos and mistakes found in the writing (also mentioned in questions). Please consider fixing them. - The LOGO visual examples are converted to an ASCII grid of characters (Fig. 8b). This might not be the most intuitive representation. Details about the transformation is not shown, such as how each number (0-9) is derived, the resolution of the ASCII grid, etc. With this design, it does not make sense for a non-fine-tuned LLM to solve the task. But technically you could still fine-tune GPT-3.5 with these inputs, but I guess it is okay to not include this experiment.

Questions

- (Typo) line 150, there should be a space between (Tbl. 1,Fig. 3b) - (Typo) figure 6a “Sygus” -> “SyGuS” - (Grammar) last sentence of Figure 4 caption has grammar mistakes - (Grammar) last sentence of Table 1 caption has grammar mistakes - Appendix A.2 is empty - I see in the prompt the authors wrote “You are a CS professor”. As far as I know this might not be the perfect prompt for code generation (this is just a joke).

Rating

5

Confidence

3

Soundness

2

Presentation

3

Contribution

2

Limitations

N/A

Reviewer CppC7/10 · confidence 3/52024-07-18

Summary

This paper investigates whether the long-studied programming by example task is "solved" by large language models with Turing-complete languages like python. Their evaluation is on three domains: lists, strings, and LOGO/Turtle graphics. They evaluate three LLM-based approaches, including a self-instruct-like fine-tuning approach that tunes LLMs on synthetic labeled data, and an adaption approach assuming access to problems (not solutions) from the testing distribution. Compared to several symbolic, neurosymbolic, and LLM baselines, the proposed approaches perform better. The analysis of the correlation between different aspects of the target program indicates that the fine-tuned model is beyond blind guess-and-check.

Strengths

1. The experiments are comprehensive, and the analysis of different predictors of model performance is helpful in understanding the extent to which LLMs solve PBE. 2. The proposed methods make use of the fact that PBEs problems can be accurately synthesized using model-generated inputs and programs. The experiment results show that they are effective in solving in-domain problems and adapting out-of-distribution ones at test time. 3. This paper answers some interesting questions regarding the role of LLMs for PBE and points out what researchers might work on in the future.

Weaknesses

Contamination. As the authors acknowledged on Line 148, the problems could be in LLMs' pertaining data. I wonder if the authors have an idea of how much of a role such potential contamination plays in LLMs' superior performance. Is there anyway to rule out or minimize the impact of that confounder?

Questions

1. How much does a turing-complete language help in solving PBE, excluding the fact that LLMs have seen lots of python code? Is the expressiveness of a turing-complete language itself helpful? 2. How far can the adaption go? Right now the adaption discussed is still within the same category of problems (such as lists), I imagine a more general PBE system might be able to adapt to problems that are more different.

Rating

7

Confidence

3

Soundness

3

Presentation

3

Contribution

3

Limitations

Yes.

Reviewer k14y2024-08-14

Thanks for the responses, which have addressed some of my concerns. I have increased the score.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC