arXiv:2502.15872cs.CLcs.AI2025-02被引 2

用搜索代替全库上下文,让大模型高效利用代码库完成编程任务。

MutaGReP: Execution-Free Repository-Grounded Plan Search for Code-Use

  • 通过变异引导的树搜索生成自然语言步骤计划,结合符号检索实现代码库定位。
  • 仅用5%上下文就达到GPT-4o满库上下文的编码性能,长代码任务表现显著提升。
  • 适合需要高效利用大型代码库的开发者和自动化编程工具使用者。

当人类要求大模型使用大型代码库中的功能完成编程任务时,如何提供有效的代码库上下文?一种方法是将整个仓库加入模型上下文,但多数任务仅涉及仓库中极少部分符号,过长上下文会损害模型推理能力,且上下文窗口有限。另一种思路是模拟人类导航仓库、提取合适功能并制定解决方案的能力。本文提出MutaGReP(Mutation-guided Grounded Repository Plan Search),一种在计划空间中进行神经树搜索的方法,通过变异生成新计划,并利用符号检索器实现代码库锚定。在具有挑战性的LongCodeArena基准上,其生成的计划仅使用了GPT-4o 128K上下文窗口的不到5%,却达到了与全库上下文输入下GPT-4o相当的编码性能。MutaGReP生成的计划使Qwen 2.5 Coder 32B和72B模型在性能上匹配拥有完整代码库上下文的GPT-4o,并推动解决了最困难的LongCodeArena任务。

原文摘要 · Abstract (English)

When a human requests an LLM to complete a coding task using functionality from a large code repository, how do we provide context from the repo to the LLM? One approach is to add the entire repo to the LLM's context window. However, most tasks involve only fraction of symbols from a repo, longer contexts are detrimental to the LLM's reasoning abilities, and context windows are not unlimited. Alternatively, we could emulate the human ability to navigate a large repo, pick out the right functionality, and form a plan to solve the task. We propose MutaGReP (Mutation-guided Grounded Repository Plan Search), an approach to search for plans that decompose a user request into natural language steps grounded in the codebase. MutaGReP performs neural tree search in plan space, exploring by mutating plans and using a symbol retriever for grounding. On the challenging LongCodeArena benchmark, our plans use less than 5% of the 128K context window for GPT-4o but rival the coding performance of GPT-4o with a context window filled with the repo. Plans produced by MutaGReP allow Qwen 2.5 Coder 32B and 72B to match the performance of GPT-4o with full repo context and enable progress on the hardest LongCodeArena tasks. Project page: zaidkhan.me/MutaGReP

代码生成大模型检索增强智能编程

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