用形式语言Dafny+强化学习,大幅减少人工标注,实现可扩展的程序验证。
Re:Form -- Reducing Human Annotations in Scalable Formal Software Verification with RL in LLMs: A Preliminary Study on Dafny
- 以Dafny为形式环境,结合自动数据清洗与强化学习反馈提升生成可靠性。
- 0.5B小模型经微调即可生成语法正确且可验证的Dafny代码,超越大厂闭源模型。
- 提出DafnyComp基准,支持复杂程序推理,适合关注形式化验证的研究者。
现有基于自然语言的大规模语言模型(LLMs)在强化学习(RL)训练中面临验证过程不可靠、难扩展的问题,大型专有模型几乎无法生成可验证程序。一种前景广阔但尚未深入探索的替代方案是基于形式语言的推理。将LLMs嵌入严格的形式系统(如Dafny)中,使生成模型在形式语言空间中运行,可实现推理过程与结果的自动、数学可证明验证,对实现大规模可靠的形式化软件验证至关重要。当前普遍依赖人工标注的思维链和答案来引导模型推理与编程能力,但复杂编程任务的标注成本过高。本文以Dafny为实验环境,系统探索减少人工标注的方法。核心流程包括引入自动可扩展的数据清洗管道,并设计精细的强化学习机制,融合形式化验证器的反馈。我们提出了DafnyComp基准,包含可组合的形式化程序及自动生成的规格说明,用于规格推理。经过监督微调(SFT),即使0.5B的小模型也能生成语法正确且可验证的Dafny代码,表现超越多种专有模型。加入正则化后的强化学习进一步提升泛化能力,在具有挑战性的DafnyComp基准上优于所有强基线。
原文摘要 · Abstract (English)
Existing informal language-based (e.g., human language) Large Language Models (LLMs) trained with Reinforcement Learning (RL) face a significant challenge: their verification processes, which provide crucial training signals, are neither reliable nor scalable. In fact, the prevalent large proprietary models could hardly generate verifiable programs. A promising yet largely uncharted alternative is formal language-based reasoning. Grounding LLMs in rigorous formal systems where generative models operate in formal language spaces (e.g., Dafny) enables the automatic and mathematically provable verification of their reasoning processes and outcomes. This capability is pivotal for achieving large-scale, reliable formal software verification. It is a common practice to employ human-annotated chain-of-thought and answers to induce the reasoning and coding capabilities of LLMs. Unfortunately, it becomes unacceptably all-consuming to provide such priors for supervising complex programming tasks. In this work, we systematically explore ways to reduce human annotations with the formal language, Dafny, as the main environment for our pilot study. Our pipeline mainly relies on introducing an automatic and scalable data curation pipeline, and careful RL designs integrated with feedback from the formal language verifier. We introduce DafnyComp, a benchmark of compositional formal programs with auto-formalized specifications for specification reasoning. Our supervised fine-tuning (SFT) stage enables even small models (e.g., 0.5B) to generate syntactically valid and verifiable Dafny code, surpassing proprietary models. RL with regularization further improves performance, achieving stronger generalization to out-of-domain tasks and outperforming all strong baselines on the challenging DafnyComp benchmark.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。