Ensuring correctness is crucial for code generation. Formal verification offers a definitive assurance of correctness, but demands substantial human effort in proof construction and hence raises a pressing need for automation. The primary obstacle lies in the severe lack of data-there is much fewer proofs than code snippets for Large Language Models (LLMs) to train upon. In this paper, we introduce SAFE, a framework that overcomes the lack of human-written proofs to enable automated proof generation of Rust code. SAFE establishes a self-evolving cycle where data synthesis and fine-tuning collaborate to enhance the model capability, leveraging the definitive power of a symbolic verifier in telling correct proofs from incorrect ones. SAFE also re-purposes the large number of synthesized incorrect proofs to train the self-debugging capability of the fine-tuned models, empowering them to fix incorrect proofs based on the verifier's feedback. SAFE demonstrates superior efficiency and precision compared to GPT-4o. Through tens of thousands of synthesized proofs and the self-debugging mechanism, we improve the capability of open-source models, initially unacquainted with formal verification, to automatically write proofs for Rust code. This advancement leads to a significant improvement in performance, achieving a 52.52% accuracy rate in a benchmark crafted by human experts, a significant leap over GPT-4o's performance of 14.39%.


翻译:确保代码生成过程的正确性至关重要。形式化验证为正确性提供了确定性保证,但需要大量人工精力进行证明构造,因此对自动化提出了迫切需求。主要障碍在于数据的严重匮乏——可供大型语言模型(LLMs)训练的证明数量远少于代码片段。本文提出SAFE框架,该框架克服了人工编写证明的不足,实现了Rust代码的自动证明生成。SAFE建立了一个自演化循环,其中数据合成与微调协同工作以增强模型能力,并利用符号验证器在区分正确与错误证明方面的确定性能力。SAFE还重新利用了大量合成的错误证明来训练微调模型的自我调试能力,使其能够根据验证器的反馈修正错误证明。与GPT-4o相比,SAFE展现出卓越的效率和精度。通过数万个合成证明及自我调试机制,我们提升了开源模型(最初不熟悉形式化验证)为Rust代码自动编写证明的能力。这一进步带来了性能的显著提升,在由人类专家构建的基准测试中达到了52.52%的准确率,较GPT-4o的14.39%实现了重大飞跃。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
29+阅读 · 2025年1月1日
生成型大型语言模型的自动事实核查:一项综述
专知会员服务
37+阅读 · 2024年7月6日
《大型语言模型代码生成》综述
专知会员服务
68+阅读 · 2024年6月4日
自动编程:大型语言模型及其他
专知会员服务
36+阅读 · 2024年5月12日
大模型如何迭代?北大等《大型语言模型自我进化》综述
专知会员服务
16+阅读 · 2021年1月23日
智能合约的形式化验证方法研究综述
专知
16+阅读 · 2021年5月8日
自然语言生成资源列表
专知
17+阅读 · 2020年1月4日
一文看懂AutoEncoder模型演进图谱
AINLP
12+阅读 · 2019年6月17日
【干货】深入理解自编码器(附代码实现)
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
VIP会员
相关VIP内容
通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
29+阅读 · 2025年1月1日
生成型大型语言模型的自动事实核查:一项综述
专知会员服务
37+阅读 · 2024年7月6日
《大型语言模型代码生成》综述
专知会员服务
68+阅读 · 2024年6月4日
自动编程:大型语言模型及其他
专知会员服务
36+阅读 · 2024年5月12日
大模型如何迭代?北大等《大型语言模型自我进化》综述
专知会员服务
16+阅读 · 2021年1月23日
相关基金
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员