arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.03636cs.PLcs.LG
收藏

面向极低资源编程语言与形式语言中文本到代码任务的合成编程启发方法

Synthetic Programming Elicitation for Text-to-Code in Very Low-Resource Programming and Formal Languages

UC Berkeley(加州大学伯克利分校);Stanford University(斯坦福大学);UCLA(加利福尼亚大学洛杉矶分校);University of Edinburgh(爱丁堡大学)

Federico Mora, Justin Wong, Haley Lepe, Sahil Bhatia, Karim Elmaaroufi, George Varghese, Joseph E. Gonzalez, Elizabeth Polgreen, Sanjit A. Seshia

AI总结:

针对大语言模型难以生成极低资源编程语言(VLPL)有效代码的问题,提出合成编程启发与编译(SPEAC)方法,通过可编译的中间语言及编译器代码修复技术,在UCLID5案例中实现了更优的语法正确率且不损失语义正确性。

摘要:

大语言模型(LLM)在代码应用领域的最新进展表明,其在测试用例生成、代码自修复等具有挑战性的代码相关任务上,展现出了出色的零样本流畅度与指令遵循能力。但意料之中的是,模型难以用预训练阶段未覆盖的编程语言(即极低资源编程语言,VLPL)编写语法有效的程序。VLPL 存在于诸多关键场景中,包括内部工具的领域特定语言、遗留语言的工具链,以及形式验证框架。受“自然编程启发”技术的启发,我们提出设计一种中间语言:LLM 能“自然地”掌握其用法,且该语言可被自动编译为目标 VLPL。当 LLM 生成的代码超出该中间语言的范围时,我们使用编译器技术将代码修复为符合中间语言规范的程序。总体而言,我们提出了**合成编程启发与编译**(SPEAC)方法,该方法使 LLM 即使针对 VLPL 也能生成语法有效的代码。我们以 UCLID5 形式验证语言为案例研究,对 SPEAC 的性能进行了实证评估,结果发现,与现有的检索和微调基线方法相比,SPEAC 能更频繁地生成语法正确的程序,且不会牺牲语义正确性。

英文摘要:

Recent advances in large language models (LLMs) for code applications have demonstrated remarkable zero-shot fluency and instruction following on challenging code related tasks ranging from test case generation to self-repair. Unsurprisingly, however, models struggle to compose syntactically valid programs in programming languages unrepresented in pre-training, referred to as very low-resource Programming Languages (VLPLs). VLPLs appear in crucial settings, including domain-specific languages for internal tools, tool-chains for legacy languages, and formal verification frameworks. Inspired by a technique called natural programming elicitation, we propose designing an intermediate language that LLMs "naturally" know how to use and which can be automatically compiled to a target VLPL. When LLMs generate code that lies outside of this intermediate language, we use compiler techniques to repair the code into programs in the intermediate language. Overall, we introduce \emph{synthetic programming elicitation and compilation} (SPEAC), an approach that enables LLMs to generate syntactically valid code even for VLPLs. We empirically evaluate the performance of SPEAC in a case study for the UCLID5 formal verification language and find that, compared to existing retrieval and fine-tuning baselines, SPEAC produces syntactically correct programs more frequently and without sacrificing semantic correctness.

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

↑