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

函数约束的程序合成

Function-constrained Program Synthesis

University of Cambridge(剑桥大学)

Patrick Hajali, Ignas Budvytis

AI总结:

本文提出函数约束的程序合成方法,通过限制LLM使用显式函数集并自动生成模块化子函数来恢复失败尝试,同时引入half-shot评估范式以更准确地衡量模型编码能力。

摘要:

本工作提出了两项技术:(1)一种允许大型语言模型(LLMs)在解决编程任务时利用用户提供的代码的技术;(2)一种在LLM初始生成的代码不充分时,迭代生成模块化子函数以辅助后续代码生成尝试的方法。使用Python等通用编程语言生成计算机程序对LLMs构成挑战,尤其是当指令要求使用提示中提供的代码时。代码专用LLMs(例如GitHub Copilot、CodeLlama2)能够利用开发环境中所有可用代码实时生成代码补全。然而,限制代码专用LLMs仅使用上下文中的代码并非易事,因为模型没有被明确指示使用用户提供的代码,用户也无法精确高亮模型应纳入其上下文的代码片段。此外,当前系统缺乏有效的恢复方法,迫使用户反复修改提示并重新提示模型,直到获得足够的解决方案。我们的方法不同于传统的由LLM驱动的代码生成,它将代码生成约束在显式函数集内,并通过自动生成的子函数实现从失败尝试中恢复。当LLM无法生成可运行的代码时,我们生成模块化子函数以辅助后续生成功能代码的尝试。我们方法的一个副产品是一个可复用的子函数库,能够解决相关任务,模拟了一个效率随经验扩展的软件团队。我们还引入了一种新的“half-shot”评估范式,与传统的zero-shot评估相比,它能对LLMs的编码能力提供更严格的估计。我们提出的评估方法鼓励模型以结构化格式输出解决方案,减少可能被误判为编码能力差的语法错误。

英文摘要:

This work introduces (1) a technique that allows large language models (LLMs) to leverage user-provided code when solving programming tasks and (2) a method to iteratively generate modular sub-functions that can aid future code generation attempts when the initial code generated by the LLM is inadequate. Generating computer programs in general-purpose programming languages like Python poses a challenge for LLMs when instructed to use code provided in the prompt. Code-specific LLMs (e.g., GitHub Copilot, CodeLlama2) can generate code completions in real-time by drawing on all code available in a development environment. However, restricting code-specific LLMs to use only in-context code is not straightforward, as the model is not explicitly instructed to use the user-provided code and users cannot highlight precisely which snippets of code the model should incorporate into its context. Moreover, current systems lack effective recovery methods, forcing users to iteratively re-prompt the model with modified prompts until a sufficient solution is reached. Our method differs from traditional LLM-powered code-generation by constraining code-generation to an explicit function set and enabling recovery from failed attempts through automatically generated sub-functions. When the LLM cannot produce working code, we generate modular sub-functions to aid subsequent attempts at generating functional code. A by-product of our method is a library of reusable sub-functions that can solve related tasks, imitating a software team where efficiency scales with experience. We also introduce a new "half-shot" evaluation paradigm that provides tighter estimates of LLMs' coding abilities compared to traditional zero-shot evaluation. Our proposed evaluation method encourages models to output solutions in a structured format, decreasing syntax errors that can be mistaken for poor coding ability.

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

↑