arXiv:2502.17441cs.SEcs.LG2025-02被引 3

用可读编程提升大项目代码生成效果

Renaissance of Literate Programming in the Era of LLMs: Enhancing LLM-Based Code Generation in Large-Scale Projects

  • 引入可互操作的可读编程(ILP)框架,融合代码与自然语言
  • 在RepoBench上验证,大模型在ILP指导下生成代码更准确
  • 适合希望提升代码可维护性的工程团队使用

大型语言模型(LLMs)已助力程序员提升编码效率,在代码生成、理解与修复方面表现优异。然而,面对现代代码库规模庞大、依赖关系复杂的问题,其在大规模项目中的应用仍具挑战。尽管高德纳提出的可读编程(LP)通过结合代码与自然语言来传达逻辑与意图,但其在大型项目中增强协作关系的潜力尚未充分挖掘。本研究提出可互操作可读编程(ILP),利用LP原则提升小规模文档与大规模项目的开发效率。我们探究了不同任务下大模型在ILP风格指令下的表现,提出一种简洁提示工程方法,使大模型能更好参与代码生成。基于RepoBench基准,评估多种大模型在生成Scheme和Python代码上的能力,结果表明:采用ILP可显著提升大模型在大规模项目中的代码生成质量。

原文摘要 · Abstract (English)

Large Language Models (LLMs) have helped programmers increase efficiency through code generation, comprehension, and repair. However, their application to large-scale projects remains challenging due to complex interdependencies and the extensive size of modern codebases. Although Knuth's concept of Literate Programming (LP) combines code and natural language to convey logic and intent, its potential for enhancing relationships in large projects has not been fully explored. In this study, we introduce the idea of Interoperable LP (ILP), which leverages literate programming principles to enhance the development of both small-scale documents and large-scale projects with LLMs. We investigate how LLMs perform under ILP-style instructions for both document-oriented tasks and entire projects. Recognizing that many researchers rely on well-structured templates to guide LLMs, we propose a concise prompt engineering method to write LP documents so LLMs can better be involved in code generation. We also examine the capacity of various LLMs to generate Scheme and Python code on the RepoBench benchmark, illustrating the advantages of our approach. Our findings indicate that ILP with LLMs can enhance LLM-based code generation in large-scale project development.

可读编程代码生成大模型提示工程

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。