CodeMEM: 基于AST的适应性内存用于仓库级迭代代码生成
CodeMEM: AST-Guided Adaptive Memory for Repository-Level Iterative Code Generation
AI总结:
CodeMEM通过基于AST的动态内存管理,提升仓库级迭代代码生成的指令遵循能力与效率。
摘要:
大型语言模型(LLMs)通过交互式协作显著提高了仓库级代码生成的开发人员生产力。然而,随着交互的进行,必须持续保存和更新仓库上下文以整合新验证的信息。同时,扩展的会话历史增加了认知负担,常常导致遗忘和重新引入先前解决的错误。现有内存管理方法显示出潜力,但受限于以自然语言为中心的表示。为克服这些限制,我们提出了CodeMEM,一种针对仓库级迭代代码生成定制的基于AST的动态内存管理系统。具体而言,CodeMEM引入了Code Context Memory组件,通过AST引导的LLM操作动态维护和更新仓库上下文,以及Code Session Memory,构建以代码为中心的交互历史表示,并通过基于AST的分析显式检测并缓解遗忘。在指令遵循基准CodeIF-Bench和代码生成基准CoderEval上的实验结果表明,CodeMEM实现了最先进的性能,提高了当前轮次的指令遵循能力12.2%,提高了会话级别的指令遵循能力11.5%,并减少了2-3次交互轮次,同时保持了具有竞争力的推理延迟和令牌效率。
英文摘要:
Large language models (LLMs) substantially enhance developer productivity in repository-level code generation through interactive collaboration. However, as interactions progress, repository context must be continuously preserved and updated to integrate newly validated information. Meanwhile, the expanding session history increases cognitive burden, often leading to forgetting and the reintroduction of previously resolved errors. Existing memory management approaches show promise but remain limited by natural language-centric representations. To overcome these limitations, we propose CodeMEM, an AST-guided dynamic memory management system tailored for repository-level iterative code generation. Specifically, CodeMEM introduces the Code Context Memory component that dynamically maintains and updates repository context through AST-guided LLM operations, along with the Code Session Memory that constructs a code-centric representation of interaction history and explicitly detects and mitigates forgetting through AST-based analysis. Experimental results on the instruction-following benchmark CodeIF-Bench and the code generation benchmark CoderEval demonstrate that CodeMEM achieves state-of-the-art performance, improving instruction following by 12.2% for the current turn and 11.5% for the session level, and reducing interaction rounds by 2-3, while maintaining competitive inference latency and token efficiency.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。