[论文解读] Latent Execution for Neural Program Synthesis Beyond Domain-Specific Languages
LaSynth 提出了一种新颖的神经程序合成方法,通过学习潜在表征来近似部分有效 C 程序的执行过程,从而实现从输入-输出示例中有效合成代码。通过在潜在空间中建模程序执行,该方法在性能上优于先前的方法,并生成更简洁、更接近人类编写的代码。
Program synthesis from input-output examples has been a long-standing challenge, and recent works have demonstrated some success in designing deep neural networks for program synthesis. However, existing efforts in input-output neural program synthesis have been focusing on domain-specific languages, thus the applicability of previous approaches to synthesize code in full-fledged popular programming languages, such as C, remains a question. The main challenges lie in two folds. On the one hand, the program search space grows exponentially when the syntax and semantics of the programming language become more complex, which poses higher requirements on the synthesis algorithm. On the other hand, increasing the complexity of the programming language also imposes more difficulties on data collection, since building a large-scale training set for input-output program synthesis require random program generators to sample programs and input-output examples. In this work, we take the first step to synthesize C programs from input-output examples. In particular, we propose LaSynth, which learns the latent representation to approximate the execution of partially generated programs, even if their semantics are not well-defined. We demonstrate the possibility of synthesizing elementary C code from input-output examples, and leveraging learned execution significantly improves the prediction performance over existing approaches. Meanwhile, compared to the randomly generated ground-truth programs, LaSynth synthesizes more concise programs that resemble human-written code. We show that training on these synthesized programs further improves the prediction performance for both Karel and C program synthesis, indicating the promise of leveraging the learned program synthesizer to improve the dataset quality for input-output program synthesis.
研究动机与目标
- 为解决从输入-输出示例中合成完整编程语言(如 C 语言)的挑战,而现有方法在很大程度上忽略了这一问题。
- 克服复杂语言中程序搜索空间的指数级增长以及数据收集的困难。
- 开发一种方法,通过学习程序执行的潜在表征,对部分有效程序进行推理。
- 与基线方法相比,提升合成性能并生成更简洁、更接近人类编写的代码。
提出的方法
- LaSynth 学习一种潜在表征,以近似部分生成程序的执行过程,即使其语法或语义不完整。
- 它使用神经网络对程序前缀进行编码并预测其潜在执行状态,从而实现在程序空间中的高效搜索。
- 该模型在一组随机生成的 C 程序及其对应输入-输出示例的数据集上进行训练。
- 潜在执行被用作程序语义的可微代理,使合成过程中能够进行基于梯度的优化。
- 该方法利用学习到的执行模型引导程序搜索,从而同时提升准确率和代码质量。
- 合成的程序被用于扩充训练数据,进一步提升在 C 语言和 Karel 程序合成任务上的性能。
实验结果
研究问题
- RQ1神经程序合成能否被有效扩展到完整编程语言(如 C 语言),而不仅限于领域特定语言?
- RQ2如何利用潜在表征对语法不完整或语义不明确的程序进行执行建模?
- RQ3与标准方法相比,学习近似程序执行是否能提升合成准确率和代码质量?
- RQ4合成的程序能否用于提升输入-输出程序合成任务中训练数据的质量?
主要发现
- 通过利用潜在执行建模,LaSynth 在 C 程序合成任务中实现了更优的预测性能。
- 与随机生成的真实程序相比,合成的程序更简洁,且更接近人类编写的代码。
- 在合成程序上进行训练进一步提升了 C 语言和 Karel 程序合成的性能,表明训练数据质量得到改善。
- 潜在执行模型使得在传统方法失效的复杂程序空间中实现有效搜索成为可能。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。