arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2412.06176cs.LGcs.AI
收藏

AlphaVerus:通过自改进翻译与Treefinement自举实现形式化验证代码生成

AlphaVerus: Bootstrapping Formally Verified Code Generation through Self-Improving Translation and Treefinement

Carnegie Mellon University(卡内基梅隆大学)

Pranjal Aggarwal, Bryan Parno, Sean Welleck

AI总结:

针对大语言模型生成代码正确性无保障、形式化验证代码训练数据少的问题,提出含三阶段的自改进框架AlphaVerus,无需人工干预或微调即可让LLaMA-3.1-70B生成验证代码,为可信代码生成智能体奠基。

摘要:

基于大语言模型的自动化代码生成已获得广泛关注,但生成代码的正确性仍无法得到保证。我们旨在利用形式化验证为生成代码的正确性提供数学层面的保证。然而,由于训练数据稀缺且形式证明复杂度高,使用大语言模型生成形式化验证代码仍面临阻碍。为解决这一挑战,我们提出AlphaVerus——一个自改进框架,通过迭代翻译来自更高资源语言的程序并利用验证器的反馈,自举实现形式化验证代码生成。AlphaVerus分为三个阶段:候选翻译探索、Treefinement(一种利用验证器反馈进行程序细化的新型树搜索算法),以及过滤不匹配的规范与程序以防止奖励黑客行为。通过这一迭代过程,AlphaVerus使LLaMA-3.1-70B模型无需人工干预或模型微调即可生成验证代码。AlphaVerus展现出为HumanEval和MBPP生成形式化验证解决方案的能力,为真正可信的代码生成智能体奠定了基础。

英文摘要:

Automated code generation with large language models has gained significant traction, but there remains no guarantee on the correctness of generated code. We aim to use formal verification to provide mathematical guarantees that the generated code is correct. However, generating formally verified code with LLMs is hindered by the scarcity of training data and the complexity of formal proofs. To tackle this challenge, we introduce AlphaVerus, a self-improving framework that bootstraps formally verified code generation by iteratively translating programs from a higher-resource language and leveraging feedback from a verifier. AlphaVerus operates in three phases: exploration of candidate translations, Treefinement -- a novel tree search algorithm for program refinement using verifier feedback, and filtering misaligned specifications and programs to prevent reward hacking. Through this iterative process, AlphaVerus enables a LLaMA-3.1-70B model to generate verified code without human intervention or model finetuning. AlphaVerus shows an ability to generate formally verified solutions for HumanEval and MBPP, laying the groundwork for truly trustworthy code-generation agents.

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

↑