让代码生成能记住失败经验,持续优化结果。
Persistent Cross-Attempt State Optimization for Repository-Level Code Generation
- 跨尝试保留成功与失败知识,指导后续生成
- 功能得分提升22.94%,重复使用率高达81.58%
- 适合需要多次调试的复杂项目生成场景
大型语言模型在仓库级代码生成方面已取得显著进展。然而,解决同一仓库级任务通常需多次尝试,现有方法仍孤立优化每次尝试,未能保留或复用任务特定状态。本文提出LiveCoder,一种基于跨尝试知识优化的仓库级代码生成新框架。LiveCoder保持先前尝试中的任务特定状态以引导后续生成,包括可复用的成功信号、失败结果及其诊断信息,以及迄今最优仓库的持久保存,防止性能退化。这些组件共同将重复生成转化为持续的知识驱动优化过程。我们在两个代表性基准上使用四种前沿LLM评估LiveCoder。大量实验表明其有效且高效:在RAL-Bench上功能得分最高提升22.94个百分点,仓库复用率达81.58%,成本降低最多达53.63%,同时维持稳定的非功能性质量。
原文摘要 · Abstract (English)
Large language models (LLMs) have achieved substantial progress in repository-level code generation. However, solving the same repository-level task often requires multiple attempts, while existing methods still optimize each attempt in isolation and do not preserve or reuse task-specific state across attempts. In this paper, we propose LiveCoder, a novel framework for repository-level code generation based on cross-attempt knowledge optimization. LiveCoder maintains persistent task-specific state from prior attempts to guide subsequent generation. This state includes success knowledge, which captures reusable signals from previously strong repositories, failure knowledge, which records unsuccessful outcomes and their diagnostic signals, and a historical-best repository, which preserves the strongest result found so far and prevents regression. These components collectively transform repeated repository generation into a persistent, knowledge-driven optimization process. We evaluate LiveCoder using four frontier LLMs on two representative repository-level code generation benchmarks. Extensive experimental results demonstrate the effectiveness and efficiency of LiveCoder, improving the functional score by up to 22.94 percentage points, increasing repository reuse to 81.58%, and reducing cost by up to 53.63% on RAL-Bench while maintaining broadly stable non-functional quality.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。