通过可验证的文字编程指导用户验证LLM生成的代码
Guiding Human Validation of LLM-Generated Code via Verifiable Literate Programming
AI总结:
提出可验证文字编程框架,通过无歧义的自然语言文档作为中间层,结合细粒度不匹配检测和验证模块,帮助用户有效验证LLM生成代码,将pass@1从28.7%-73.2%提升至65.4%-93.5%。
摘要:
Vibe coding通过允许用户与大语言模型进行自然语言交互来生成代码,从而民主化软件开发。然而,只有当代码忠实地实现用户意图时,代码才是可靠的,而用户验证这一点既困难又劳动密集。现有的验证方法要么依赖LLM辅助的自动化测试,这存在提示歧义和模型易错性问题,要么仅让用户参与部分软件工件(如提示和测试用例),这可能忽略边界情况和程序细节。通过对LLM生成代码的错误研究,我们发现详细的人类反馈至关重要,因为失败通常源于需求不明确或微妙的语义偏差。本文提出了可验证文字编程,这是一个人在环中的框架,旨在使各编程水平的用户都能参与LLM生成代码的审查/验证过程。其核心是,VLP提出基于无歧义自然语言的文档作为提示和代码之间的可读中间层。该文档展示了具体的程序语义,并允许用户对潜在的意图-代码不匹配提供反馈。它通过三种技术支持人在环的端到端修复和验证:(i)具有无歧义语法和基本确定性代码到文档翻译的自然语言风格文字语言,(ii)基于LLM的细粒度不匹配检测,利用提示和文档之间的追踪链接将用户的审查工作集中在可疑的文档行上,以及(iii)一个验证模块,利用用户验证过的文档推导API使用检查和形式化属性,然后通过模型检查对生成的代码进行验证。我们的评估表明,VLP在合理的用户工作量下,将代码pass@1从28.7%-73.2%提升至65.4%-93.5%。
英文摘要:
Vibe coding democratizes software development by allowing users to generate code via natural-language (NL) interaction with large language models (LLMs). However, the code is reliable only when it faithfully implements the user's intent, which is difficult and labor-intensive for users to validate. Existing validation methods either rely on LLM-assisted automated testing, which suffers from prompt ambiguity and model fallibility, or involve users only in partial software artifacts such as prompts and test cases, which may overlook corner cases and program details. Motivated by a bug study of LLM-generated code, we find that detailed human feedback is essential, as failures often stem from underspecified requirements or subtle semantic deviations. This paper presents verifiable literate programming (VLP), a human-in-the-loop framework designed to make the review/validation process of LLM-generated code accessible to users at all programming levels. At its core, VLP proposes unambiguous NL-based documentation as a readable intermediate layer between prompts and code. The documentation demonstrates concrete program semantics and enables users to provide feedback on potential intent-code mismatches. It supports human-involved, end-to-end repair and validation via three techniques: (i) an NL-style literate language with unambiguous syntax and mostly deterministic code-to-documentation translation, (ii) LLM-based fine-grained mismatch detection that uses trace links between prompts and documentation to focus users' review effort on suspicious documentation lines, and (iii) a verification module that leverages user-validated documentation to derive API-usage checks and formal properties, which are then verified against the generated code using model checking. Our evaluation shows that VLP improves code pass@1 from 28.7%-73.2% to 65.4%-93.5% with reasonable user effort.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。