arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2309.14396cs.SEcs.LGcs.PL
收藏

猜测与草图:语言模型引导的转译

Guess & Sketch: Language Model Guided Transpilation

Cornell University(康奈尔大学);Harvard University(哈佛大学);Northwestern University(西北大学)

Celine Lee, Abdulrahman Mahmoud, Michal Kurek, Simone Campanoni, David Brooks, Stephen Chong, Gu-Yeon Wei, Alexander M. Rush

AI总结:

提出神经符号方法Guess & Sketch,结合语言模型与符号求解器,实现汇编代码的自动转译,在测试集上比GPT-4多转译57.6%的示例,比工程化转译器多39.6%。

摘要:

维护遗留软件需要大量的软件和系统工程工时。汇编代码程序要求对计算机机器状态进行低级控制,且没有变量名,人类分析起来尤其困难。现有的传统程序翻译器保证正确性,但针对源和目标编程语言是手工设计的。学习式转译,即代码的自动翻译,为手动重写和工程工作提供了一种替代方案。自动化的符号程序翻译方法保证正确性,但由于指数级庞大的搜索空间,难以扩展到更长的程序。它们僵化的基于规则的系统也限制了其表达能力,因此只能处理缩减的程序空间。概率神经语言模型(LMs)对每个输入产生合理的输出,但以牺牲保证正确性为代价。在这项工作中,我们利用LM和符号求解器的优势,采用神经符号方法进行汇编代码的学习式转译。汇编代码是神经符号方法的合适场景,因为汇编代码可以划分为较短的无分支基本块,适合使用符号方法。猜测与草图(Guess & Sketch)从LM的特征中提取对齐和置信度信息,然后将其传递给符号求解器,以解决转译输入和输出的语义等价性。我们在三个不同难度的汇编转译任务测试集上测试了Guess & Sketch,结果表明它比GPT-4成功转译的示例多57.6%,比工程化转译器多39.6%。我们还分享了该任务的训练和评估数据集。

英文摘要:

Maintaining legacy software requires many software and systems engineering hours. Assembly code programs, which demand low-level control over the computer machine state and have no variable names, are particularly difficult for humans to analyze. Existing conventional program translators guarantee correctness, but are hand-engineered for the source and target programming languages in question. Learned transpilation, i.e. automatic translation of code, offers an alternative to manual re-writing and engineering efforts. Automated symbolic program translation approaches guarantee correctness but struggle to scale to longer programs due to the exponentially large search space. Their rigid rule-based systems also limit their expressivity, so they can only reason about a reduced space of programs. Probabilistic neural language models (LMs) produce plausible outputs for every input, but do so at the cost of guaranteed correctness. In this work, we leverage the strengths of LMs and symbolic solvers in a neurosymbolic approach to learned transpilation for assembly code. Assembly code is an appropriate setting for a neurosymbolic approach, since assembly code can be divided into shorter non-branching basic blocks amenable to the use of symbolic methods. Guess & Sketch extracts alignment and confidence information from features of the LM then passes it to a symbolic solver to resolve semantic equivalence of the transpilation input and output. We test Guess & Sketch on three different test sets of assembly transpilation tasks, varying in difficulty, and show that it successfully transpiles 57.6% more examples than GPT-4 and 39.6% more examples than an engineered transpiler. We also share a training and evaluation dataset for this task.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑