代码的自然语言大纲:大语言模型时代的文学编程
Natural Language Outlines for Code: Literate Programming in the LLM Era
AI总结:
提出自然语言大纲作为AI辅助开发者的新模态与交互界面,支持代码与自然语言双向同步,验证其生成质量并展示在代码审查、恶意软件检测等场景的应用价值。
摘要:
我们提出将自然语言大纲作为一种新颖的模态和交互界面,在整个软件开发过程中为开发者提供AI辅助。代码函数的自然语言大纲包含多句简洁的散文式陈述,这些陈述对代码进行划分,并以文学编程的风格总结其核心思想。关键在于,我们发现现代大语言模型(LLM)在实践中能够生成准确且高质量的自然语言大纲。此外,自然语言大纲支持代码与自然语言之间的双向同步:开发者可以修改代码或自然语言,LLM会自动更新另一方。我们讨论了自然语言大纲的多种用例:它们可加速代码和差异(diff)的理解与导航、简化代码维护、增强代码搜索、引导代码生成等。接着,我们提出并比较了多种用于生成大纲的LLM提示技术,并邀请专业开发者评判大纲质量。最后,我们展示了将自然语言大纲应用于代码审查和恶意软件检测的两个案例研究。
英文摘要:
We propose using natural language outlines as a novel modality and interaction surface for providing AI assistance to developers throughout the software development process. An NL outline for a code function comprises multiple statements written in concise prose, which partition the code and summarize its main ideas in the style of literate programming. Crucially, we find that modern LLMs can generate accurate and high-quality NL outlines in practice. Moreover, NL outlines enable a bidirectional sync between code and NL, where a developer can change either code or NL and have the LLM automatically update the other. We discuss many use cases for NL outlines: they can accelerate understanding and navigation of code and diffs, simplify code maintenance, augment code search, steer code generation, and more. We then propose and compare multiple LLM prompting techniques for generating outlines and ask professional developers to judge outline quality. Finally, we present two case studies applying NL outlines toward code review and malware detection.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。