arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2310.17807cs.AIcs.LGcs.SE
收藏

Clover:闭环可验证代码生成

Clover: Closed-Loop Verifiable Code Generation

Stanford University(斯坦福大学);VMware Research(威睿研究中心)

Chuyue Sun, Ying Sheng, Oded Padon, Clark Barrett

AI总结:

本文提出Clover范式,通过形式化验证工具与大型语言模型集成,在代码、文档字符串和形式化注释间进行一致性检查,有效过滤错误代码,在CloverBench上实现高达87%的接受率且无误报。

摘要:

在软件开发中,使用大型语言模型进行代码生成是一个快速发展的趋势。然而,如果没有确保生成代码正确性的有效方法,这一趋势可能会导致不良后果。在本文中,我们介绍了一种解决这一挑战的新方法:Clover范式,即闭环可验证代码生成的简称,它使用一致性检查为错误代码提供强大的过滤器。Clover在代码、文档字符串和形式化注释之间执行一致性检查。该检查器是通过形式化验证工具和大型语言模型的全新集成来实现的。我们提供了理论分析来支持我们的论点,即Clover在一致性检查方面应该是有效的。我们还在一个手工设计的数据集(CloverBench)上实证研究了其性能,该数据集具有教科书级难度的带注释Dafny程序。实验结果表明,对于该数据集:(i) LLM在自动生成形式化规范方面相当成功;(ii) 我们的一致性检查器对正确实例实现了有前景的接受率(高达87%),同时对对抗性错误实例保持零容忍(无误报)。Clover还在现有的人工编写数据集MBPP-DFY-50中发现了6个错误程序。

英文摘要:

The use of large language models for code generation is a rapidly growing trend in software development. However, without effective methods for ensuring the correctness of generated code, this trend could lead to undesirable outcomes. In this paper, we introduce a new approach for addressing this challenge: the Clover paradigm, short for Closed-Loop Verifiable Code Generation, which uses consistency checking to provide a strong filter for incorrect code. Clover performs consistency checks among code, docstrings, and formal annotations. The checker is implemented using a novel integration of formal verification tools and large language models. We provide a theoretical analysis to support our thesis that Clover should be effective at consistency checking. We also empirically investigate its performance on a hand-designed dataset (CloverBench) featuring annotated Dafny programs at a textbook level of difficulty. Experimental results show that for this dataset: (i) LLMs are reasonably successful at automatically generating formal specifications; and (ii) our consistency checker achieves a promising acceptance rate (up to 87%) for correct instances while maintaining zero tolerance for adversarial incorrect ones (no false positives). Clover also discovered 6 incorrect programs in the existing human-written dataset MBPP-DFY-50.

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

↑